Commit 3ae08e3
Bug 1773312 - Allow more characters in element/attribute names and prefixes 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/D2778221 parent 3eddd4c commit 3ae08e3
File tree
31 files changed
+287
-2226
lines changed- devtools/client/inspector/markup/test
- dom
- base
- html
- test
- tests/mochitest/dom-level1-core
- testing/web-platform/meta
- dom/nodes
- html/dom/elements/global-attributes
31 files changed
+287
-2226
lines changedLines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
| 46 | + | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9048 | 9048 | | |
9049 | 9049 | | |
9050 | 9050 | | |
9051 | | - | |
9052 | | - | |
| 9051 | + | |
| 9052 | + | |
| 9053 | + | |
9053 | 9054 | | |
9054 | 9055 | | |
9055 | 9056 | | |
| |||
9126 | 9127 | | |
9127 | 9128 | | |
9128 | 9129 | | |
9129 | | - | |
9130 | | - | |
| 9130 | + | |
| 9131 | + | |
| 9132 | + | |
9131 | 9133 | | |
9132 | 9134 | | |
9133 | 9135 | | |
| |||
9225 | 9227 | | |
9226 | 9228 | | |
9227 | 9229 | | |
9228 | | - | |
9229 | | - | |
9230 | | - | |
| 9230 | + | |
| 9231 | + | |
| 9232 | + | |
9231 | 9233 | | |
9232 | 9234 | | |
9233 | 9235 | | |
| |||
9239 | 9241 | | |
9240 | 9242 | | |
9241 | 9243 | | |
9242 | | - | |
9243 | | - | |
| 9244 | + | |
| 9245 | + | |
| 9246 | + | |
9244 | 9247 | | |
9245 | 9248 | | |
9246 | 9249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1617 | 1617 | | |
1618 | 1618 | | |
1619 | 1619 | | |
1620 | | - | |
1621 | | - | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1622 | 1623 | | |
1623 | 1624 | | |
1624 | 1625 | | |
| |||
1652 | 1653 | | |
1653 | 1654 | | |
1654 | 1655 | | |
1655 | | - | |
1656 | | - | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1657 | 1659 | | |
1658 | 1660 | | |
1659 | 1661 | | |
| |||
1777 | 1779 | | |
1778 | 1780 | | |
1779 | 1781 | | |
1780 | | - | |
1781 | | - | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1782 | 1785 | | |
1783 | 1786 | | |
1784 | 1787 | | |
| |||
0 commit comments