Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created March 2, 2012 22:05
Show Gist options
  • Save Raynos/1961715 to your computer and use it in GitHub Desktop.
Save Raynos/1961715 to your computer and use it in GitHub Desktop.
Document Fragment builder
// 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