Skip to content

Commit c431f1c

Browse files
committed
postcss-nesting : partially revert 10.1.9 and fix #510
1 parent edb4700 commit c431f1c

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

plugins/postcss-nesting/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changes to PostCSS Nesting
22

3+
### Unreleased
4+
5+
- Partially revert the changes to pseudo element selectors from 10.1.9.
6+
7+
```diff
8+
.anything::before {
9+
@nest .something_else > & {
10+
order: 1;
11+
}
12+
}
13+
14+
/* becomes */
15+
16+
- .something_else > :is(.anything:::before) { /* 10.1.9 */
17+
+ .something_else > .anything::before { /* previous and restored behavior */
18+
order: 1;
19+
}
20+
```
21+
22+
The exact behavior of this pattern is unspecified and might change in the future.
23+
We are reverting to the previous behavior until the specification is clarified.
24+
325
### 10.1.9 (June 23, 2022)
426

527
- Fix selector order with any pseudo element.

plugins/postcss-nesting/src/lib/merge-selectors/merge-selectors.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export default function mergeSelectors(fromSelectors, toSelectors, opts) {
157157
}
158158

159159
function isSimpleSelector(selector) {
160-
if (selector.type === 'combinator' || parser.isPseudoElement(selector)) {
160+
if (selector.type === 'combinator') {
161161
return false;
162162
}
163163

@@ -178,7 +178,7 @@ function isCompoundSelector(selector, toSelector = null) {
178178
}
179179

180180
const hasCombinators = !!(selector.parent.nodes.find((x) => {
181-
return x.type === 'combinator' || parser.isPseudoElement(x);
181+
return x.type === 'combinator';
182182
}));
183183

184184
if (hasCombinators) {
@@ -210,10 +210,6 @@ function nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(selecto
210210
if (selector.parent.nodes[i].type === 'combinator' && (selector.parent.nodes[i].value !== ' ' && selector.parent.nodes[i].value !== '>')) {
211211
return false;
212212
}
213-
214-
if (parser.isPseudoElement(selector.parent.nodes[i])) {
215-
return false;
216-
}
217213
}
218214

219215
return true;

plugins/postcss-nesting/test/pseudo-element.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@
3737
}
3838
}
3939
}
40+
41+
.anything::before {
42+
@nest .something_else > & {
43+
order: 9;
44+
}
45+
}

plugins/postcss-nesting/test/pseudo-element.expect.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
.foo:is(::before), ::before:focus {
3+
.foo::before, ::before:focus {
44
order: 1;
55
}
66

@@ -31,3 +31,7 @@
3131
.a::after:hover {
3232
order: 8;
3333
}
34+
35+
.something_else > .anything::before {
36+
order: 9;
37+
}

0 commit comments

Comments
 (0)