fix(compiler-sfc): preserve leading universal selector when followed by combinator#14549
fix(compiler-sfc): preserve leading universal selector when followed by combinator#14549babu-ch wants to merge 7 commits intovuejs:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPreserve leading universal selectors before combinators and modify scoped-selector rewriting to respect nested rule contexts by propagating an Changes
Sequence Diagram(s)(omitted — changes are localized selector-rewrite logic and tests) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/compiler-sfc/src/style/pluginScoped.ts`:
- Around line 202-209: The condition in pluginScoped.ts that checks
rule.parent?.type !== 'rule' should be replaced with an ancestor walk to
determine if any ancestor node is a 'rule' (so selectors inside an at-rule
nested within a rule are recognized as nested). Update the check where next.type
=== 'combinator' and next.value === ' ' to compute something like
"hasRuleAncestor" by walking rule.parent up the parent chain until null and
testing node.type === 'rule', then use !hasRuleAncestor instead of
rule.parent?.type !== 'rule' when deciding to remove the combinator and node.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 09a648c9-a51d-4683-8ce3-39e593d1908a
📒 Files selected for processing (2)
packages/compiler-sfc/__tests__/compileStyle.spec.tspackages/compiler-sfc/src/style/pluginScoped.ts
…ing universal selector
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
| }) | ||
|
|
||
| test('should keep leading universal selector before non-space combinator', () => { | ||
| // * > .foo: * removed → invalid CSS ` > .foo` |
There was a problem hiding this comment.
The comment here is unnecessary.
|
Here is a regression
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/compiler-sfc/src/style/pluginScoped.ts`:
- Line 104: The recursive rewriteSelector calls do not propagate the isNested
flag, causing nested pseudo-selector branches (e.g., :slotted, :is, :where) to
incorrectly treat universals as non-nested; update every recursive invocation of
rewriteSelector inside the :slotted handler and inside the :is/:where handler
(and similar branches around lines referenced) to pass the current isNested
value through (i.e., rewriteSelector(child, isNested)) so nested contexts keep
the correct flag instead of defaulting to false.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f7523476-eddd-4481-a791-0e7094eca38e
📒 Files selected for processing (2)
packages/compiler-sfc/__tests__/compileStyle.spec.tspackages/compiler-sfc/src/style/pluginScoped.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/compiler-sfc/tests/compileStyle.spec.ts
|
@edison1105 Thanks for the review. |
close #13429
Summary by CodeRabbit
Tests
Bug Fixes