diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-03-23 00:11:16 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-03-23 00:11:16 +0000 |
| commit | 2e818b7beafe567a19447c81f9a033e32cc2022f (patch) | |
| tree | 18ff106e289c73cf5cb8f5c65214dc8c3c78fda7 /tests/html | |
| parent | b8b685562a374bc14719fa1746477a6916fe0da8 (diff) | |
Improve collapsing of elements when there are empty elements
Specifically, strip out empty nodes before attempting to collapse.
Diffstat (limited to 'tests/html')
| -rw-r--r-- | tests/html/simplify.tests.js | 14 |
1 files changed, 14 insertions, 0 deletions
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")])])); + }); }); |
