Skip to content

Allow more characters in custom element names - #7991

Merged
domenic merged 2 commits into
mainfrom
pcne-loosening
Jun 9, 2025
Merged

domenic merged 2 commits into
mainfrom
pcne-loosening

Conversation

@domenic domenic added normative change topic: custom elements Relates to custom elements (as defined in DOM and HTML) labels Jun 7, 2022
@domenic
domenic requested a review from annevk June 7, 2022 16:24

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I like how this simplifies things quite a bit and reduces our reliance on ABNF and derivatives.

@annevk

annevk commented Jun 8, 2022

Copy link
Copy Markdown
Member

Hmm, I guess 0th is technically correct, but I wonder if we are using that consistently. Perhaps we should support string[0] to make it less confusing?

@domenic

domenic commented Jun 8, 2022

Copy link
Copy Markdown
Member Author

I doubt we are using it consistently. But the algorithms in https://infra.spec.whatwg.org/#strings use it indirectly quite a lot, e.g. "Let potentialPrefixCodeUnit be the ith code unit of potentialPrefix." where i can be 0. And the plus side is that nobody will be confused by 0th, although they might be confused by first.

Allowing string[0] is a bit tricky IMO because it doesn't clarify whether that's code point or code unit. Maybe string[0]cu and string[0]cp, but that feels a bit like adding notation for notation's sake...

@domenic domenic added the needs tests Moving the issue forward requires someone to write tests label Jun 14, 2022
@josepharhar

Copy link
Copy Markdown
Contributor

Thanks for removing the EBNF, it is much easier for me to read and implement this way!

@domenic

domenic commented May 19, 2025

Copy link
Copy Markdown
Member Author

I've rebased this onto main. It was pretty straightforward.

Comment thread source Resolved
Comment thread source Resolved
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 5, 2025
This patch changes the parsing of custom element names in DOM APIs to
allow more flexibility and better parity with the HTML parser.

Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I516de464254c5413e5610aedc3a70a73ea236616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6559428
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1470050}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 5, 2025
This patch changes the parsing of custom element names in DOM APIs to
allow more flexibility and better parity with the HTML parser.

Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I516de464254c5413e5610aedc3a70a73ea236616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6559428
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1470050}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 5, 2025
This patch changes the parsing of custom element names in DOM APIs to
allow more flexibility and better parity with the HTML parser.

Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I516de464254c5413e5610aedc3a70a73ea236616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6559428
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1470050}
@josepharhar

Copy link
Copy Markdown
Contributor

@domenic domenic removed the needs tests Moving the issue forward requires someone to write tests label Jun 6, 2025
@domenic

domenic commented Jun 6, 2025

Copy link
Copy Markdown
Member Author

I'll plan on merging this and github.com/whatwg/dom/pull/1079 on Monday or Tuesday. Thanks @josepharhar for helping finish this up!!

@domenic
domenic merged commit 78d2678 into main Jun 9, 2025
@domenic
domenic deleted the pcne-loosening branch June 9, 2025 04:47
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 13, 2025
Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I216706db819aee655c7e05fd492eed546f449a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6615057
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1473709}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 13, 2025
Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I216706db819aee655c7e05fd492eed546f449a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6615057
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1473709}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 13, 2025
Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I216706db819aee655c7e05fd492eed546f449a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6615057
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1473709}
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jun 19, 2025
…names, a=testonly

Automatic update from web-platform-tests
Allow more characters in custom element names

This patch changes the parsing of custom element names in DOM APIs to
allow more flexibility and better parity with the HTML parser.

Spec PR: whatwg/html#7991

Bug: 40122442, 40228234
Change-Id: I516de464254c5413e5610aedc3a70a73ea236616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6559428
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1470050}

--

wpt-commits: 1f3beebca7401634153d6d14c00742b29edbd072
wpt-pr: 52982
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jan 15, 2026
…efixes r=smaug,dom-core,devtools-reviewers,ochameau

Implement "relaxed" element/attribute name-validation rules, per:

- whatwg/dom#1079
- whatwg/html#7991
- whatwg/html#11453

That aligns DOM-API name behavior with HTML parser behavior - which has
always allowed a wider range of characters in element and attribute names.

New validation functions in nsContentUtils:

- IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute -
  no null, whitespace, /, >, or =
- IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or >
- IsValidDoctypeName(): For createDocumentType - no null, whitespace, or >
- ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules

ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm
per the DOM spec: for qualified names with multiple colons like "f:o:o", the
local name is just the second token ("o"), not everything after the first colon
("o:o"). This matches the spec's requirement to split on all colons and use only
splitResult[0] as prefix and splitResult[1] as localName.

Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name
validation rules; WPT name-validation.html provides coverage for the new
relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass.

Differential Revision: https://phabricator.services.mozilla.com/D277822
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Feb 18, 2026
…efixes r=smaug,dom-core,devtools-reviewers,ochameau

Implement "relaxed" element/attribute name-validation rules, per:

- whatwg/dom#1079
- whatwg/html#7991
- whatwg/html#11453

That aligns DOM-API name behavior with HTML parser behavior - which has
always allowed a wider range of characters in element and attribute names.

New validation functions in nsContentUtils:

- IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute -
  no null, whitespace, /, >, or =
- IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or >
- IsValidDoctypeName(): For createDocumentType - no null, whitespace, or >
- ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules

ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm
per the DOM spec: for qualified names with multiple colons like "f:o:o", the
local name is just the second token ("o"), not everything after the first colon
("o:o"). This matches the spec's requirement to split on all colons and use only
splitResult[0] as prefix and splitResult[1] as localName.

Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name
validation rules; WPT name-validation.html provides coverage for the new
relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass.

