Created
March 2, 2012 22:05
-
-
Save Raynos/1961715 to your computer and use it in GitHub Desktop.
Document Fragment builder
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
// http://jsfiddle.net/DMtAU/4/ | |
function Fragment(html) { | |
var range = document.createRange() | |
range.selectNode(document.body) | |
return range.createContextualFragment(html.replace(/%s/g, toString)) | |
function toString() { | |
return String(args[i++]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment