mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-30 08:56:14 +01:00
standalone :global() with multiple selectors shouldn't be treated as error (#6508)
This commit is contained in:
parent
64c162c6b7
commit
f60cb22a9d
@ -142,6 +142,15 @@ export default class Selector {
|
||||
}
|
||||
}
|
||||
|
||||
this.validate_global_with_multiple_selectors(component);
|
||||
}
|
||||
|
||||
validate_global_with_multiple_selectors(component: Component) {
|
||||
if (this.blocks.length === 1 && this.blocks[0].selectors.length === 1) {
|
||||
// standalone :global() with multiple selectors is OK
|
||||
return;
|
||||
}
|
||||
|
||||
for (const block of this.blocks) {
|
||||
for (const selector of block.selectors) {
|
||||
if (selector.type === 'PseudoClassSelector' && selector.name === 'global') {
|
||||
|
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 1,
|
||||
"character": 54
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 20,
|
||||
"character": 73
|
||||
},
|
||||
"pos": 54
|
||||
}
|
||||
]
|
@ -0,0 +1,12 @@
|
||||
<style>
|
||||
:global(h1, h2, h3), div {
|
||||
color: red;
|
||||
}
|
||||
:global(h1, h2, h3) div {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>hello world</h1>
|
||||
</div>
|
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 1,
|
||||
"character": 54
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 20,
|
||||
"character": 73
|
||||
},
|
||||
"pos": 54
|
||||
}
|
||||
]
|
@ -0,0 +1,12 @@
|
||||
<style>
|
||||
:global(.h1\,h2\,h3).foo {
|
||||
color: red;
|
||||
}
|
||||
:global(h1, h2, h3).foo {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>hello world</h1>
|
||||
</div>
|
@ -3,15 +3,15 @@
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"line": 11,
|
||||
"column": 5,
|
||||
"character": 58
|
||||
"character": 143
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"line": 11,
|
||||
"column": 24,
|
||||
"character": 77
|
||||
"character": 162
|
||||
},
|
||||
"pos": 58
|
||||
"pos": 143
|
||||
}
|
||||
]
|
||||
|
@ -2,6 +2,12 @@
|
||||
div :global(.h1\,h2\,h3) {
|
||||
color: red;
|
||||
}
|
||||
:global(h1, h2, h3) {
|
||||
color: red;
|
||||
}
|
||||
div, :global(h1, h2, h3) {
|
||||
color: red;
|
||||
}
|
||||
div :global(h1, h2, h3) {
|
||||
color: red;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user