Commit e149aed
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 621b2d1 commit e149aed
File tree
40 files changed
+299
-3430
lines changed- devtools/client/inspector/markup/test
- dom
- base
- html
- test
- tests/mochitest
- dom-level1-core
- dom-level2-core
- testing/web-platform/meta
- dom/nodes
- html/dom/elements/global-attributes
40 files changed
+299
-3430
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 | |
|---|---|---|---|
| |||
8997 | 8997 | | |
8998 | 8998 | | |
8999 | 8999 | | |
9000 | | - | |
9001 | | - | |
| 9000 | + | |
| 9001 | + | |
| 9002 | + | |
9002 | 9003 | | |
9003 | 9004 | | |
9004 | 9005 | | |
| |||
9075 | 9076 | | |
9076 | 9077 | | |
9077 | 9078 | | |
9078 | | - | |
9079 | | - | |
| 9079 | + | |
| 9080 | + | |
| 9081 | + | |
9080 | 9082 | | |
9081 | 9083 | | |
9082 | 9084 | | |
| |||
9174 | 9176 | | |
9175 | 9177 | | |
9176 | 9178 | | |
9177 | | - | |
9178 | | - | |
9179 | | - | |
| 9179 | + | |
| 9180 | + | |
| 9181 | + | |
9180 | 9182 | | |
9181 | 9183 | | |
9182 | 9184 | | |
| |||
9188 | 9190 | | |
9189 | 9191 | | |
9190 | 9192 | | |
9191 | | - | |
9192 | | - | |
| 9193 | + | |
| 9194 | + | |
| 9195 | + | |
9193 | 9196 | | |
9194 | 9197 | | |
9195 | 9198 | | |
| |||
11827 | 11830 | | |
11828 | 11831 | | |
11829 | 11832 | | |
11830 | | - | |
11831 | | - | |
| 11833 | + | |
| 11834 | + | |
| 11835 | + | |
| 11836 | + | |
| 11837 | + | |
11832 | 11838 | | |
11833 | 11839 | | |
11834 | | - | |
11835 | | - | |
| 11840 | + | |
11836 | 11841 | | |
11837 | | - | |
11838 | | - | |
11839 | | - | |
11840 | | - | |
11841 | | - | |
11842 | | - | |
11843 | | - | |
| 11842 | + | |
| 11843 | + | |
| 11844 | + | |
| 11845 | + | |
| 11846 | + | |
| 11847 | + | |
11844 | 11848 | | |
11845 | 11849 | | |
11846 | 11850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1678 | 1678 | | |
1679 | 1679 | | |
1680 | 1680 | | |
1681 | | - | |
1682 | | - | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
1683 | 1684 | | |
1684 | 1685 | | |
1685 | 1686 | | |
| |||
1713 | 1714 | | |
1714 | 1715 | | |
1715 | 1716 | | |
1716 | | - | |
1717 | | - | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
1718 | 1720 | | |
1719 | 1721 | | |
1720 | 1722 | | |
| |||
1838 | 1840 | | |
1839 | 1841 | | |
1840 | 1842 | | |
1841 | | - | |
1842 | | - | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
1843 | 1846 | | |
1844 | 1847 | | |
1845 | 1848 | | |
| |||
0 commit comments