Skip to content

Commit 173cd9a

Browse files
committed
Add starting-style to bubble defaults
1 parent 80467c5 commit 173cd9a

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

README.md

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88

99
```css
1010
.phone {
11-
&_title {
12-
width: 500px;
13-
@media (max-width: 500px) {
14-
width: auto;
15-
}
16-
body.is_dark & {
17-
color: white;
18-
}
11+
&_title {
12+
width: 500px;
13+
@media (max-width: 500px) {
14+
width: auto;
1915
}
20-
img {
21-
display: block;
16+
body.is_dark & {
17+
color: white;
2218
}
19+
}
20+
img {
21+
display: block;
22+
}
2323
}
2424

2525
.title {
2626
font-size: var(--font);
2727

2828
@at-root html {
29-
--font: 16px
29+
--font: 16px;
3030
}
3131
}
3232
```
@@ -35,39 +35,39 @@ will be processed to:
3535

3636
```css
3737
.phone_title {
38-
width: 500px;
38+
width: 500px;
3939
}
4040
@media (max-width: 500px) {
41-
.phone_title {
42-
width: auto;
43-
}
41+
.phone_title {
42+
width: auto;
43+
}
4444
}
4545
body.is_dark .phone_title {
46-
color: white;
46+
color: white;
4747
}
4848
.phone img {
49-
display: block;
49+
display: block;
5050
}
5151

5252
.title {
5353
font-size: var(--font);
5454
}
5555
html {
56-
--font: 16px
56+
--font: 16px;
5757
}
5858
```
5959

6060
Related plugins:
6161

62-
* Use [`postcss-current-selector`] **after** this plugin if you want
62+
- Use [`postcss-current-selector`] **after** this plugin if you want
6363
to use current selector in properties or variables values.
64-
* Use [`postcss-nested-ancestors`] **before** this plugin if you want
64+
- Use [`postcss-nested-ancestors`] **before** this plugin if you want
6565
to reference any ancestor element directly in your selectors with `^&`.
6666

6767
Alternatives:
6868

69-
* See also [`postcss-nesting`], which implements [CSSWG draft].
70-
* [`postcss-nested-props`] for nested properties like `font-size`.
69+
- See also [`postcss-nesting`], which implements [CSSWG draft].
70+
- [`postcss-nested-props`] for nested properties like `font-size`.
7171

7272
<a href="https://evilmartians.com/?utm_source=postcss-nested">
7373
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
@@ -76,11 +76,10 @@ Alternatives:
7676

7777
[`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector
7878
[`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors
79-
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
80-
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
81-
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
82-
[PostCSS]: https://github.com/postcss/postcss
83-
79+
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
80+
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
81+
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
82+
[PostCSS]: https://github.com/postcss/postcss
8483

8584
## Usage
8685

@@ -110,16 +109,16 @@ module.exports = {
110109

111110
[official docs]: https://github.com/postcss/postcss#usage
112111

113-
114112
## Options
115113

116114
### `bubble`
117115

118-
By default, plugin will bubble only `@media`, `@supports` and `@layer`
119-
at-rules. Use this option to add your custom at-rules to this list.
116+
By default, plugin will bubble only `@media`, `@supports`, `@layer`,
117+
`@container`, and `@starting-style` at-rules. Use this option
118+
to add your custom at-rules to this list.
120119

121120
```js
122-
postcss([ require('postcss-nested')({ bubble: ['phone'] }) ])
121+
postcss([require('postcss-nested')({ bubble: ['phone'] })])
123122
```
124123

125124
```css
@@ -141,14 +140,13 @@ a {
141140
}
142141
```
143142

144-
145143
### `unwrap`
146144

147145
By default, plugin will unwrap only `@font-face`, `@keyframes` and `@document`
148146
at-rules. You can add your custom at-rules to this list by `unwrap` option:
149147

150148
```js
151-
postcss([ require('postcss-nested')({ unwrap: ['phone'] }) ])
149+
postcss([require('postcss-nested')({ unwrap: ['phone'] })])
152150
```
153151

154152
```css
@@ -168,51 +166,56 @@ a {
168166
}
169167
```
170168

171-
172169
### `preserveEmpty`
173170

174171
By default, plugin will strip out any empty selector generated by intermediate
175172
nesting levels. You can set `preserveEmpty` to `true` to preserve them.
176173

177174
```css
178175
.a {
179-
.b {
180-
color: black;
181-
}
176+
.b {
177+
color: black;
178+
}
182179
}
183180
```
184181

185182
Will be compiled to:
186183

187184
```css
188-
.a { }
185+
.a {
186+
}
189187
.a .b {
190-
color: black;
188+
color: black;
191189
}
192190
```
193191

194192
This is especially useful if you want to export the empty classes with `postcss-modules`.
195193

196-
197194
### `rootRuleName`
198195

199196
The plugin supports the SCSS custom at-rule `@at-root` which breaks rule
200197
blocks out of their nested position. If you want, you can choose a new
201198
custom name for this rule in your code.
202199

203200
```js
204-
postcss([ require('postcss-nested')({ rootRuleName: '_escape-nesting' }) ])
201+
postcss([require('postcss-nested')({ rootRuleName: '_escape-nesting' })])
205202
```
206203

207204
```css
208205
/* input */
209206
.a {
210207
color: white;
211208
@_escape-nesting {
212-
.b { color: black; }
209+
.b {
210+
color: black;
211+
}
213212
}
214213
}
215214
/* output */
216-
.a { color: white; }
217-
.b { color: black; }
215+
.a {
216+
color: white;
217+
}
218+
.b {
219+
color: black;
220+
}
218221
```

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ const hasRootRule = Symbol('hasRootRule')
269269

270270
module.exports = (opts = {}) => {
271271
let bubble = atruleNames(
272-
['media', 'supports', 'layer', 'container'],
272+
['media', 'supports', 'layer', 'container', 'starting-style'],
273273
opts.bubble
274274
)
275275
let atruleChilds = createFnAtruleChilds(bubble)

0 commit comments

Comments
 (0)