From a12b966752ba7ae880f7d6348a42cc986e891a82 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 28 Nov 2016 21:08:40 +0000 Subject: Map breaks with style maps --- lib/html/ast.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib/html') diff --git a/lib/html/ast.js b/lib/html/ast.js index c949550..34b9a3d 100644 --- a/lib/html/ast.js +++ b/lib/html/ast.js @@ -8,12 +8,8 @@ function nonFreshElement(tagName, attributes, children) { } function freshElement(tagName, attributes, children) { - if (isVoidElement(tagName, children)) { - return selfClosingElement(tagName, attributes); - } else { - var tag = htmlPaths.element(tagName, attributes, {fresh: true}); - return elementWithTag(tag, children); - } + var tag = htmlPaths.element(tagName, attributes, {fresh: true}); + return elementWithTag(tag, children); } var voidTagNames = { @@ -22,16 +18,20 @@ var voidTagNames = { "img": true }; -function isVoidElement(tagName, children) { - return (!children || children.length === 0) && voidTagNames[tagName]; +function elementWithTag(tag, children) { + if (isVoidElement(tag.tagName, children)) { + return selfClosingElement(tag.tagName, tag.attributes); + } else { + return { + type: "element", + tag: tag, + children: children || [] + }; + } } -function elementWithTag(tag, children) { - return { - type: "element", - tag: tag, - children: children || [] - }; +function isVoidElement(tagName, children) { + return (!children || children.length === 0) && voidTagNames[tagName]; } function selfClosingElement(tagName, attributes) { -- cgit v1.2.3