diff --git a/src/compiler/compile/css/Selector.ts b/src/compiler/compile/css/Selector.ts index d7e80f5499..49ba5e71e5 100644 --- a/src/compiler/compile/css/Selector.ts +++ b/src/compiler/compile/css/Selector.ts @@ -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') ); } } diff --git a/test/validator/samples/css-invalid-global-placement-2/errors.json b/test/validator/samples/css-invalid-global-placement-2/errors.json new file mode 100644 index 0000000000..4594469cc2 --- /dev/null +++ b/test/validator/samples/css-invalid-global-placement-2/errors.json @@ -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 +}] diff --git a/test/validator/samples/css-invalid-global-placement-2/input.svelte b/test/validator/samples/css-invalid-global-placement-2/input.svelte new file mode 100644 index 0000000000..75bd7b66e1 --- /dev/null +++ b/test/validator/samples/css-invalid-global-placement-2/input.svelte @@ -0,0 +1,5 @@ +