Skip to content

Commit 032025b

Browse files
build(html): one generator for the HTML tables, reflect data from webref's packages
The two HTML generators are one: `generate-html-data.js` now emits both `lib/html/data.js` and the entity region inside `lib/html/syntax.js`, so a single command covers everything the parser and minifier look a name up in. The reflected-attribute tables come from `@webref/idl` and `@webref/elements` rather than a vendored distillation of them, which deletes `tooling/html-reflect.json` and its `--fetch` refresh: upstream now moves as a lockfile bump whose regenerated diff is reviewable, instead of an undated copy that drifts unnoticed. It already had: the packaged IDL derives four attributes the vendored file missed, so `frame`, `frameset`, `marquee`, `dir`, `listing` and `xmp` gain the reflected attributes the spec gives them — `noresize`, `truespeed`, `scrollamount`, `scrolldelay`, `compact` on `dir`, `hspace` and `vspace` on `marquee`, `width` on `listing`/`xmp`, and the window event handlers on `frameset`. Nothing is removed. The entity table stays vendored: WHATWG publishes it as `entities.json` and no package carries it faithfully — the ones that exist drop the semicolon, which loses the 106 legacy names that match unterminated. `--fetch` still refreshes it, and the emitted region is byte-identical apart from its provenance note.
1 parent 43d7fc0 commit 032025b

10 files changed

Lines changed: 241 additions & 501 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+
Recognize the reflected attributes of `frame`, `frameset`, `marquee` and `dir`.

‎AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,11 @@ These files are produced by `yarn fix:special` and must not be edited by hand:
572572
- `schemas/**/*.check.{js,d.ts}` — precompiled schema validators.
573573
- Generated runtime code under `lib/` (driven by `tooling/generate-runtime-code.js`).
574574
- `lib/css/data.js` — every table the CSS minifier looks a name up in, and the arithmetic its math-function descriptors bind to: derived from `mdn-data` + `color-name` (box shorthands, color-argument and math functions, named colors) plus the generator's `SUPPLEMENT` of spec-prose tables and math primitives, by `tooling/generate-css-data.js` — which also holds the value-definition-syntax parser those grammars are read with, and runs the generation only as the entry point so its tests can require it.
575-
- `lib/html/data.js` — every table the HTML parser and minifier look a name up in: the reflected-attribute tables distilled from webref's HTML IDL (vendored as `tooling/html-reflect.json`), plus the generator's `SUPPLEMENT` and `PARSER_TABLES` of §13.2 tree-construction vocabulary, by `tooling/generate-html-data.js`.
575+
- `lib/html/data.js` — every table the HTML parser and minifier look a name up in: the reflected-attribute tables distilled from webref's HTML IDL (the `@webref/idl` and `@webref/elements` packages), plus the generator's `SUPPLEMENT` and `PARSER_TABLES` of §13.2 tree-construction vocabulary, by `tooling/generate-html-data.js` — which also emits the `// #region html entities` block inside `lib/html/syntax.js` from the vendored `tooling/html-entities.json`, WHATWG's own named character references table.
576576

577577
Both `syntax.js` files are algorithm only — a new lookup table belongs in the matching generator, not next to the code that reads it.
578578

579-
**And in the generator, derive it — do not type it out.** Read the table out of a published dataset (`mdn-data`, `color-name`, the vendored webref IDL) whenever it is derivable at all, _including by analyzing a grammar rather than by listing names_: the value-definition syntax states which properties take an `<integer>`, so that set is computed, never enumerated. A table already in `SUPPLEMENT` counts as a source too — cosine at each eighth turn is sine two eighths along, and each inverse trig table is its forward one read back, so one stated table can carry several.
579+
**And in the generator, derive it — do not type it out.** Read the table out of a published dataset (`mdn-data`, `color-name`, `@webref/idl`) whenever it is derivable at all, _including by analyzing a grammar rather than by listing names_: the value-definition syntax states which properties take an `<integer>`, so that set is computed, never enumerated. A table already in `SUPPLEMENT` counts as a source too — cosine at each eighth turn is sine two eighths along, and each inverse trig table is its forward one read back, so one stated table can carry several.
580580