Differential Revision: https://phabricator.services.mozilla.com/D277822
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Feb 19, 2026
…efixes r=smaug,dom-core,devtools-reviewers,ochameau

Implement "relaxed" element/attribute name-validation rules, per:

- whatwg/dom#1079
- whatwg/html#7991
- whatwg/html#11453

That aligns DOM-API name behavior with HTML parser behavior - which has
always allowed a wider range of characters in element and attribute names.

New validation functions in nsContentUtils:

- IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute -
  no null, whitespace, /, >, or =
- IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or >
- IsValidDoctypeName(): For createDocumentType - no null, whitespace, or >
- ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules

ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm
per the DOM spec: for qualified names with multiple colons like "f:o:o", the
local name is just the second token ("o"), not everything after the first colon
("o:o"). This matches the spec's requirement to split on all colons and use only
splitResult[0] as prefix and splitResult[1] as localName.

Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name
validation rules; WPT name-validation.html provides coverage for the new
relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass.

Differential Revision: https://phabricator.services.mozilla.com/D277822
webkit-commit-queue pushed a commit to sideshowbarker/WebKit that referenced this pull request Mar 8, 2026
https://bugs.webkit.org/show_bug.cgi?id=241419

Reviewed by Darin Adler.

Implement relaxed name-validation rules per whatwg/dom#1079, whatwg/html#7991,
and whatwg/html#11453. This aligns DOM API name behavior with HTML parser behavior —
which has always allowed a wider range of characters in element and attribute names.

New validation functions in NameValidation.h/cpp:

- isValidElementName(): For createElement — allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- isValidAttributeName(): For setAttribute/toggleAttribute/createAttribute —
  no null, whitespace, /, >, or =
- isValidNamespacePrefix(): For *NS methods — no null, whitespace, /, or >
- isValidDoctypeName(): For createDocumentType — no null, whitespace, or >
- isValidXMLName(): Preserves old XML Name production for createProcessingInstruction

* LayoutTests/fast/dom/dataset-expected.txt:
* LayoutTests/fast/dom/dataset-xhtml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument.html:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocumentType-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createAttribute-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS.html:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS.js:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/attributes-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/name-validation-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/dataset-set-expected.txt:
* LayoutTests/platform/glib/http/tests/misc/acid3-expected.txt:
* LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocumentType):
* Source/WebCore/dom/Document.cpp:
(WebCore::createHTMLElementWithNameValidation):
(WebCore::Document::createElementForBindings):
(WebCore::Document::createProcessingInstruction):
(WebCore::Document::createElementNS):
(WebCore::Document::createAttribute):
(WebCore::Document::createAttributeNS):
(WebCore::isValidNameStart): Deleted.
(WebCore::isValidNamePart): Deleted.
(WebCore::isValidHTMLElementName):
(WebCore::Document::hasValidNamespaceForElements): Deleted.
(WebCore::Document::hasValidNamespaceForAttributes): Deleted.
(WebCore::isValidNameNonASCII): Deleted.
(WebCore::isValidNameASCII): Deleted.
(WebCore::isValidNameASCIIWithoutColon): Deleted.
(WebCore::Document::isValidName): Deleted.
(WebCore::Document::parseQualifiedName): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::toggleAttribute):
(WebCore::Element::setAttribute):
(WebCore::Element::setAttributeNS):
(WebCore::Element::parseAttributeName):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/NameValidation.cpp: Added.
(WebCore::NameValidation::isInvalidAttributeNameCharacter):
(WebCore::NameValidation::isInvalidElementNameCharacterAfterAlphaStart):
(WebCore::NameValidation::isValidElementNameContinuationCharacter):
(WebCore::NameValidation::isInvalidNamespacePrefixCharacter):
(WebCore::NameValidation::isInvalidDoctypeNameCharacter):
(WebCore::NameValidation::isValidElementName):
(WebCore::NameValidation::isValidAttributeName):
(WebCore::NameValidation::isValidNamespacePrefix):
(WebCore::NameValidation::isValidDoctypeName):
(WebCore::NameValidation::isValidASCIIXMLName):
(WebCore::NameValidation::isValidXMLNameStart):
(WebCore::NameValidation::isValidXMLNamePart):
(WebCore::NameValidation::isValidXMLName):
(WebCore::NameValidation::parseQualifiedNameToPair):
(WebCore::NameValidation::parseQualifiedElementName):
(WebCore::NameValidation::parseQualifiedAttributeName):
(WebCore::NameValidation::hasValidNamespaceForElements):
(WebCore::NameValidation::hasValidNamespaceForAttributes):
* Source/WebCore/dom/NameValidation.h: Added.
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::checkSetPrefix):
* Source/WebCore/dom/ProcessingInstruction.cpp:
* Source/WebCore/editing/EditorCommand.cpp:
(WebCore::executeFormatBlock):
* Source/WebCore/svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::constructAttributeName const):
* Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::handleNamespaceAttributes):
(WebCore::handleElementAttributes):

Canonical link: https://commits.webkit.org/308884@main
Koukyosyumei added a commit to h5i-dev/h5i that referenced this pull request Aug 28, 2026
Four separate defects, each of which repeated across every element or every
call site, found by reading what the failures actually said.

**The reflection type system, four bugs, all of them per-element.**

* `-0` is not a value an IDL long may report. `Number("-0")` is negative zero,
  reflections are integers, and testharness compares with `Object.is`
  semantics — so `tabindex="-0"` failed an `assert_equals(0)` on *every*
  element in every `reflection-*.html` file. `tabIndex` has its own parser, so
  it needed the same fix twice.
