DOMImplementation hates HTML5

This doesn’t work:

documentType = impl.createDocumentType("html", "", "");
document = impl.createDocument(null, "html", documentType);
document.getElementsByTagName("html").item(0).appendChild(document.createElement("head"));

assertNotNull(document.getChildNodes().item(0).getChildNodes().item(0));
assertEquals("head", document.getChildNodes().item(0).getChildNodes().item(0).getNodeName());

In fact, it just silently fails to add any child nodes. No exceptions, nada.

This gives the same result:

documentType = impl.createDocumentType("html", null, null);
document = impl.createDocument(null, "html", documentType);
document.getElementsByTagName("html").item(0).appendChild(document.createElement("head"));

assertNotNull(document.getChildNodes().item(0).getChildNodes().item(0));
assertEquals("head", document.getChildNodes().item(0).getChildNodes().item(0).getNodeName());

But *this* does work:

documentType = impl.createDocumentType("html", " ", " ");
document = impl.createDocument(null, "html", documentType);
document.getElementsByTagName("html").item(0).appendChild(document.createElement("head"));

assertNotNull(document.getChildNodes().item(0).getChildNodes().item(0));
assertEquals("head", document.getChildNodes().item(0).getChildNodes().item(0).getNodeName());

Gah!

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment