Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: global with pseudo element should be considered as global #6317

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/compiler/compile/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,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>