aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-13 22:14:41 +0100
committerMichael Williamson <mike@zwobble.org>2015-10-13 22:14:41 +0100
commite04d054a1b414e843fa6d6f5ee1ae75c0df533b1 (patch)
tree4e6acf783e9ec47bbd47da9a7cc87e8093177209 /lib
parentaac776b1711d1e286812035a28108c622e73994a (diff)
Reuse matchesElement from HTML paths
Diffstat (limited to 'lib')
-rw-r--r--lib/html-paths.js2
-rw-r--r--lib/html/simplify.js2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/html-paths.js b/lib/html-paths.js
index b881131..04bc655 100644
--- a/lib/html-paths.js
+++ b/lib/html-paths.js
@@ -39,7 +39,7 @@ function Element(tagName, attributes, options) {
this.attributes = attributes || {};
this.fresh = options.fresh;
}
-
+
Element.prototype.matchesElement = function(element) {
return this.tagNames[element.tagName] && _.isEqual(this.attributes || {}, element.attributes || {});
};
diff --git a/lib/html/simplify.js b/lib/html/simplify.js
index 52a1b0a..291e5d4 100644
--- a/lib/html/simplify.js
+++ b/lib/html/simplify.js
@@ -29,7 +29,7 @@ function simplifyNodes(nodes) {
nodes.map(simplify).forEach(function(child) {
var lastChild = children[children.length - 1];
- if (child.type === "element" && !child.tag.fresh && lastChild && _.isEqual(lastChild.tag, child.tag)) {
+ if (child.type === "element" && !child.tag.fresh && lastChild && child.tag.matchesElement(lastChild.tag)) {
child.children.forEach(function(grandChild) {
// Mutation is fine since simplifying elements create a copy of the children.
lastChild.children.push(grandChild);