581581
**Per-construct behaviour is a table as well.** Where the minifier does something different for each name — each math function, and whatever comes next for properties or at-rules — the per-name part belongs in the generator as a descriptor and the shared part in `syntax.js` as an engine keyed by it. `MATH_FUNCTION_FOLD` is the worked example: it says how each function's arguments are read, which arithmetic runs and what unit the answer carries, so `syntax.js` implements neither and names no function of its own. The arithmetic is emitted alongside the descriptors and bound to them by reference rather than by name, so a name nothing defines fails generation rather than folding nothing. Adding a function is then adding a line, and a name whose arithmetic already exists needs nothing else. A test must still drive every descriptor — one input per entry is enough to turn a wrong-but-existing binding into a failure instead of a silent decline. Listing names by hand into a generator's `SUPPLEMENT` is the last resort, and every entry there carries the reason it cannot be derived — spec prose, an equivalence between two spellings, a judgement no dataset states. A hand-typed list goes stale the next time a spec moves and nothing in CI notices; a derived one turns the same spec change into a reviewable diff.
582582

@@ -586,7 +586,7 @@ Re-run `yarn fix:special` **before the next commit** whenever you touch:
586586

587587
- `schemas/**/*.json` — reshapes validators, declarations, and `types.d.ts`.
588588
- `lib/**/*.js` JSDoc on anything reachable from a public export — regenerates `types.d.ts`.
589-
- `tooling/generate-runtime-code.js`, `tooling/generate-wasm-code.js`, `tooling/generate-css-data.js`, `tooling/generate-html-data.js`, or any file they consume (including the `mdn-data` / `color-name` versions in `package.json` and the vendored `tooling/html-reflect.json`).
589+
- `tooling/generate-runtime-code.js`, `tooling/generate-wasm-code.js`, `tooling/generate-css-data.js`, `tooling/generate-html-data.js`, or any file they consume (including the `mdn-data` / `color-name` / `@webref/*` versions in `package.json` and the vendored `tooling/html-entities.json`).
590590

591591
CI's `lint` job verifies these outputs are up to date. The combined `yarn fix` script runs `fix:code` + `fix:special` + `fmt` in one go; prefer it as the final step.
592592

‎cspell.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@
561561
"test/cases/json/weird-properties/globals.json",
562562
"test/JavascriptParser.unittest.js",
563563
"tooling/html-entities.json",
564-
"tooling/html-reflect.json",
565564
"test/test262-cases/**",
566565
"test/wpt/**",
567566
"test/css-parsing-tests/**",

