don't throw error on comments in template converter

This commit is contained in:
Leo Horie 2014-08-12 18:01:11 -04:00
parent c736e738ce
commit 7f62ab4954

View file

@ -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 = ""