* Out of the 32-bit range is "not a valid integer" for a reflection rather than
  a large number: `marquee.hspace = 2147483648` read back as itself instead of
  the default.
* `[LegacyNullToEmptyString]`, which the legacy presentational colour
  attributes carry: `body.bgColor = null` writes "" and not "null". Marked per
  attribute, because everywhere else `null` really does stringify and a browser
  agrees.
* `form.action` and `input.formAction` answer with the document's address when
  the attribute is missing or empty. A form whose action reads "" submits
  somewhere different from one that reads the page's URL.

**Nine element interfaces the table never had** — meter, progress, iframe, del,
q, th, thead, tfoot, colgroup — plus a `double` reflection for meter and
progress. A missing entry there is not one attribute missing, it is every
attribute of that element failing at once; `ins` was present and `del` was not,
`td` was present and `th` was not.

`crossOrigin` is one nullable enumerated attribute and was spelled out on
`<link>` while `<img>`, `<script>`, `<video>` and `<audio>` had it as a plain
string. One definition now, and a nullable enumerated removes its attribute when
set to null or undefined. `document.dir` reflects `<html dir>` and was absent.

    html/dom  56,241 -> 57,080

**Custom element names were validated by one rule out of eight.** The dash was
checked; uppercase, the leading character, the eight reserved SVG/MathML
compound names and the local-name character rule were not — so this engine
accepted names a browser refuses, after which the page and the engine disagree
about what `<font-face>` is. It throws a `DOMException` now, which is what
`assert_throws_dom` checks and what the old unit test had pinned wrongly.

Two things this got wrong on the way, both worth recording:

* The first implementation used `PotentialCustomElementNameChar`, which is the
  *superseded* production. whatwg/html#7991 replaced it with "a valid element
  local name", which excludes rather than includes — so the old rule rejected
  names that are now legal, failing the file in the opposite direction from the
  one it was written to fix.
* `whenDefined` did not validate, so once `define` threw correctly the test
  reached `await promise_rejects_dom(t, 'SyntaxError', whenDefined(bad))` and
  hung there, taking all 5,900 subtests with it. A promise that never settles
  is the worst of the three answers: a caller cannot tell it from a component
  that has not loaded, so it waits out its own timeout instead of handling an
  error it could have handled at once.

`valid-custom-element-names.html`: 222 of 1,975 passing -> **1,975 of 1,975**.

**URL and body plumbing.** `new URLSearchParams(otherParams)` walked the
object's own keys, so it copied the internal `_pairs` field and serialised as
`_pairs=a%2Cb` — a params object emitting its own implementation. It takes any
iterable of pairs now. Added `sort()`, `size`, form-urlencoded serialisation
(`+` for space, and the escapes `encodeURIComponent` leaves alone), the
`URL.parse`/`URL.canParse` statics, and `formData`/`arrayBuffer`/`blob` on both
`Request` and `Response`.

    url  68 -> 148 of 499

