Skip to content

Commit d5cd38b

Browse files
committed
allow pseudo class after global
1 parent 5bb2bbf commit d5cd38b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/svelte/src/compiler/phases/2-analyze/css/Selector.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ export default class Selector {
184184
selector.name === 'global' &&
185185
block.selectors.length !== 1 &&
186186
(i === block.selectors.length - 1 ||
187-
block.selectors.slice(i + 1).some((s) => s.type !== 'PseudoElementSelector'))
187+
block.selectors
188+
.slice(i + 1)
189+
.some((s) => s.type !== 'PseudoElementSelector' && s.type !== 'PseudoClassSelector'))
188190
) {
189191
error(selector, 'invalid-css-global-selector-list');
190192
}

packages/svelte/tests/validator/samples/css-invalid-global-placement-2/errors.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"code": "invalid-css-global-placement",
44
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
55
"start": {
6-
"line": 2,
6+
"line": 5,
77
"column": 6
88
},
99
"end": {
10-
"line": 2,
10+
"line": 5,
1111
"column": 19
1212
}
1313
}

packages/svelte/tests/validator/samples/css-invalid-global-placement-2/input.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<style>
2+
.foo :global(.bar):first-child {
3+
color: red;
4+
}
25
.foo :global(.bar):first-child .baz {
36
color: red;
47
}

0 commit comments

Comments
 (0)