From 7f62ab49549f9cb8572740efc5532cc65f778793 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 12 Aug 2014 18:01:11 -0400 Subject: [PATCH] don't throw error on comments in template converter --- docs/layout/tools/template-converter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/layout/tools/template-converter.js b/docs/layout/tools/template-converter.js index 5501df8e..8f33d623 100644 --- a/docs/layout/tools/template-converter.js +++ b/docs/layout/tools/template-converter.js @@ -12,13 +12,13 @@ templateConverter.VirtualFragment = function recurse(domFragment) { if (el.nodeType == 3) { virtualFragment.push(el.nodeValue); } - else { + else if (el.nodeType == 1) { var attrs = {}; for (var j = 0, attr; attr = el.attributes[j]; j++) { attrs[attr.name] = attr.value; } - virtualFragment.push({tag: el.tagName.toLowerCase(), attrs: attrs, children: recurse(el.childNodes)}); + virtualFragment.push({tag: el.nodeName.toLowerCase(), attrs: attrs, children: recurse(el.childNodes)}); } } return virtualFragment; @@ -49,6 +49,7 @@ templateConverter.Template = function recurse() { for (var j = 0, attrName; attrName = attrNames[j]; j++) { if (attrName != "style") virtual += "[" + attrName + "='" + el.attrs[attrName].replace(/'/g, "\\'") + "']"; } + if (virtual == "") virtual = "div" virtual = '"' + virtual + '"'; var style = ""