Created
October 22, 2012 10:30
-
-
Save bloodyowl/3930814 to your computer and use it in GitHub Desktop.
String to Element
This file contains 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
String.prototype.toElement = function() { | |
var childNodes, fragment, i, item, sandbox, _i, _len; | |
sandbox = document.createElement("div"); | |
fragment = document.createDocumentFragment(); | |
sandbox.innerHTML = this; | |
childNodes = $A(sandbox.childNodes); | |
for (i = _i = 0, _len = childNodes.length; _i < _len; i = ++_i) { | |
item = childNodes[i]; | |
fragment.appendChild(item); | |
} | |
return fragment; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment