Skip to content

Commit 1097a7f

Browse files
fix(html): align walkHtmlTokens with WHATWG spec (#21000)
1 parent 67b7419 commit 1097a7f

7 files changed

Lines changed: 4975 additions & 152 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Align the experimental HTML tokenizer with the WHATWG spec: fix offset-range bugs in the script-data, content-mode end-tag, attribute-value, and EOF states; surface tokenizer parse errors to consumers via a new `parseError` callback (`"warning"` when the tokenizer recovers and the emitted token is still well-formed, `"error"` when the offset range is incomplete — e.g. `eof-in-tag`); and add the full WHATWG named character references table so `decodeHtmlEntities` handles all named entities (including legacy bare forms like `&AMP` and multi-code-point entities like `≂̸`) with proper longest-prefix backtracking.

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@
391391
"**/**/*.snap",
392392
"test/cases/json/weird-properties/globals.json",
393393
"test/JavascriptParser.unittest.js",
394+
"tooling/html-entities.json",
394395
"test/test262-cases/**",
395396
"**/*.svg",
396397
"*.log",

lib/html/walkHtmlTokens.js

Lines changed: 641 additions & 125 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"prelint": "yarn setup",
3535
"lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-benchmark && yarn lint:types-module-test && yarn lint:types-hot && yarn fmt:check && yarn lint:spellcheck",
3636
"lint:code": "node node_modules/eslint/bin/eslint.js --cache .",
37-
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
37+
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-html-entities.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
3838
"lint:types": "tsc",
3939
"lint:types-test": "tsc -p tsconfig.types.test.json",
4040
"lint:types-benchmark": "tsc -p tsconfig.types.benchmark.json",
@@ -48,7 +48,7 @@
4848
"fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
4949
"fix": "yarn fix:code && yarn fix:special && yarn fmt",
5050
"fix:code": "yarn lint:code --fix",
51-
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
51+
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-html-entities.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
5252
"build:examples": "cd examples && node buildAll.js",
5353
"benchmark": "node --max-old-space-size=6144 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
5454
"pretest": "yarn lint",

0 commit comments

Comments
 (0)