Skip to content

Instantly share code, notes, and snippets.

@garlicnation
Created January 19, 2016 23:39
Show Gist options
  • Save garlicnation/e6137465ecd2ba9aa022 to your computer and use it in GitHub Desktop.
Save garlicnation/e6137465ecd2ba9aa022 to your computer and use it in GitHub Desktop.
// findBodyElements returns a document fragment containing
// all elements that should be moved into body from a document-order
// array of elements in head, searching from startIndex to endIndex
function findBodyElements(flatHead, startIndex, endIndex) {
if (endIndex === -1) {
endIndex = flatHead.length;
}
var container = dom5.constructors.fragment();
for (var headidx = start, el; headidx < endIndex; headidx++) {
el = flatHead[headidx];
// if the element is a script, move it to bodyFragment
if (matchers.JS(el)) {
dom5.append(container, el);
}
}
return container
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment