Skip to content

Commit 35a3353

Browse files
committed
test(html): read a token list as the set of tokens it names
The new attribute case put a repeat and extra whitespace in `accesskey` and `itemref`, and the equivalence check called the minified page a different DOM: it read neither as a list, and it sorted the lists it did read without dropping a repeat. Both are sets of unique tokens in the spec, so a repeat names nothing the first did not. `ping` stays as written, where the spec lists URLs rather than a set.
1 parent f23c27c commit 35a3353

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎test/helpers/syntaxEquivalence.js‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,14 +1021,25 @@ const installHelpers = () => {
10211021
// ASCII whitespace" and whose descriptors are then tokenized by skipping
10221022
// whitespace — so a run of it between the two carries nothing.
10231023
const SRCSET_ATTRIBUTES = new Set(["imagesrcset", "srcset"]);
1024-
// A space-separated list the engine does not reflect as a DOMTokenList.
1024+
// A space-separated list the engine does not reflect as a DOMTokenList, so
1025+
// the whitespace between its tokens is read here rather than by the engine.
10251026
const TOKEN_LIST_ATTRIBUTES = new Set([
1027+
"accesskey",
10261028
"headers",
10271029
"itemprop",
10281030
"itemref",
10291031
"itemtype",
10301032
"ping"
10311033
]);
1034+
// Of those, the ones the spec calls a set of *unique* tokens, where a repeat
1035+
// names nothing the first did not. `ping` is not one: it lists URLs.
1036+
const UNIQUE_TOKEN_LIST_ATTRIBUTES = new Set([
1037+
"accesskey",
1038+
"headers",
1039+
"itemprop",
1040+
"itemref",
1041+
"itemtype"
1042+
]);
10321043
// Set by its presence alone, and parsed by the rules for non-negative
10331044
// integers — for attributes this engine reflects no IDL property for.
10341045
const BOOLEAN_ATTRIBUTES = new Set([
@@ -1074,11 +1085,11 @@ const installHelpers = () => {
10741085
}
10751086
if (URL_ATTRIBUTES.has(name)) return raw.replace(/[\t\n\r]/g, "").trim();
10761087
if (TOKEN_LIST_ATTRIBUTES.has(name)) {
1077-
return raw
1078-
.split(/[\t\n\f\r ]+/)
1079-
.filter(Boolean)
1080-
.sort()
1081-
.join(" ");
1088+
const tokens = raw.split(/[\t\n\f\r ]+/).filter(Boolean);
1089+
const read = UNIQUE_TOKEN_LIST_ATTRIBUTES.has(name)
1090+
? [...new Set(tokens)]
1091+
: tokens;
1092+
return read.sort().join(" ");
10821093
}
10831094
// The viewport meta is a comma-separated list of `key=value` pairs; every
10841095
// other `content` is opaque text.

0 commit comments

Comments
 (0)