Skip to content

Fix Rule#selectors losing the empty selector - #2129

Merged
ai merged 1 commit into
postcss:mainfrom
lazerg:fix/issue-2128-list-comma-empty-string
Aug 6, 2026
Merged

Fix Rule#selectors losing the empty selector#2129
ai merged 1 commit into
postcss:mainfrom
lazerg:fix/issue-2128-list-comma-empty-string

Conversation

@lazerg

@lazerg lazerg commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

8.5.25 made list.split() return [] for an empty string (#2121), so list.comma('') went from [''] to [], and with it Rule#selectors on a rule whose selector is empty.

Plugins read that getter and assume at least one entry. postcss-nested's mergeSelectors() loops over parent.selectors and joins the result back into the child, so an empty parent selector now wipes the child's:

postcss([nested]).process('{ color: red; .dark & { color: blue } }', { from: undefined }).css
// 8.5.24: '{ color: red; } .dark  { color: blue }'
// 8.5.25: '{ color: red; }  { color: blue }'

That is what the Panda CSS reproduction in #2128 hits: the selector is wiped, the block is merged away, and .dark is gone from the tokens layer.

'' is a string, and its last: true split has always been [''], same as the trailing item in list.comma('a, b,'). So this narrows the guard to non-strings, which keeps what #2121 was after (list.split(undefined) no longer throws) without changing the empty-string result.

Fixes #2128

@lazerg
lazerg force-pushed the fix/issue-2128-list-comma-empty-string branch from 193815f to e57b8c7 Compare August 6, 2026 07:54
@ai

ai commented Aug 6, 2026

Copy link
Copy Markdown
Member

cc @amir-rezaei

@ai
ai merged commit 1493a83 into postcss:main Aug 6, 2026
10 checks passed
@ai

ai commented Aug 6, 2026

Copy link
Copy Markdown
Member

Thanks. Released in 8.5.26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with layer generation in 8.5.25

2 participants