- From: Codifier <notifications@github.com>
- Date: Tue, 31 Jul 2018 04:20:27 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/671/409185870@github.com>
But `Name` is *not* a subset of `QName`.
[`QName`](https://www.w3.org/TR/xml-names/#NT-QName) allows for only one colon which *must* be preceded by a [`NCName`](https://www.w3.org/TR/xml-names/#NT-NCName):
QName ::= PrefixedName | UnprefixedName
PrefixedName ::= Prefix ':' LocalPart
UnprefixedName ::= LocalPart
Prefix ::= NCName
LocalPart ::= NCName
[`Name`](https://www.w3.org/TR/REC-xml/#NT-Name), however, allows for multiple colons, even at the start of the token:
NameStartChar ::= ":" | [A-Z] /* etc. */
NameChar ::= NameStartChar | "-" /* etc. */
Name ::= NameStartChar (NameChar)*
As an aside:
In my previous comments my interpretation of how lenient `createElementNS()` actually is, was incorrect. I interpreted it as though a `null` namespace allowed for a `Name` production element name, and I even thought I was reassured by testing it in Firefox, but it seems I must have confused a `createElement()` test with a `createElementNS()` test, in that I thought the latter actually allowed `createElementNS( null, '::p' )`. However, it doesn't, as it *shouldn't* anyway, now that I've inspected the specs more carefully. In other words `createElement( '::p' )` does not produce the same result as `createElementNS( null, '::p' )`.
This is the outcome of some tests in Firefox 61:
console.log( document.createElement( 'p' ) ) /* <p> */
console.log( document.createElement( ':p' ) ) /* <:p> */
console.log( document.createElement( '::p' ) ) /* <::p> */
console.log( document.createElementNS( 'my-namespace', 'mn:p' ) ) /* <mn:p>*/
console.log( document.createElementNS( null, 'p' ) ) /* <p> */
console.log( document.createElementNS( null, '::p' ) ) /* throws InvalidCharacterError */
console.log( document.createElementNS( null, ':p' ) ) /* throws InvalidCharacterError */
console.log( document.createElementNS( null, 'mn:p' ) ) /* throws NamespaceError */
So, to conclude:
`Name` is not a subset of `QName` and the specs for `createElementNS()` should *not* allow `Name`, given its current state. Unless, of course, the goal is to actually let it be more lenient, in that it would, for instance, accept `createElementNS( null, '::p' )` as valid.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/671#issuecomment-409185870
Received on Tuesday, 31 July 2018 11:21:38 UTC