Repository navigation
Call the builder with every node when the output is escaped - #2175
Conversation
Since 8.5.29 the stringifier of ours buffers the output from the first `<` on and, where it escaped anything, hands the builder all of it as a single piece — of the root's own, marked with `start` since 8.5.30. A builder is documented to be called with every node's string and node instance, and ours is how a custom syntax gets to know which part of the output belongs to which node, so the escaping took that away from every builder that is given a stylesheet holding `<style`, `</style` or `<!--`. The escaping is what the buffer is for, so the text cannot be escaped piece by piece. It can be cut back into the pieces it was built from: escaping only ever replaces a `<` with the three characters longer `\3c `, so the escaped text holds every part in the order the chunks were buffered in, each around its own nodes. Doing that restores the builder calls, and the source map of the escaping stays as precise as it is now, since each piece is mapped where its node stands rather than the whole output standing at the root.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Thanks. Released in 8.5.31 |
|
Thank you for accepting this fix! |
Bumps `postcss` from 8.5.30 to 8.5.31, both in the root resolution and in the `@dnb/eufemia` dev dependency. 8.5.31 is a bug fix with no security fix ([release](https://github.com/postcss/postcss/releases/tag/8.5.31)). `npm diff` shows only two code changes: - `lib/stringify.js`: when `SafeStringifier` escapes `</style>` or `<!--` in CSS, it now builds a correct source map for every node. Before, it mapped only the start of the node (postcss/postcss#2175). - `lib/processor.js`: the version string. The escaped CSS text itself is unchanged, so the CSS we build cannot change. No other dependency changes. In the lockfile, only the `postcss` entry changes. **Verified locally** - I built all library CSS with `makeLibStyles` and `makeMainStyle` in production mode, so the `--isolated` variants are included. That is 500 files: 125 plain, 125 `.min.css` and 250 isolated. - The files are byte-identical on 8.5.30 and 8.5.31, both before and after rebasing onto the current `main`. - Two `main` builds also matched each other (control, 0 differing). - Old `main` against new `main` showed 24 differing files, from the style change in #10032 (positive control). So the comparison does see real changes. - `vitest run src/plugins scripts/prebuild` passes (297 tests). This covers the repo's own PostCSS plugins and the style build. `lint:styles` passes. - `yarn install --immutable`, `yarn dedupe --check`, `lint:resolutions` and the three `audit:ci` workspaces pass.
Closes #2174.
Since 8.5.29 the stringifier buffers the output from the first
<on and, where it escaped anything, hands the builder all of it as a single piece. A builder is documented to be called with every node's string and node instance, so a stylesheet holding<style,</styleor<!--no longer tells a custom syntax which part of the output belongs to which node.The escaping is what the buffer is for, so the text cannot be escaped piece by piece. It can be cut back into the pieces it was built from: escaping only ever replaces a
<with the three characters longer\3c, so the escaped text holds every part in the order the chunks were buffered in, each around its own nodes. This PR does that, so the builder calls come back.The source map of the escaping stays as precise as it is in 8.5.30: each piece is mapped where its node stands, rather than the whole output standing at the root. The mapping added by #2169 is not added again, as
test/map.test.tsshows.On 8.5.30:
Here:
Summary by CodeRabbit