Skip to content

fix(styles): treat newlines/tabs as CSS descendant combinators in encapsulation#175

Merged
Brooooooklyn merged 1 commit intovoidzero-dev:mainfrom
ashley-hunter:fix/style-encapsulation-comment-newline
Mar 27, 2026
Merged

fix(styles): treat newlines/tabs as CSS descendant combinators in encapsulation#175
Brooooooklyn merged 1 commit intovoidzero-dev:mainfrom
ashley-hunter:fix/style-encapsulation-comment-newline

Conversation

@ashley-hunter
Copy link
Copy Markdown
Contributor

@ashley-hunter ashley-hunter commented Mar 27, 2026

Summary

Issue where if a style had a comment before it, the style was not encapsulated.

  • split_by_combinators() only recognized ' ' (space) as a whitespace descendant combinator, missing \n, \t, and \r
  • When a comment placeholder (%COMMENT%) was followed by a newline, the placeholder and selector merged into one part, causing scope_simple_selector to bail out and skip scoping the first rule
  • This surfaced when SCSS @import pulled in files with block comments — Sass hoists the comment before the first rule, and the newline after it triggered the bug

Test plan

  • Added 6 regression tests covering comment+space, comment+newline, multiline comment, multiple comments, newline as descendant combinator, and :host with newline combinator
  • TDD verified: tests fail without fix, pass with fix
  • Full test suite (987+ unit tests, 66 shadow CSS tests) passes with zero regressions

…apsulation

split_by_combinators() only recognized ' ' (space) as a whitespace
descendant combinator, missing '\n', '\t', and '\r'. When a comment
placeholder (%COMMENT%) was followed by a newline, the placeholder and
selector merged into one part, causing scope_simple_selector to bail
out and skip scoping the first rule entirely.

This surfaced when SCSS @import pulled in files with block comments —
Sass hoists the comment before the first rule, and the newline after
it triggered the bug.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn merged commit cec9ef8 into voidzero-dev:main Mar 27, 2026
2 checks passed
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.

2 participants