diff --git a/src/jqLite.js b/src/jqLite.js index d03ea67b4..a471d3742 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -205,17 +205,19 @@ function jqLiteIsTextNode(html) { function jqLiteBuildFragment(html, context) { var elem, tmp, tag, wrap, fragment = context.createDocumentFragment(), - nodes = [], i; + nodes = [], i, j, jj; if (jqLiteIsTextNode(html)) { // Convert non-html into a text node nodes.push(context.createTextNode(html)); } else { + tmp = fragment.appendChild(context.createElement('div')); // Convert html into DOM nodes - tmp = tmp || fragment.appendChild(context.createElement("div")); tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase(); wrap = wrapMap[tag] || wrapMap._default; - tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; + tmp.innerHTML = '
 
' + + wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; + tmp.removeChild(tmp.firstChild); // Descend through wrappers to the right content i = wrap[0]; @@ -223,7 +225,7 @@ function jqLiteBuildFragment(html, context) { tmp = tmp.lastChild; } - nodes = concat(nodes, tmp.childNodes); + for (j=0, jj=tmp.childNodes.length; j