Because I am a glutton for embarrassment, I have another in my series of stupid questions about synthetic documents in JavaScript.
So here goes: createDocument
, createHTMLDocument
, new Document()
and DOMParser.parseFromString()
all return new documents. While the first three all return complete documents, documents returned by DOMParser.parseFromString()
are uninitialized. Any idea why? (I'm betting on some stupid JavaScript error on my part.)
Here's some code if you want to test:
<script>
function doit() {
var doc1 = document.implementation.createDocument (null, 'html', null);
console.log(doc1.readyState); // complete
var doc2 = document.implementation.createHTMLDocument("HTML Doc");
console.log(doc2.readyState); // complete
var doc3 = new Document();
console.log(doc3.readyState); // complete
var parser = new DOMParser;
var doc4 = parser.parseFromString("<!doctype html>", "text/html");
console.log(doc4.readyState); // uninitialized
}
window.onload = doit;
</script>
ETA: Above are the results on Firefox. Chrome returns "interactive." Still not sure why.