Closed thenoviceoof closed 10 years ago
Agreed but default behavior should not be changed for backward compatibility reasons. Instead, an CLI option should be added to indicate input is a document fragment. JSDOM should support doc fragments, I think.
innerHTML
might be used to get document fragment.
var jsdom = require("jsdom").jsdom;
var doc = jsdom("<html>", null, {});
doc.documentElement.innerHTML = "<span>Hello</span> <span>World</span>"
console.log(doc.documentElement.childNodes.item(0).nodeName);
console.log(doc.documentElement.childNodes.item(1).nodeName);
console.log(doc.documentElement.childNodes.item(2).nodeName);
doc.documentElement.innerHTML = "<html><head></head><documentElement></documentElement></html>"
console.log(doc.documentElement.childNodes.item(0).nodeName);
No CLI option for this yet? Is it posing a challenge or is it just not high priority?
No. Just not high priority. Sorry. Pull requests are welcome.
--bodyless
option in version 0.6.5+ disables default html and body wrappers.
In a templating/partial system, some html documents are included in other documents without being full pages. Auto wrapping each document in html/body seems unnecessary and not doing so facilitates the partial template case.
Example:
=>