From 0ad3a12213086e433c617fb951edaada6e7500f5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 10 Dec 2016 21:53:24 +0000 Subject: Remove self-closing tags from AST --- lib/html/simplify.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/html/simplify.js') diff --git a/lib/html/simplify.js b/lib/html/simplify.js index e05bde2..8ba37eb 100644 --- a/lib/html/simplify.js +++ b/lib/html/simplify.js @@ -21,7 +21,6 @@ function collapseNode(node) { var collapsers = { element: collapseElement, - selfClosingElement: identity, text: identity, forceWrite: identity }; @@ -61,7 +60,6 @@ function flatMap(values, func) { var emptiers = { element: elementEmptier, - selfClosingElement: neverEmpty, text: textEmptier, forceWrite: neverEmpty }; @@ -72,10 +70,10 @@ function neverEmpty(node) { function elementEmptier(element) { var children = removeEmpty(element.children); - if (children.length === 0) { + if (children.length === 0 && !ast.isVoidElement(element)) { return []; } else { - return ast.elementWithTag(element.tag, children); + return [ast.elementWithTag(element.tag, children)]; } } -- cgit v1.2.3