Repository navigation
Commit 3ff0051
authored
refactor(html): split syntax into syntax-parser and syntax-printer (#22223)
* refactor(html): split syntax into syntax-parser and syntax-printer
The tokenizer, tree construction and entity table now live in
syntax-parser.js and the default node printer in syntax-printer.js,
with lib/html/syntax.js keeping the public surface: it loads both,
binds SourceProcessor to them and re-exports what it always did.
Module state the walk writes and the printer reads moved into one
initialized object, so the two files share it without a stale copy.
generate-html-data.js writes the entity region into the parser file.
* refactor(html): reach the halves through getters, as javascript does
syntax.js now exposes `parser` and `printer` the way lib/javascript's
facade does, and every name it published before is a getter onto the half
that owns it. Nothing loads until a name is read: requiring the facade
loads neither half, and a walk that only fires visitors never loads the
printer.
SourceProcessor asks for its printer on the first print rather than
naming it up front — util/SourceProcessor takes that loader as a third
argument and calls it once per process, never per node. HtmlParser and
HtmlModulesPlugin now import the parser half directly.
`html.syntax.printer` is the printer half now, as in javascript; the
print function it holds is `printer.printer`.
* test(html): cover the printer a processor asks for on its first print
* test: prove a supplied printer is not re-asked for through the loader
* test(html): assert the whole facade surface, not two names of it
The surface test read `parseHtml` and `NodeType`, leaving the other 33
getters unexecuted. Walk every published name instead: each resolves to
a defined value, and each one the parser half spells the same way is
identical to it.
* test(html): state each facade binding instead of counting them
Deriving the expected names from the facade only checked how many there
are: a renamed getter, an alias repointed at another export of the same
module, and a printer-owned name bound to the parser all kept the counts
at 35 and 25. Spell out the source of each of the 35.1 parent 13ec116 commit 3ff0051
18 files changed
Lines changed: 15086 additions & 14308 deletions
File tree
- .changeset
- lib
- html
- util
- test
- configCases
- css/minify-embedded-svg
- html/minify-inline-embedded
- helpers
- unitCases
- tooling
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| |||
737 | 742 | | |
738 | 743 | | |
739 | 744 | | |
740 | | - | |
| 745 | + | |
741 | 746 | | |
742 | 747 | | |
743 | | - | |
| 748 | + | |
744 | 749 | | |
745 | 750 | | |
746 | 751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
34 | | - | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
Large diffs are not rendered by default.
0 commit comments