From 93b1078a24e905be1a5469739fec187060b96783 Mon Sep 17 00:00:00 2001 From: deepsweet Date: Sat, 29 Sep 2012 14:26:26 +0400 Subject: [PATCH] plugins/moveElemsAttrsToGroup: fix bug with a wrong attrs intersecting --- lib/tools.js | 2 ++ plugins/moveElemsAttrsToGroup.js | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) 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]); } }); - } }