Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(compiler-sfc): auto add nesting selector for nesting ::v-deep #13163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
edison1105 wants to merge 2 commits into main
base: main
Choose a base branch
Loading
from edison/fix/deepNesting

Conversation

@edison1105
Copy link
Member

@edison1105 edison1105 commented Apr 5, 2025

close #13159

Copy link

github-actions bot commented Apr 5, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 38.1 kB 34.4 kB
vue.global.prod.js 158 kB 58.3 kB 51.9 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.4 kB 18.2 kB 16.6 kB
createApp 54.4 kB 21.2 kB 19.4 kB
createSSRApp 58.6 kB 22.9 kB 20.9 kB
defineCustomElement 59.2 kB 22.7 kB 20.7 kB
overall 68.5 kB 26.4 kB 24 kB

Copy link

pkg-pr-new bot commented Apr 5, 2025
edited
Loading

Open in StackBlitz

@vue/compiler-core
npm i https://pkg.pr.new/@vue/compiler-core@13163
@vue/compiler-dom
npm i https://pkg.pr.new/@vue/compiler-dom@13163
@vue/compiler-ssr
npm i https://pkg.pr.new/@vue/compiler-ssr@13163
@vue/compiler-sfc
npm i https://pkg.pr.new/@vue/compiler-sfc@13163
@vue/reactivity
npm i https://pkg.pr.new/@vue/reactivity@13163
@vue/runtime-core
npm i https://pkg.pr.new/@vue/runtime-core@13163
@vue/runtime-dom
npm i https://pkg.pr.new/@vue/runtime-dom@13163
@vue/server-renderer
npm i https://pkg.pr.new/@vue/server-renderer@13163
@vue/shared
npm i https://pkg.pr.new/@vue/shared@13163
vue
npm i https://pkg.pr.new/vue@13163
@vue/compat
npm i https://pkg.pr.new/@vue/compat@13163

commit: bfd11af

@edison1105 edison1105 changed the title (削除) fix(compiler-sfc): auto add nesting combinators for ::v-deep (削除ここまで) (追記) fix(compiler-sfc): auto add nesting selector for ::v-deep (追記ここまで) Apr 5, 2025
@edison1105 edison1105 changed the title (削除) fix(compiler-sfc): auto add nesting selector for ::v-deep (削除ここまで) (追記) fix(compiler-sfc): auto add nesting selector for nesting ::v-deep (追記ここまで) Apr 5, 2025
Copy link
Member Author

/ecosystem-ci run

github-actions[bot] reacted with thumbs up emoji

Copy link
Contributor

vue-bot commented Apr 5, 2025

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
quasar success success
primevue success success
pinia success success
nuxt success success
radix-vue success success
test-utils success success
vite-plugin-vue success success
router success success
vant success success
vueuse success success
vue-i18n success success
vitepress success success
vue-simple-compiler success success
vuetify success success
vue-macros success success

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: sfc 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Apr 5, 2025
Copy link
Contributor

I think we'd also need to consider the case where the & is inside the :deep(). e.g.:

.foo {
 .bar :deep(&) {
 color: red;
 }
}

This works on main, but it breaks with this PR due to the extra &.

The example above uses :deep(&), but the selector inside the :deep() could be something more complex, rather than just &.


I'm also wondering about media queries within the nesting. e.g.:

.foo {
 @media (screen) {
 :deep(.bar) {
 color: red;
 }
 }
}

There are quite a lot of edge cases here. Some combinations of nesting seem to work, while others don't.

I'm not sure whether this would be considered in scope for this PR, as some cases fail even without :deep().

Copy link

cchangwen commented Jun 8, 2025
edited
Loading

强烈建议保留 :deep inner-selector 语法,因为它更符合语言上的直觉

而 :deep(inner-selector) 多了个小括号语法,是额外的知识负担
而且需要多次看文档、踩坑,才能理解它的一些细节
比如 :deep(inner-selector) 会强制添加空格,这和 scss 的 & 语法冲突:

div:deep() {
 &:hover span { color: red; }
}
// 编译结果:
// 这里 :hover 前面多了个非预期的空格
div[data-v-2ecdb3cb] :hover span {
 color: red;
}

而 :deep 能与 scss& 语法兼容,显然更灵活,
重要的是它符合直觉、容易理解:只需要把 :deep 理解成决定 [data-v-] 位置 css 伪类

div:deep {
 &:hover span { color: red; }
 ... 更多嵌套规则,也只需要在外层加一个 :deep
}
div[data-v-2ecdb3cb]:hover span {
 color: red;
}

https://github.com/orgs/vuejs/discussions/13446

Copy link

Oh, I didn't realize there was a pull request for this! I added a note over here: #13159 (comment). I'd really prefer to see Vue adhering to the CSS spec in this case, rather than deviating from it further.

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

Reviewers

No reviews

Assignees

No one assigned

Labels

🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: sfc

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CSS nesting and :deep() in scoped styles not working

AltStyle によって変換されたページ (->オリジナル) /