Created
August 13, 2010 18:50
-
-
Save alunny/523349 to your computer and use it in GitHub Desktop.
a stab at a new wrap function for xui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// private method | |
// Wraps the HTML in a TAG, Tag is optional | |
// If the html starts with a Tag, it will wrap the context in that tag. | |
// doesn't ACTUALLY work | |
function wrap(xhtml, tag) { | |
// new approach | |
// createDocumentFragment | |
var docFrag = document.createDocumentFragment(), | |
dummy, | |
wrapTag; | |
if (tag) { | |
wrapTag = document.createElement(tag); | |
wrapTag.innerHTML = xhtml; | |
docFrag.appendChild(wrapTag); | |
} else { | |
dummy = document.createElement('div'), | |
dummy.innerHTML = xhtml; | |
while (dummy.children.length) | |
docFrag.appendChild(dummy.children[0]); | |
} | |
return docFrag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment