Skip to content

Commit a954f2e

Browse files
committed
[scoped styles]: add shorthand for pseudo selectors
1 parent 36dda5b commit a954f2e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

active-rfcs/0023-scoped-styles-changes.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ Provide more consistent custom CSS extensions in Single File Component scoped st
1313
<style scoped>
1414
/* deep selectors */
1515
::v-deep(.foo) {}
16+
/* shorthand */
17+
:deep(.foo) {}
1618
1719
/* targeting slot content */
1820
::v-slotted(.foo) {}
21+
/* shorthand */
22+
:slotted(.foo) {}
1923
2024
/* one-off global rule */
2125
::v-global(.foo) {}
26+
/* shorthand */
27+
:global(.foo) {}
2228
</style>
2329
```
2430

@@ -38,17 +44,19 @@ To avoid the confusion of the dropped `/deep/` combinator, we introduced yet ano
3844

3945
The previous versions of the deep combinator are still supported for compatibility reasons in the current [Vue 2 SFC compiler](https://github.com/vuejs/component-compiler-utils), which again, can be confusing to users. In v3, we are deprecating the support for `>>>` and `/deep/`.
4046

41-
As we were working on the new SFC compiler for v3, we noticed that CSS pseudo elements are in fact semantically NOT [combinators](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators). It is more consistent with idiomatic CSS for pseudo elements to accept arguments instead, so we are also making `::v-deep()` work that way. The current usage of `::v-deep` as a combinator is still supported, however it is considered deprecated and will raise a warning.
47+
As we were working on the new SFC compiler for v3, we noticed that CSS pseudo elements are in fact semantically NOT [combinators](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators). It is more consistent with idiomatic CSS for pseudo elements to accept arguments instead, so we are also making `::v-deep()` work that way. If you don't care about the explicit `v-` prefix, you can also use the shorter `:deep()` variant, which works exactly the same.
48+
49+
The current usage of `::v-deep` as a combinator is still supported, however it is considered deprecated and will raise a warning.
4250

4351
## Targeting / Avoiding Slot Content
4452

4553
Currently, slot content passed in from the parent are affected by both the parent's scoped styles AND the child's scoped styles. There is no way to author rules that explicitly target slot content only, or ones that do not affect slot content.
4654

47-
In v3, we intend to make child scoped styles NOT affecting slot content by default. To explicitly target slot content, the `::v-slotted()` pseudo element can be used.
55+
In v3, we intend to make child scoped styles NOT affecting slot content by default. To explicitly target slot content, the `::v-slotted()` (shorthand: `:slotted()`) pseudo element can be used.
4856

4957
## One-Off Global Rules
5058

51-
Currently to add a global CSS rule we need to use a separate unscoped `<style>` block. We are introducing a new `::v-global()` pseudo element for one-off global rules.
59+
Currently to add a global CSS rule we need to use a separate unscoped `<style>` block. We are introducing a new `::v-global()` (shorthand: `:global()`) pseudo element for one-off global rules.
5260

5361
---
5462

0 commit comments

Comments
 (0)