585 tests, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
Koukyosyumei added a commit to h5i-dev/h5i that referenced this pull request Aug 28, 2026
…s content (#569)

* update

* update

* browser: the instruments, and a flag that copied a file nothing wrote (#B19)

A second pass over Obscura, focused on how it *measures* rather than on its
verb surface — §B15 settled that half in August and almost all of it shipped.
The finding that reversed the shape of this work: the verb-line comparison is
closed and the instrument comparison is not.

Eleven of twelve queued items shipped. The twelfth was measured and reverted,
which is the one worth reading.

The engine:

* `--allow-any-remote`, the instrument grant the corpus and the sweep were both
  blocked on. It widens the *name* check only, and that took one more change
  than expected: `check_address` sends an IP-literal host back to the allowlist,
  so a blanket grant would have become a route into RFC 1918 space by spelling.
  The allowlist match is split out as `Policy::listed` and the address check
  asks that narrower question.
* A `screenshot` verb on the session — the one thing an agent driving a live
  page could not do. First user of `browser_session::artifact_path`, which was
  written for exactly this and had no caller: h5i names the file, the engine
  chooses only the bytes. Refused during LOGIN mode, because a password is
  pixels before it is anything else.
* `reload`, routed through `navigate_to` so it is policy-checked and drops the
  served refs by construction rather than by remembering to.
* The cookie jar persists when h5i passes `--cookie-jar`, written on change
  rather than at exit (a session is stopped with a signal), 0600,
  temp-then-rename. `--restore` therefore works: it had been copying a
  `cookies.json` that nothing in the workspace ever wrote, so the flag was a
  silent no-op under help text promising an inherited login. A session that
  left no jar is now refused by name.
* Import maps. The bare-specifier refusal keeps its exact target — the engine
  must not invent a CDN — because a map is the *page* naming the destination in
  markup the parser already read.

The instruments:

* `harness.py`, which is the actual fix for the corpus bug: not three wrong
  paths but three copies of the answer. `corpus/run.py` and `corpus/compare.py`
  had been pointed at `target/*/h5i-browser-light` since the engine became a
  library, so neither had run, and the hand-built allowlist they carried made a
  page pulling from an unlisted CDN look like an engine failure.
* `reliability/sweep.py`: crawl, sweep, and classify into CRASH / PANIC / HANG /
  HANG_HARD / REFUSED / THIN / OK. REFUSED is ours and is not in theirs, because
  a policy refusal is this engine working.
* `wpt/tiers.list` and `wpt/tiers.py`, which turn §B13.3's caveat from prose
  into a table: core 59,953, encoding 225,786, headline 79% encoding, said by
  construction. Plus a triage rollup that groups failure messages across a
  sweep — 8,425 subtests failing on one shape, on the first run.
* `wpt/wptserve.py`, which puts §B17's CORS, §B16.5's PSL cookies and §B17.4's
  compression under external test for the first time. The https variants are
  dropped by name: wptserve serves them under its own CA and this engine trusts
  webpki-roots with no way to add a root, so they would fail on a trust decision
  recorded as a conformance result.
* `capability/`, nine offline stages with the frameworks vendored. 9/9: React
  18, Preact, Vue 3, hydration, a fetch+pushState SPA, the modern language and
  platform surface, timer ordering, and the import map above. Timing reported,
  never gated.

And the one that did not survive: batching WPT files into one engine process
produced identical scores and was 5x slower on `dom` (75s to 392s). A batch
shares a process, so correctness requires re-running a crashed batch file by
file — and WPT is a corpus where crashing files are common, so most batches
split and most files ran twice. Reverted, with the numbers kept on `run_one`.
That is §B15.12a's lesson arriving a fourth time, and the tell was the same: a
sentence in ROADMAP.md saying a change would be fast, written before anything
was timed.

576 engine tests (from 552). WPT gate exactly at baseline, 273,796.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: the reader did not lowercase what the writer did (+10,847 WPT subtests)

`getAttribute("accessKey")` answered null for an attribute that
`getAttribute("accesskey")` returned on the very next line. DOM §4.9 says both
lowercase the qualified name for an element in the HTML namespace; `set_attr`
and `remove_attr` did, `get_attr` did not, and `hasAttribute` inherited the bug
because it routes through the same op.

Found by reading failure messages rather than by guessing, which is §B12.2's
own method and is the only reason it was found at all: the symptom was
`assert_equals: getAttribute() expected (string) "" but got (object) null`,
identical across eleven files, and the cause was invisible until the WPT
reflection harness turned out to pass the **IDL** name straight through to both
calls (`html/dom/reflection.js`: `domName = idlName`). So every camelCase
reflected attribute — `accessKey` on every element, plus `tabIndex`,
`readOnly`, `maxLength`, `dateTime`, `useMap`, `cellPadding` and the rest —
failed on every element in all eleven `reflection-*.html` files.

    html/dom   43,744 -> 54,591 of 60,514 scored   (72.3% -> 90.2%)
    gate total 273,796 -> 284,655, no regression anywhere

The fix is namespace-conditional and that is not pedantry. The HTML parser
case-corrects SVG attributes, so an `<svg>` genuinely holds one named
`viewBox`; a blanket lowercase would have traded one silent wrong answer for
another. `set_attr` and `remove_attr` lowercasing *unconditionally* was the
same bug pointing the other way — `svg.setAttribute("viewBox", …)` stored
`viewbox` and rendered nothing — so all three now share one normaliser.

One place rather than three, deliberately. `guard_mutation` a few hundred lines
below records what happened the last time a defect of this shape was fixed at
each call site as it was found: "each was fixed where it was found, which is
precisely why there was a third."

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: forty-seven interface names, and three bugs hiding behind them (+1,664)

Chasing WPT core toward 80%. Three items from §B19's queue, and the useful part
is what each turned out to actually cost.

**getHTML: a 6,908-subtest file that is not a 6,908-subtest win.**
`shadow-dom/declarative/gethtml.html` is the largest single file in core and was
queued as the biggest available gain. The breakdown says otherwise: 380 subtests
need only `getHTML() == innerHTML`, which is built and measures at exactly +380,
and 6,528 need a shadow root serialised as `<template shadowrootmode>` — which
this engine cannot do, because a shadow root here is a view of its host and the
component's output and the light content are siblings in one element. Emitting
the flattened content under that header would be markup describing a tree that
never existed, so it is recorded through `unsupported()` instead. §B12.8 says a
large cluster usually has one cheap structural cause; this one has a single
expensive structural cause, and the file's size said nothing about which. A
subtest count measures how much a test repeats itself, not how much work its
failure represents.

**Forty-seven interface globals, and why they are not the stubs §B8.4 deleted.**
That rule is about feature detection: a name that exists and answers wrongly
sends a page down a branch it cannot recover from. A page writing
`nodes instanceof NodeList` is not detecting a feature, it is asking what it
holds, and the honest answers are yes and no — never ReferenceError. So each
interface object carries a `Symbol.hasInstance` doing the real brand check, and
`new NodeList()` still throws as it does in a browser.

Adding them surfaced three bugs with nothing to do with WPT:

* `CharacterData` *was* `Text`. A duplicate key in the globals literal, so the
  later binding won and `comment instanceof CharacterData` was false for a class
  the comment genuinely extends.
* `option.value = x` was silently lost: the setter took the editor path, which
  an option does not have, and stashed it where the option's getter never looks
  — taking `new Option(label, value)` with it.
* `fetch` resolved an object literal with the right fields, which reads
  identically until something asks what it is. `Response` was not a global, so
  `new Response(...)` was a ReferenceError. It is a real class now, and fetch
  builds one.

Plus one that was ours all along: interface objects were **enumerable** on the
global, which WebIDL §3.7 forbids and `idlharness` checks first for every
interface — a subtest per interface across the suite, spent before anything
about the interface was examined.

**new Document(), and a score that depended on machine load.** Exposing
`Document` as non-constructible took `html/dom/idlharness.https.html` from 269
passing to reporting nothing: `new Document()` is legal (DOM §4.5) and the test
builds one in setup. That is §8.4's hazard in a new costume, introduced by the
change meant to stop names being absent. Made constructible, the file goes from
373 subtests to 6,408 with 1,896 passing — and then became unstable, because it
needs about twenty seconds of script and `SCRIPT_PHASE_BUDGET` is twenty
seconds. The guard is right; a conformance harness is just where a runaway and a
slow page are hard to tell apart. A run whose score depends on the other
processes on the box is not a measurement, so `--script-seconds` lets an
instrument say so — announced, off by default, and still under the navigation
deadline, exactly like `--allow-any-remote`.

**testdriver-vendor.js, the second empty seam.** It ships as a zero-byte file
for the same reason `testharnessreport.js` does, and unfilled it fails 633 core
files on a missing harness rather than on the engine. Filled in `serve.py` with
no engine change: `click` and `send_keys` dispatch the events the action would
produce, and `bless` (706 call sites) is built on `click` upstream, so one
function unlocks both. Anything needing authority this engine lacks keeps
testdriver's own rejection — a shim that resolved those would turn "the harness
cannot do this" into "the engine got the wrong answer".

    html/dom   54,591 -> 56,241
    gate       284,655 -> 286,319, no regression
    585 engine tests (from 578)

§B20 records the analysis, including two corrections worth more than the code:
the "instrument cannot name what is missing" claim was wrong (87% of those
subtests already carry the name; the *analysis* was reading one channel and not
joining the other), and a 192-subtest "regression" in shadow-dom was drift
between a month-old artifact and today's engine. A before/after needs a before
taken from the current commit.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: re-baseline the WPT gate at 286,319

Raised after the interface-object work and `--script-seconds`. `html/dom`
carries the change (54,591 -> 56,241), most of it `idlharness.https.html`
becoming measurable rather than landing on the script-phase ceiling.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: reflection types, custom element names, and URL statics

Four separate defects, each of which repeated across every element or every
call site, found by reading what the failures actually said.

**The reflection type system, four bugs, all of them per-element.**

* `-0` is not a value an IDL long may report. `Number("-0")` is negative zero,
  reflections are integers, and testharness compares with `Object.is`
  semantics — so `tabindex="-0"` failed an `assert_equals(0)` on *every*
  element in every `reflection-*.html` file. `tabIndex` has its own parser, so
  it needed the same fix twice.
* Out of the 32-bit range is "not a valid integer" for a reflection rather than
  a large number: `marquee.hspace = 2147483648` read back as itself instead of
  the default.
* `[LegacyNullToEmptyString]`, which the legacy presentational colour
  attributes carry: `body.bgColor = null` writes "" and not "null". Marked per
  attribute, because everywhere else `null` really does stringify and a browser
  agrees.
* `form.action` and `input.formAction` answer with the document's address when
  the attribute is missing or empty. A form whose action reads "" submits
  somewhere different from one that reads the page's URL.

**Nine element interfaces the table never had** — meter, progress, iframe, del,
q, th, thead, tfoot, colgroup — plus a `double` reflection for meter and
progress. A missing entry there is not one attribute missing, it is every
attribute of that element failing at once; `ins` was present and `del` was not,
`td` was present and `th` was not.

`crossOrigin` is one nullable enumerated attribute and was spelled out on
`<link>` while `<img>`, `<script>`, `<video>` and `<audio>` had it as a plain
string. One definition now, and a nullable enumerated removes its attribute when
set to null or undefined. `document.dir` reflects `<html dir>` and was absent.

    html/dom  56,241 -> 57,080

**Custom element names were validated by one rule out of eight.** The dash was
checked; uppercase, the leading character, the eight reserved SVG/MathML
compound names and the local-name character rule were not — so this engine
accepted names a browser refuses, after which the page and the engine disagree
about what `<font-face>` is. It throws a `DOMException` now, which is what
`assert_throws_dom` checks and what the old unit test had pinned wrongly.

Two things this got wrong on the way, both worth recording:

* The first implementation used `PotentialCustomElementNameChar`, which is the
  *superseded* production. whatwg/html#7991 replaced it with "a valid element
  local name", which excludes rather than includes — so the old rule rejected
  names that are now legal, failing the file in the opposite direction from the
  one it was written to fix.
* `whenDefined` did not validate, so once `define` threw correctly the test
  reached `await promise_rejects_dom(t, 'SyntaxError', whenDefined(bad))` and
  hung there, taking all 5,900 subtests with it. A promise that never settles
  is the worst of the three answers: a caller cannot tell it from a component
  that has not loaded, so it waits out its own timeout instead of handling an
  error it could have handled at once.

`valid-custom-element-names.html`: 222 of 1,975 passing -> **1,975 of 1,975**.

**URL and body plumbing.** `new URLSearchParams(otherParams)` walked the
object's own keys, so it copied the internal `_pairs` field and serialised as
`_pairs=a%2Cb` — a params object emitting its own implementation. It takes any
iterable of pairs now. Added `sort()`, `size`, form-urlencoded serialisation
(`+` for space, and the escapes `encodeURIComponent` leaves alone), the
`URL.parse`/`URL.canParse` statics, and `formData`/`arrayBuffer`/`blob` on both
`Request` and `Response`.

    url  68 -> 148 of 499

585 tests, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: popovers and <dialog> were declared and never acted on

`html/semantics/popovers` was 3,846 unpassed against 20 passing, and the reason
was not that the feature is large: the `popover` attribute *reflected*, and
nothing anywhere did anything with it. `<dialog>` was the same shape — `open`
reflected, `show`, `showModal` and `close` all absent — so a dialog could be
described and never opened.

Both are real now as far as the DOM is concerned: the state machine, the
exceptions with the names the spec gives them, the `beforetoggle`/`toggle` pair
with its cancel-on-open-only asymmetry, auto popovers closing their peers where
manual ones do not, the `popovertarget` invoker, and `returnValue`.

**What is deliberately not real is the top layer.** This engine has no separate
paint layer, so an open popover renders where it sits in the document and a
modal dialog does not block the page behind it. That is a rendering property;
the API contract a page scripts against is not, and separating the two is worth
more than refusing the feature whole — a page can open a popover, be told why
it could not, and observe the same event sequence a browser fires.

Three things fell out of building it that the failures would not have said:

* `<div popover>` has the value `""`, which maps to the **auto** state. Without
  the alias it fell through to `invalid` and every bare popover reported
  "manual" — the one state that does not close its peers, so they stacked up.
* `popover` is **nullable**: an element without the attribute reports `null`,
  which is how a page asks "is this a popover at all". Reporting `""` made
  every element look like one.
* An invoker runs **after** the click and only if it was not cancelled, so the
  click event has to be held and asked. Dispatching and discarding it made
  `preventDefault()` in a handler do nothing, which is the one thing default
  activation behaviour has to respect.

589 tests, clippy clean. §B20.10 records the round.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: DOMTokenList had four gaps, and createElementNS validated nothing

**`classList` could hold a class a page could not remove.** `add("a b")` wrote
one token that read back as two, and `add("")` wrote a trailing space, because
neither validation existed — so the token a page added was not a token it could
later name. That is the worst shape a DOM bug takes: the write succeeds, the
read disagrees, and nothing reports either.

Also absent: `replace()`, which the corpus asked for 262 times and which is how
a component moves between states without a remove-then-add that briefly has
neither class; and indexed access, so `classList[0]` answered `undefined` for a
collection whose whole point is being indexed. The reporting had recorded that
one twice, as `DOMTokenList.0` and `DOMTokenList.-1`, because nothing
implemented either.

**`createElementNS` accepted anything and returned an element**, which is why
`dom/nodes/Document-createElementNS.html` scored **1 of 596**: the file is
almost entirely a sweep of names that must be rejected, and every one of them
succeeded. It validates the XML `Name` production now, and keeps the two errors
apart because the spec does and pages catch them separately —
`InvalidCharacterError` is "that is not a name", `NamespaceError` is "that name
and that namespace may not go together".

    dom       2,022 -> 2,629
    html/dom  57,080 -> 57,498
    gate      286,319 -> 288,183, no regression

Measured alongside: popovers and `<dialog>` took `html/semantics` from 2,839 to
**4,642**. §B20.11 and §B20.12 record the round and where core now stands —
58.5%, from 49.7%, with the remaining distance to 80% resting on two product
decisions rather than on more of this.

591 tests, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: constraint validation, text selection, and an empty input that read as a space

§B20.11 named `html/semantics/forms` as the one large remaining block that
needed no design reversal. It was 723 passing of 4,870, and the reason was not
subtlety: **the constraint validation API did not exist at all.** Nine files
scored 1 of 920 between them, every one failing on "the validity attribute
doesn't exist" before reaching what it meant to check.

Built, in the order the failures ranked them:

* `validity`, `willValidate`, `validationMessage`, `checkValidity`,
  `reportValidity`, `setCustomValidity`, and the form-level pair. The
  barred-from-validation clause is the part worth reading: a disabled control
  that reported itself invalid would block a form the user cannot even reach,
  so barred elements are always valid *including* when a custom error was set.
  `reportValidity` is identical to `checkValidity` here and says so — the
  difference is that a browser shows the message and there is no UI to show it
  in.
* Text-field selection: `selectionStart`/`End`/`Direction`,
  `setSelectionRange`, `setRangeText` with all four select modes, `select`.
  Held on this side rather than in the layout engine, because it has to answer
  for a detached control too. `<input type=number>` reports `null` rather than
  0, which is the distinction a page tests before using it.
* `valueAsNumber`, `valueAsDate`, `stepUp`, `stepDown`, `showPicker` — all off
  one table, so a type is steppable in one place rather than four that can
  disagree. NaN rather than `undefined` for a type with no numeric form:
  `undefined` says "this engine lacks the property", NaN says "this control
  holds no number".
* `<input type=color>` sanitisation, `files` returning null off a non-file
  input, `form.autocomplete` defaulting to `on`.

**Three bugs with nothing to do with forms fell out of it.**

*An empty `<input>` read as `" "`.* blitz seeds a laid-out input's editor with
a single space, and the value getter applied its whitespace-is-unseeded rule to
`<textarea>` only. So `if (!input.value)` was **false** for an empty field —
every page and every agent testing a form for emptiness got the wrong answer,
and `required` could never fire. Found only because constraint validation asked
the question from a different direction.

*`cloneNode` copied `class` and `style` and nothing else.* A clone lost its id,
its href, its data-* and every hook a page had put on it, so a cloned
`<template>` came out stripped. The form-control cloning steps went with them.

*`click()` on a disabled control dispatched a click*, so a page that disables a
control to stop it being used still saw it used.

    html/semantics/forms  723 -> 2,012 of 4,655
    html/dom              57,498 -> 58,073
    dom                   2,629 -> 2,651
    gate                  288,183 -> 288,780, no regression

598 tests, clippy clean. §B20.12 records the round; what remains in forms is
submission, `:focus` in the selector engine, and `color()` parsing — and
submission is the one worth taking next, because it is the half of a form this
engine can observe better than anything else, being the HTTP client itself.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: form submission, and a `===` that was never true

The rest of forms was submission, and §B20.12 said it was worth taking because
this engine *is* the HTTP client.

* **Form ownership is not containment.** `form=""` names no id and therefore
  has no owner, but the old code read the attribute for truthiness and fell
  through to the ancestor search — reporting the surrounding form, when taking
  a control *out* of the form it sits in is the entire purpose of the
  attribute. `form.elements` asks the same question now, so a control with
  `form="thisId"` is submitted from anywhere on the page and a descendant
  pointing elsewhere is not submitted here.
* **The entry list**, properly: the submitter is an entry (skipping every
  button meant a server could not tell which one was pressed), `_charset_` is
  supplied by the engine, a `<datalist>` descendant is a suggestion and never
  an entry, disabled and unnamed controls are out.
* **The `formdata` event**, firing with the list under construction rather than
  a copy — the documented replacement for the hidden inputs a page used to
  inject.
* **`requestSubmit` and `submit`**, which differ in the two ways that matter:
  the first validates and fires a cancelable `submit`, the second does neither.
  Implementing them as one function is the obvious shortcut and would make
  `form.submit()` called from inside a `submit` handler recurse.

Neither navigates, deliberately: this engine drives navigation through its own
verbs so an agent and a receipt both see it, and a form submitting itself out
from under that would be a request nothing decided on.

**A bug with nothing to do with forms fell out of it.** `form.elements` came
back empty because it compared `formOwnerOf(el) === this` — and `wrap()` hands
back the `observed` proxy while a getter runs with the raw *target* as `this`,
by design, since `observed` passes the target as receiver to avoid paying a
trap per field read. So a proxy and its target are two objects for one node,
and identity comparison silently answers "different" for **every element**.
Anything anywhere comparing two wrappers with `===` has the same defect; there
is a `sameNode` helper saying so now.

    html/semantics/forms  723 -> 2,051 of 4,655 across the two rounds
    gate                  288,780 -> 288,784, no regression

**The boundary.** What remains in `form-submission-0` is three enctype files at
62 subtests each plus the double-submit pair, and every one submits into an
`<iframe>` and waits for its load. That is §B6's refusal reached from a third
direction, after declarative shadow DOM and `html/browsers/origin`. The
submission algorithm is implemented and observable; being navigated by it is
what is out of reach.

602 tests, clippy clean. §B20.13 records the round.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: the three boundaries, decided, and tiers.list made to say so (§B20.15)

§B20.14 ended on three blocks "blocked on a product decision, not on effort".
The decision was put and made, argued on the product's terms rather than WPT's:

* **No second browsing context — kept.** Two origins in one realm is the
  hazard `retain_origin` exists to bound, and doing iframes right is site
  isolation. One carve-out queued: `window.open` maps onto h5i's own session
  model, so it should become a named refusal carrying a recovery ("open one
  with --session"), per §B15.6. Revisit trigger: corpus demand from real agent
  tasks (payments/auth), never WPT — and the first step would be same-origin
  srcdoc iframes only.
* **Flattened shadow root — kept, defended hardest.** 6,528 of the 7,140 is
  one serialisation file. The flattening is aligned, not a shortcut: it is
  what the accessibility tree does, and the snapshot is modeled on that tree.
  Revisit trigger: visible misrendering from style leakage — and the fix would
  be scoping in the cascade, not a second tree.
* **Synchronous fetch — not a boundary, reclassified.** Fail-closed requires
  decide-and-record before the bytes move; nothing forces the transport to
  block. Decision: measure first (the repaired corpus/compare.py), build
  concurrent brokered fetch with real abort only if serial fetch is where
  real-page latency actually goes. §B15.12a applied before the mistake.

tiers.list moves three entries to `exclude`, reasons on the line:
`html/browsers/origin`, `fetch/metadata` (the *feature* is still wanted — the
tests need window.open plus .py handlers), and `gethtml.html` by exact path so
the rest of shadow-dom stays measured. Two look-alikes deliberately NOT
excluded, because either would be exclusion by outcome wearing a capability's
name: the enctype files (their subject is entry-list serialisation, which we
claim) and the fetch abort timeouts (an implementation ceiling, per decision
3). Both stay in core as honest losses.

The effect, disclosed the way §B12.6 requires, since this is its third way of
moving a number:

    core, old scope   81,120 / 130,958 = 61.9%
    core, new scope   80,738 / 121,987 = 66.2%
    moved out         8,971 scored, of which only 382 passed

Nothing got better; the denominator now says what the engine is. The moved-out
block was 4% passing — exactly what a capability hole looks like, and exactly
why the exclusion had to be argued from the product rather than read off the
score. The reasons being on the line in tiers.list, where moving a line and
re-running is the audit, is the difference between this and a gamed number.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: frames as content, abort made observable, window.open named (§B21)

§B20.15's revisit triggers fired the day they were written: task evidence —
real agent runs, not WPT — showed work blocked on frames and on abort. This is
the narrow reopening, and the boundary it does not cross.

**Frames as content.** A frame's document is fetched through the broker under
its own initiator — `frame` in the request log, so an auditor asking "did this
page pull in another document" gets the answer by name — and its content is
flattened into the page the way a shadow root is: readable in the snapshot,
actionable by the verbs. The payment form inside the iframe mints refs like
any other form. What deliberately does not happen: its scripts never run
(stripped after the graft; `javascript:` frames refused by name), its styles
do not apply, `contentDocument` still answers null, and the whole tree is
bounded at eight frames with the bound said rather than silent. A refused
frame is a note the agent reads, never an empty box.

Three findings from building it, each worth more than the feature:

* **Fragment parsing inside `<iframe>` is raw text** — the first graft set the
  frame's own innerHTML and produced one text node of escaped markup. The
  graft goes into a `<div>` container, which is a neutral parsing context.
* **Blitz styles nothing it will not render**, so the snapshot's
  hidden-content defence ("no styles means hidden") silently dropped every
  grafted subtree. Inside a frame that inference is wrong — no styles means
  *outside the styled tree* — so the walk carries an `in_frame` flag, and the
  hiding vectors a page actually controls there (`hidden`, inline
  display:none, `aria-hidden`) keep their teeth, pinned by test.
* **The document-origin loopback rule fired on the first test draft**,
  refusing a web page's frame from reaching the dev server. §B3.1 doing its
  job on a road that did not exist when it was written; now pinned too.

**Abort made observable.** The §B20.15 claim that fetch is synchronous
underneath was half stale — script fetches have been threaded since the ticket
queue — but abort only took effect when the network answered, which is why 260
fetch files timed out. The promise now rejects the moment the page says stop,
while the wire request runs to completion and its receipt stands: the request
*was* made, and a log that unwrote it when the page changed its mind would
record intentions rather than traffic. The reason is a DOMException named
AbortError (a plain Error sent every `e.name` branch the wrong way),
`AbortSignal.timeout()` runs on the virtual clock so a fetch-versus-timeout
race settles deterministically, and every `Request` mints a `signal` when the
caller brings none.

**window.open, the named refusal.** Returns null — the popup-blocker answer
every page already handles — and says why, naming the recovery: open the URL
in another session and drive both. Not a same-realm fake window, which would
hand the opened page's globals to the opener.

    fetch/api/abort   hanging -> 32 of 96 scored (the rest needs wptserve)
    dom               2,651 -> 2,672
    gate              288,784 -> 288,807, no regression

tiers.list is unchanged, deliberately: frames-as-content moves what an agent
can read and drive, not what the excluded tests measure — html/browsers/origin
still needs live contexts scripting each other, and the enctype files still
observe submission through a frame's *load*, which a flattened frame does not
perform.

608 tests, clippy clean. §B21 records the round.

Co-Authored-By: Claude Opus 5 <[email protected]>

* browser: the skill said iframes were unavailable, and §B21 made that false

The agent-facing reference is exactly where a stale capability claim costs the
most: an agent reading "not available: iframes" routes to Chromium for a page
this engine now reads fine. Says what frames-as-content gives (flattened,
actionable, receipted under the `frame` initiator), what it withholds (frame
scripts, styles, contentDocument), and what window.open's refusal tells you to
do instead.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
alexios-angel added a commit to alexios-angel/compile-time-browser that referenced this pull request Sep 17, 2026
…not PotentialCustomElementName

customElements.define checked the old HTML production, a fixed list of XML name
characters. whatwg/html#7991 replaced it: a valid custom element name is any
valid element LOCAL name with no ASCII upper alpha, a hyphen in it and not one
of the eight SVG/MathML names. That is much wider - `a!-element`,
`a\x01-element` and `_-element` are names a page may define, and the old rule
refused every one of them, so 222 of the 1,975 subtests of
custom-elements/registries/valid-custom-element-names.html asked for a
definition that threw.

The local-name rule is the specification's own alternation: what the HTML
tokenizer can read back as a tag name (everything but the six characters that
would END one), or the XML Name shape.

Co-Authored-By: Claude Opus 5 <[email protected]>
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…efixes r=smaug,dom-core,devtools-reviewers,ochameau

Implement "relaxed" element/attribute name-validation rules, per:

- whatwg/dom#1079
- whatwg/html#7991
- whatwg/html#11453

That aligns DOM-API name behavior with HTML parser behavior - which has
always allowed a wider range of characters in element and attribute names.

New validation functions in nsContentUtils:

- IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute -
  no null, whitespace, /, >, or =
- IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or >
- IsValidDoctypeName(): For createDocumentType - no null, whitespace, or >
- ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules

ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm
per the DOM spec: for qualified names with multiple colons like "f:o:o", the
local name is just the second token ("o"), not everything after the first colon
("o:o"). This matches the spec's requirement to split on all colons and use only
splitResult[0] as prefix and splitResult[1] as localName.

Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name
validation rules; WPT name-validation.html provides coverage for the new
relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass.

Differential Revision: https://phabricator.services.mozilla.com/D277822
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…efixes r=smaug,dom-core,devtools-reviewers,ochameau

Implement "relaxed" element/attribute name-validation rules, per:

- whatwg/dom#1079
- whatwg/html#7991
- whatwg/html#11453

That aligns DOM-API name behavior with HTML parser behavior - which has
always allowed a wider range of characters in element and attribute names.

New validation functions in nsContentUtils:

- IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by
  any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute -
  no null, whitespace, /, >, or =
- IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or >
- IsValidDoctypeName(): For createDocumentType - no null, whitespace, or >
- ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules

ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm
per the DOM spec: for qualified names with multiple colons like "f:o:o", the
local name is just the second token ("o"), not everything after the first colon
("o:o"). This matches the spec's requirement to split on all colons and use only
splitResult[0] as prefix and splitResult[1] as localName.

Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name
validation rules; WPT name-validation.html provides coverage for the new
relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass.

Differential Revision: https://phabricator.services.mozilla.com/D277822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

normative change topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Development

Successfully merging this pull request may close these issues.

3 participants