From 2e818b7beafe567a19447c81f9a033e32cc2022f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 23 Mar 2016 00:11:16 +0000 Subject: Improve collapsing of elements when there are empty elements Specifically, strip out empty nodes before attempting to collapse. --- tests/html/simplify.tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/html') diff --git a/tests/html/simplify.tests.js b/tests/html/simplify.tests.js index 2a16ba4..db7beb4 100644 --- a/tests/html/simplify.tests.js +++ b/tests/html/simplify.tests.js @@ -78,4 +78,18 @@ describe("simplify", function() { nonFreshElement("blockquote", {}, [nonFreshElement("p", {}, [text("there")])])])), fragment([nonFreshElement("blockquote", {}, [nonFreshElement("p", {}, [text("Hello"), text("there")])])])); }); + + test("empty elements are removed before collapsing", function() { + var freshPath = htmlPaths.elements([ + htmlPaths.element("p", {}, {fresh: true})]); + var nonFreshPath = htmlPaths.elements([ + htmlPaths.element("p", {}, {fresh: false})]); + assert.deepEqual( + html.simplify(fragment([ + pathToNode(nonFreshPath, [text("Hello")]), + pathToNode(freshPath, []), + pathToNode(nonFreshPath, [text(" there")])])), + fragment([ + pathToNode(nonFreshPath, [text("Hello"), text(" there")])])); + }); }); -- cgit v1.2.3