‎lib/html/data.js‎

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ const REWRITABLE_ATTRIBUTES = new Set([
178178
"rowspan",
179179
"sandbox",
180180
"scope",
181+
"scrollamount",
182+
"scrolldelay",
181183
"size",
182184
"sizes",
183185
"span",
@@ -330,7 +332,7 @@ const BOOLEAN_ATTRIBUTES = new Map([
330332
["autofocus", null],
331333
["autoplay", new Set(["audio", "video"])],
332334
["checked", new Set(["input"])],
333-
["compact", new Set(["dl", "menu", "ol", "ul"])],
335+
["compact", new Set(["dir", "dl", "menu", "ol", "ul"])],
334336
["controls", new Set(["audio", "img", "video"])],
335337
["declare", new Set(["object"])],
336338
["default", new Set(["track"])],
@@ -358,6 +360,7 @@ const BOOLEAN_ATTRIBUTES = new Map([
358360
["muted", new Set(["audio", "video"])],
359361
["nohref", new Set(["area"])],
360362
["nomodule", new Set(["script"])],
363+
["noresize", new Set(["frame"])],
361364
["noshade", new Set(["hr"])],
362365
["novalidate", new Set(["form"])],
363366
["nowrap", new Set(["td", "th"])],
@@ -369,7 +372,8 @@ const BOOLEAN_ATTRIBUTES = new Map([
369372
["selected", new Set(["option"])],
370373
["shadowrootclonable", new Set(["template"])],
371374
["shadowrootdelegatesfocus", new Set(["template"])],
372-
["shadowrootserializable", new Set(["template"])]
375+
["shadowrootserializable", new Set(["template"])],
376+
["truespeed", new Set(["marquee"])]
373377
]);
374378

375379
/**
@@ -435,7 +439,7 @@ const URL_ATTRIBUTES = new Map([
435439
["data", new Set(["object"])],
436440
["formaction", new Set(["button", "input"])],
437441
["href", new Set(["a", "area", "base", "link"])],
438-
["longdesc", new Set(["iframe", "img"])],
442+
["longdesc", new Set(["frame", "iframe", "img"])],
439443
["lowsrc", new Set(["img"])],
440444
["manifest", new Set(["html"])],
441445
["poster", new Set(["video"])],
@@ -444,6 +448,7 @@ const URL_ATTRIBUTES = new Map([
444448
new Set([
445449
"audio",
446450
"embed",
451+
"frame",
447452
"iframe",
448453
"img",
449454
"input",
@@ -480,17 +485,19 @@ const INTEGER_ATTRIBUTES = new Map([
480485
"video"
481486
])
482487
],
483-
["hspace", new Set(["img", "object"])],
488+
["hspace", new Set(["img", "marquee", "object"])],
484489
["maxlength", new Set(["input", "textarea"])],
485490
["minlength", new Set(["input", "textarea"])],
486491
["rows", new Set(["textarea"])],
487492
["rowspan", new Set(["td", "th"])],
493+
["scrollamount", new Set(["marquee"])],
494+
["scrolldelay", new Set(["marquee"])],
488495
["size", new Set(["input", "select"])],
489496
["span", new Set(["col", "colgroup"])],
490497
["start", new Set(["ol"])],
491498
["tabindex", null],
492499
["value", new Set(["li"])],
493-
["vspace", new Set(["img", "object"])],
500+
["vspace", new Set(["img", "marquee", "object"])],
494501
[
495502
"width",
496503
new Set([
@@ -499,10 +506,12 @@ const INTEGER_ATTRIBUTES = new Map([
499506
"iframe",
500507
"img",
501508
"input",
509+
"listing",
502510
"object",
503511
"pre",
504512
"source",
505-
"video"
513+
"video",
514+
"xmp"
506515
])
507516
]
508517
]);
@@ -533,13 +542,13 @@ const COMMA_LIST_ATTRIBUTES = new Set(["accept", "coords", "sizes"]);
533542
*/
534543
const EVENT_HANDLER_ATTRIBUTES = new Map([
535544
["onabort", null],
536-
["onafterprint", new Set(["body"])],
545+
["onafterprint", new Set(["body", "frameset"])],
537546
["onauxclick", null],
538547
["onbeforeinput", null],
539548
["onbeforematch", null],
540-
["onbeforeprint", new Set(["body"])],
549+
["onbeforeprint", new Set(["body", "frameset"])],
541550
["onbeforetoggle", null],
542-
["onbeforeunload", new Set(["body"])],
551+
["onbeforeunload", new Set(["body", "frameset"])],
543552
["onblur", null],
544553
["oncancel", null],
545554
["oncanplay", null],
@@ -568,40 +577,40 @@ const EVENT_HANDLER_ATTRIBUTES = new Map([
568577
["onerror", null],
569578
["onfocus", null],
570579
["onformdata", null],
571-
["onhashchange", new Set(["body"])],
580+
["onhashchange", new Set(["body", "frameset"])],
572581
["oninput", null],
573582
["oninvalid", null],
574583
["onkeydown", null],
575584
["onkeypress", null],
576585
["onkeyup", null],
577-
["onlanguagechange", new Set(["body"])],
586+
["onlanguagechange", new Set(["body", "frameset"])],
578587
["onload", null],
579588
["onloadeddata", null],
580589
["onloadedmetadata", null],
581590
["onloadstart", null],
582-
["onmessage", new Set(["body"])],
583-
["onmessageerror", new Set(["body"])],
591+
["onmessage", new Set(["body", "frameset"])],
592+
["onmessageerror", new Set(["body", "frameset"])],
584593
["onmousedown", null],
585594
["onmouseenter", null],
586595
["onmouseleave", null],
587596
["onmousemove", null],
588597
["onmouseout", null],
589598
["onmouseover", null],
590599
["onmouseup", null],
591-
["onoffline", new Set(["body"])],
592-
["ononline", new Set(["body"])],
593-
["onpagehide", new Set(["body"])],
594-
["onpagereveal", new Set(["body"])],
595-
["onpageshow", new Set(["body"])],
596-
["onpageswap", new Set(["body"])],
600+
["onoffline", new Set(["body", "frameset"])],
601+
["ononline", new Set(["body", "frameset"])],
602+
["onpagehide", new Set(["body", "frameset"])],
603+
["onpagereveal", new Set(["body", "frameset"])],
604+
["onpageshow", new Set(["body", "frameset"])],
605+
["onpageswap", new Set(["body", "frameset"])],
597606
["onpaste", null],
598607
["onpause", null],
599608
["onplay", null],
600609
["onplaying", null],
601-
["onpopstate", new Set(["body"])],
610+
["onpopstate", new Set(["body", "frameset"])],
602611
["onprogress", null],
603612
["onratechange", null],
604-
["onrejectionhandled", new Set(["body"])],
613+
["onrejectionhandled", new Set(["body", "frameset"])],
605614
["onreset", null],
606615
["onresize", null],
607616
["onscroll", null],
@@ -612,13 +621,13 @@ const EVENT_HANDLER_ATTRIBUTES = new Map([
612621
["onselect", null],
613622
["onslotchange", null],
614623
["onstalled", null],
615-
["onstorage", new Set(["body"])],
624+
["onstorage", new Set(["body", "frameset"])],
616625
["onsubmit", null],
617626
["onsuspend", null],
618627
["ontimeupdate", null],
619628
["ontoggle", null],
620-
["onunhandledrejection", new Set(["body"])],
621-
["onunload", new Set(["body"])],
629+
["onunhandledrejection", new Set(["body", "frameset"])],
630+
["onunload", new Set(["body", "frameset"])],
622631
["onvolumechange", null],
623632
["onwaiting", null],
624633
["onwebkitanimationend", null],

‎lib/html/syntax.js‎

Lines changed: 9 additions & 12 deletions
Large diffs are not rendered by default.

‎package.json‎

Lines changed: 4 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 tooling/generate-css-data.js && node tooling/generate-html-data.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 && node tooling/generate-internal-serializables.js",
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-css-data.js && node tooling/generate-html-data.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals && node tooling/generate-internal-serializables.js",
3838
"lint:types": "tsc",
3939
"lint:types-test": "tsc -p tsconfig.types.test.json",
4040
"lint:types-benchmark": "tsc -p tsconfig.types.benchmark.json",
@@ -49,7 +49,7 @@
4949
"fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
5050
"fix": "yarn fix:code && yarn fix:special && yarn fmt",
5151
"fix:code": "yarn lint:code --fix",
52-
"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-css-data.js --write && node tooling/generate-html-data.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 && node tooling/generate-internal-serializables.js --write",
52+
"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-css-data.js --write && node tooling/generate-html-data.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 && node tooling/generate-internal-serializables.js --write",
5353
"fix:serializables": "node tooling/generate-internal-serializables.js --write",
5454
"build:examples": "cd examples && node buildAll.js",
5555
"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",
@@ -138,6 +138,8 @@
138138
"@types/node": "^26.2.0",
139139
"@types/xxhashjs": "^0.2.4",
140140
"@webdiscus/pug-loader": "^2.11.1",
141+
"@webref/elements": "^2.8.0",
142+
"@webref/idl": "^3.83.1",
141143
"assemblyscript": "^0.28.18",
142144
"babel-loader": "^10.0.0",
143145
"bundle-loader": "^0.5.6",

0 commit comments

Comments
 (0)