Skip to content

fix(compiler-sfc): keep scope id on :deep() selector lists with nesting (fix #15205) - #15206

Closed
lazerg wants to merge 1 commit into
vuejs:mainfrom
lazerg:fix/issue-15205-deep-selector-list
Closed

fix(compiler-sfc): keep scope id on :deep() selector lists with nesting (fix #15205)#15206
lazerg wants to merge 1 commit into
vuejs:mainfrom
lazerg:fix/issue-15205-deep-selector-list

Conversation

@lazerg

@lazerg lazerg commented Aug 3, 2026

Copy link
Copy Markdown

When a scoped style rule mixes a comma-separated selector list, a :deep() member, and nested child rules, one of the plain members can end up without a scope id, so its selector leaks to the whole page.

The rule's :deep status is set as a side effect while each member of the list is rewritten. A member that comes before the :deep() one reads the status as not-yet-deep and skips the scope id. This resolves the status once for the whole list before any member is rewritten, so every member gets scoped regardless of its position.

Fixes #15205

Summary by CodeRabbit

  • Bug Fixes

    • Fixed scoped CSS handling for :deep() selectors when combined with nested rules.
    • Ensured selector scoping remains correct regardless of selector order.
    • Preserved nested child selectors in affected styles.
  • Tests

    • Added regression coverage for deep selectors within selector lists.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 483998d5-b8f7-489d-a03a-9070aa5dbb84

📥 Commits

Reviewing files that changed from the base of the PR and between b5f8518 and 9f8fcd3.

📒 Files selected for processing (2)
  • packages/compiler-sfc/__tests__/compileStyle.spec.ts
  • packages/compiler-sfc/src/style/pluginScoped.ts

📝 Walkthrough

Walkthrough

The scoped CSS plugin now detects :deep() across the full selector list before rewriting selectors. Regression tests cover nested rules with both selector orderings and verify correct scope injection.

Changes

Scoped CSS deep selector handling

Layer / File(s) Summary
Detect deep selectors before rewriting
packages/compiler-sfc/src/style/pluginScoped.ts, packages/compiler-sfc/__tests__/compileStyle.spec.ts
processRule scans the complete selector list before rewriting. Tests verify scoped output and preservation of nested > span rules for both selector orderings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: scope: sfc, :hammer: p3-minor-bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the scoped CSS fix for :deep() selector lists with nesting.
Linked Issues check ✅ Passed The implementation and regression tests address all stated requirements in issue #15205.
Out of Scope Changes check ✅ Passed The changes are limited to the scoped CSS fix and its regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@15206
npm i https://pkg.pr.new/@vue/compiler-core@15206
yarn add https://pkg.pr.new/@vue/compiler-core@15206.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@15206
npm i https://pkg.pr.new/@vue/compiler-dom@15206
yarn add https://pkg.pr.new/@vue/compiler-dom@15206.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@15206
npm i https://pkg.pr.new/@vue/compiler-sfc@15206
yarn add https://pkg.pr.new/@vue/compiler-sfc@15206.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@15206
npm i https://pkg.pr.new/@vue/compiler-ssr@15206
yarn add https://pkg.pr.new/@vue/compiler-ssr@15206.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@15206
npm i https://pkg.pr.new/@vue/reactivity@15206
yarn add https://pkg.pr.new/@vue/reactivity@15206.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@15206
npm i https://pkg.pr.new/@vue/runtime-core@15206
yarn add https://pkg.pr.new/@vue/runtime-core@15206.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@15206
npm i https://pkg.pr.new/@vue/runtime-dom@15206
yarn add https://pkg.pr.new/@vue/runtime-dom@15206.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@15206
npm i https://pkg.pr.new/@vue/server-renderer@15206
yarn add https://pkg.pr.new/@vue/server-renderer@15206.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@15206
npm i https://pkg.pr.new/@vue/shared@15206
yarn add https://pkg.pr.new/@vue/shared@15206.tgz

vue

pnpm add https://pkg.pr.new/vue@15206
npm i https://pkg.pr.new/vue@15206
yarn add https://pkg.pr.new/vue@15206.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@15206
npm i https://pkg.pr.new/@vue/compat@15206
yarn add https://pkg.pr.new/@vue/compat@15206.tgz

commit: 9f8fcd3

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 107 kB 40.5 kB 36.3 kB
vue.global.prod.js 166 kB 60.6 kB 53.8 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.2 kB 19.1 kB 17.5 kB
createApp 57.3 kB 22.2 kB 20.3 kB
createSSRApp 61.9 kB 24.1 kB 21.9 kB
defineCustomElement 63.5 kB 24.1 kB 22 kB
overall 71.9 kB 27.5 kB 25 kB

@edison1105

Copy link
Copy Markdown
Member

Thanks for the fix. Closing in favor of #15270

@edison1105 edison1105 closed this Aug 12, 2026
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.

@vue/compiler-sfc: Partly unscoped styling with selector list & :deep & nesting

2 participants