You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 597536f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(html): keep an attribute name or list token spelling a foreign delimiter (#22018)
* fix(html): keep an attribute name or list token spelling a foreign delimiter
A `{% … %}` statement written into a tag tokenizes as attribute names, and one
written into a `class` as list tokens, so its delimiters repeat. Both the
spec's duplicate-attribute drop and the token list's own fold then discard one,
turning valid input into invalid template markup.
Neither fold is wrong about the DOM, but both discard bytes webpack cannot
read. `_isWordSpan` now asks whether a name or token is one HTML vocabulary
spells, and a tag or list holding one that is not keeps every name it names:
the tag is echoed from source rather than rebuilt, and the list is read as text
rather than as the set the DOM reflects. The test is per tag and per list, not
per token — one foreign token in `class="a {% if x %} a {% endif %}"` has to
disqualify the whole list, or the repeated `a` inside the statement still goes.
This stays spec-exact: re-parsing the echoed tag drops the repeat again, so
Chrome reads the same attributes from input and output. Word-shaped names still
fold — `<p a=1 a=2>` prints `<p a=1>`, `rel="preload preload"` prints
`rel=preload`, `class="a b a"` prints `class="a b"`. `sortTokenLists` reads the
same rule and no longer reorders a list holding a statement.
The word test runs only for a tag that dropped a duplicate, and for a list only
once a repeat is found, so the parse and print hot paths are unchanged.
Refs #22013
* chore: teach cspell the tsc members README names
`lint:spellcheck` reads every Markdown file in the repo, so the names #22006
added to the README fail it on `main` and on every branch off it.
* test(cli): update the flags snapshot for the reworded schema description
The CLI flags are derived from the schema and carry each option's description
verbatim, so rewording `normalizeListAttributes` changes four lines of it.
* Normalize a list-shaped attribute value: a space-separated token list (`class`, `rel`, `part`, …), a comma-separated one (`accept`, `sizes`, …), a `srcset` and the viewport `<meta content>`. On by default. Reordering a token list is `sortTokenLists`, which is separate and off by default.
2616
+
* Normalize a list-shaped attribute value: a space-separated token list (`class`, `rel`, `part`, …), a comma-separated one (`accept`, `sizes`, …), a `srcset` and the viewport `<meta content>`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is `sortTokenLists`, which is separate and off by default.
Copy file name to clipboardExpand all lines: schemas/WebpackOptions.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4205,7 +4205,7 @@
4205
4205
"added": "5.110.0"
4206
4206
},
4207
4207
"normalizeListAttributes": {
4208
-
"description": "Normalize a list-shaped attribute value: a space-separated token list (`class`, `rel`, `part`, …), a comma-separated one (`accept`, `sizes`, …), a `srcset` and the viewport `<meta content>`. On by default. Reordering a token list is `sortTokenLists`, which is separate and off by default.",
4208
+
"description": "Normalize a list-shaped attribute value: a space-separated token list (`class`, `rel`, `part`, …), a comma-separated one (`accept`, `sizes`, …), a `srcset` and the viewport `<meta content>`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is `sortTokenLists`, which is separate and off by default.",
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
11565
+
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
11571
+
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
12230
+
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
12236
+
"description": "Normalize a list-shaped attribute value: a space-separated token list (\`class\`, \`rel\`, \`part\`, …), a comma-separated one (\`accept\`, \`sizes\`, …), a \`srcset\` and the viewport \`<meta content>\`. On by default. A list is read as the set the DOM reflects, so a repeat folds away, only where every token of it is a word: one holding a delimiter another language wrote a statement in is text, and keeps every token it names. Reordering a token list is \`sortTokenLists\`, which is separate and off by default.",
0 commit comments