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!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s