Repository navigation
Commit 0e0bd79
authored
refactor(css): split syntax into syntax-parser and syntax-printer (#22222)
* refactor(css): split syntax into syntax-parser and syntax-printer
The CSS engine and its default printer now live in files of their own,
with lib/css/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; the
streaming writer sits in a second one to keep CssPath out of its type.
Dependencies run one way — printer to parser, facade to both.
* refactor(css): 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. In-repo readers
that never print (CssParser, CssIcssExportDependency, the html parser's
css tokens) now import the parser half directly.
`css.syntax.printer` is the printer half now, as in javascript; the
print function it holds is `printer.printer`.
* test(css): cover the printer a processor asks for on its first print
* test(css): assert the whole facade surface, not two names of it
The surface test read `parseAStylesheet` and `NodeType`, leaving the
other 53 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(css): state each facade binding instead of counting them
Deriving the expected names from the facade only checked how many there
are: a renamed getter and an alias repointed at another export of the
same module both kept the counts at 55 and 49. Spell out the source of
each of the 55.
* refactor(css): keep the printer's parser imports sorted
`_anyUnordered`, which the ported seam fix reaches across the cut, was
inserted ahead of `_alphaByteText` rather than after it.1 parent bb2c8dd commit 0e0bd79
14 files changed
Lines changed: 20778 additions & 19727 deletions
File tree
- .changeset
- lib
- css
- dependencies
- html
- test
- helpers
- specCases
- unitCases
- tooling
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
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 | | |
| |||
0 commit comments