Skip to content

Commit

Permalink
fix: :global(...):some-pseudoclass should be considered global (#6317)
Browse files Browse the repository at this point in the history
  • Loading branch information
roychoo authored Jun 22, 2021
1 parent 3c889da commit 228832c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compiler/compile/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,10 @@ class Block {

get global() {
return (
this.selectors.length === 1 &&
this.selectors.length >= 1 &&
this.selectors[0].type === 'PseudoClassSelector' &&
this.selectors[0].name === 'global'
this.selectors[0].name === 'global' &&
this.selectors.every((selector) => selector.type === 'PseudoClassSelector')
);
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/validator/samples/css-invalid-global-placement-2/errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[{
"code": "css-invalid-global",
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
"start": {
"line": 2,
"column": 6,
"character": 14
},
"end": {
"line": 2,
"column": 19,
"character": 27
},
"pos": 14
}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<style>
.foo :global(.bar):first-child .baz {
color: red;
}
</style>

0 comments on commit 228832c

Please sign in to comment.