[whatwg/dom] Misalignment between spec and WPT for "validate and extract" (Issue #1387)

shannonbooth created an issue (whatwg/dom#1387)

### What is the issue with the DOM Standard?

WPT has tests such as the following: https://github.com/web-platform-tests/wpt/blob/856c33e87e61f513ddc81e082f78b6d24027e83d/dom/nodes/Document-createElementNS.js#L69

Where qualified name in [validate and extract](https://dom.spec.whatwg.org/#validate-and-extract) (in this case, `":foo"`) ends up being something that begins with a colon.

As I understand, this means that when we strictly split that prefix on `":"`, `splitResult[0]` ends up being the empty string, and `localName` is `foo`.

Therefore when we hit step 5.

> 5. If prefix is not a [valid namespace prefix](https://dom.spec.whatwg.org/#valid-namespace-prefix), then [throw](https://webidl.spec.whatwg.org/#dfn-throw) an "[InvalidCharacterError](https://webidl.spec.whatwg.org/#invalidcharactererror)" [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException).

Since prefix is the empty string, a DOMException is thrown as the empty string is not a valid namespace. Sidenote: This step also can result in "null" being passed into the AO which expects a string.


I can get all WPT tests passing if:

>  5. If prefix is not a valid namespace prefix, then throw an "InvalidCharacterError" DOMException.

Is changed to:

>  5. If prefix non-null and not the empty and and is not a valid namespace prefix, then throw an "InvalidCharacterError" DOMException.

And:

> 8. If prefix is non-null and namespace is null, then throw a "NamespaceError" DOMException.

Is changed to:

> 8. If prefix is non-null and prefix is not the empty string and namespace is null, then throw a "NamespaceError" DOMException.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1387
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1387@github.com>

Received on Wednesday, 2 July 2025 09:22:30 UTC