createElement restrictions on names do not match innerHTML-parseable names

Domenic Denicola <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <B4AE8F4E86E26C47AC407D49872F6F9F878601E7@BY2PRD0510MB354.namprd05.prod.outlook.com>
>From http://dom.spec.whatwg.org/#dom-document-createelement:

> If localName does not match the Name production, throw an "InvalidCharacterError" exception and terminate these steps.

The "Name" production links to http://www.w3.org/TR/xml/#NT-Name, which says:

```
[4]   	NameStartChar	   ::=   	":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a]   	NameChar	   ::=   	NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5]   	Name	   ::=   	NameStartChar (NameChar)*
```

And indeed, browsers will throw such an error. But they accept such element names when parsing HTML, e.g.

http://jsconsole.com/?document.body.innerHTML%3D%22%3Ca\0%20href%3D%27foo%27%3E%3Cb%3E%22%3Bdocument.body.children[0].tagName

http://jsconsole.com/?document.body.innerHTML%3D%22%3Ca\xD7%20href%3D%27foo%27%3E%3Cb%3E%22%3Bdocument.body.children[0].tagName

Is this mismatch intentional? Does it make sense?

In particular, this makes it impossible to explain the behavior of the parser in terms of JS, as we try to do in [jsdom](https://github.com/tmpvar/jsdom).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.