Support dotted layer names in @layer at-rule prelude parsing#268
Merged
Conversation
parse_layer_names() only handled bare IDENT tokens, so a nested layer name like a.b.c was tokenized as three separate LayerName nodes with the connecting '.' silently discarded. Reprinting those nodes as a comma list turned one nested layer into unrelated top-level layers, changing cascade order. Glue immediately-adjacent 'ident . ident' sequences (no whitespace around the dot, per the <layer-name> grammar) into a single LAYER_NAME node spanning the whole dotted name.
Contributor
|
| 📦 Package | 📋 Versions |
|---|---|
| tinybench | 2 versions
|
| @babel/helper-validator-identifier | 2 versions
|
| js-tokens | 2 versions
|
| @babel/parser | 2 versions
|
| @babel/types | 2 versions
|
| @babel/helper-string-parser | 2 versions
|
| @emnapi/core | 3 versions
|
| @emnapi/wasi-threads | 2 versions
|
| @emnapi/runtime | 3 versions
|
| @rolldown/binding-wasm32-wasi | 2 versions
|
| obug | 2 versions
|
| picomatch | 2 versions
|
| postcss-value-parser | 2 versions
|
| glob-parent | 2 versions
|
| yaml | 2 versions
|
| is-arrayish | 2 versions
|
| get-tsconfig | 2 versions
|
| semver | 2 versions
|
| @oxc-project/types | 2 versions
|
| rolldown | 2 versions
|
| @rolldown/binding-android-arm64 | 2 versions
|
| @rolldown/binding-darwin-arm64 | 2 versions
|
| @rolldown/binding-darwin-x64 | 2 versions
|
| @rolldown/binding-freebsd-x64 | 2 versions
|
| @rolldown/binding-linux-arm-gnueabihf | 2 versions
|
| @rolldown/binding-linux-arm64-gnu | 2 versions
|
| @rolldown/binding-linux-arm64-musl | 2 versions
|
| @rolldown/binding-linux-ppc64-gnu | 2 versions
|
| @rolldown/binding-linux-s390x-gnu | 2 versions
|
| @rolldown/binding-linux-x64-gnu | 2 versions
|
| @rolldown/binding-linux-x64-musl | 2 versions
|
| @rolldown/binding-openharmony-arm64 | 2 versions
|
| @rolldown/binding-win32-arm64-msvc | 2 versions
|
| @rolldown/binding-win32-x64-msvc | 2 versions
|
| tinyexec | 2 versions
|
💡 To find out what depends on a specific package, run: pnpm -r why example-package
⚠️ Package Size Increase
| 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change |
|---|---|---|---|
| @projectwallace/css-parser | 41 kB | 41.1 kB | +78 B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for parsing dotted layer names (e.g.,
a.b.c) in CSS@layerat-rule prelude declarations, allowing nested layer references to be properly recognized and preserved.Key Changes
parse_layer_names()to recognize and preserve dotted notation in layer names by consuming consecutive.and<ident>tokens that immediately follow the initial identifier with no whitespace gapsa. bparses as two separate names)TOKEN_DELIMimport to support dot token detectionCHAR_PERIODconstant for dot character code comparisond.e.f)Implementation Details
The parser now uses a lookahead mechanism with position save/restore to safely attempt consuming dot-identifier segments. It validates that:
TOKEN_DELIMwith character code matchingCHAR_PERIODIf any condition fails, the parser restores the previous position and stops consuming segments, allowing the comma separator or end of prelude to be processed normally.
https://claude.ai/code/session_01R9GWUSxhM3VVAWVFs9F5bG