diff --git a/lib/tools.js b/lib/tools.js index fd14b414..b9de4835 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -106,6 +106,8 @@ exports.intersectAttrs = function(a, b) { } }); + if (!Object.keys(c).length) return false; + return c; }; diff --git a/plugins/moveElemsAttrsToGroup.js b/plugins/moveElemsAttrsToGroup.js index ac223585..d7ae2634 100644 --- a/plugins/moveElemsAttrsToGroup.js +++ b/plugins/moveElemsAttrsToGroup.js @@ -34,22 +34,23 @@ exports.moveElemsAttrsToGroup = function(item, params) { if (!Object.keys(intersection).length) { intersection = g.attrs; } else { - intersection = intersectAttrs(intersection, g.attrs) + intersection = intersectAttrs(intersection, g.attrs); + + if (!intersection) return false; } return true; } }); - if (every && Object.keys(intersection).length) { + if (every) { item.content.forEach(function(g) { for (var name in intersection) { g.removeAttr(name); item.addAttr(intersection[name]); } }); - } }