Closed Bug 1773312 Opened 3 years ago Closed 2 months ago

Allow more characters in element/attribute names and prefixes

Categories

(Core :: DOM: Core & HTML, task)

task

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: d, Assigned: sideshowbarker)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, webcompat:platform-bug)

Attachments

(1 file)

See spec changes at https://github.com/whatwg/dom/pull/1079 for:

  • createAttribute()
  • setAttribute()
  • toggleAttribute()
  • createElement()
  • createElementNS()
  • createDocument()
  • createAttributeNS()
  • setAttributeNS()

and https://github.com/whatwg/html/pull/7991 for updates to "valid custom element name" which impacts:

Depends on: 1974274

We found one more instance, the dataset named property setter: https://github.com/whatwg/html/pull/11453

Keywords: dev-doc-needed

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

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.

Assignee: nobody → mike
Status: NEW → ASSIGNED
See Also: → 2009915
Pushed by opettay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/3ae08e317eb9 https://hg.mozilla.org/integration/autoland/rev/4d11a13157d7 Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau
Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d11b8803574c https://hg.mozilla.org/integration/autoland/rev/ffbf2e75d4f8 Revert "Bug 1773312 - Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau" for causing failures at Document-createElement.html.
Pushed by opettay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/07632bbd30ee https://hg.mozilla.org/integration/autoland/rev/060f0f5828e3 Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau
Pushed by imoraru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/11344a72b7d4 https://hg.mozilla.org/integration/autoland/rev/ddca65a8990f Revert "Bug 1773312 - Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau" for causing mochitest-plain failures on test_createAttributeNS03.html.

Revert for causing mochitest-plain failures on test_createAttributeNS03.html.

Attachment #9535507 - Attachment description: Bug 1773312 - Allow more characters in element/attribute names and prefixes r=#dom-core,smaug → Bug 1773312 - Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau
Flags: needinfo?(mike)
Pushed by opettay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e149aed5126a https://hg.mozilla.org/integration/autoland/rev/06922ba5c6ce Allow more characters in element/attribute names and prefixes r=smaug,dom-core,devtools-reviewers,ochameau
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
QA Whiteboard: [qa-triage-done-c150/b149]

FF149 Docs work for this can be tracked in https://github.com/mdn/content/issues/43218

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: