disallow multiple selectors inside :global() ()

pull/6314/head
Tan Li Hau 4 years ago committed by GitHub
parent cba92ad2a9
commit bbcc1e7479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -143,6 +143,19 @@ export default class Selector {
}); });
} }
} }
for (const block of this.blocks) {
for (const selector of block.selectors) {
if (selector.type === 'PseudoClassSelector' && selector.name === 'global') {
if (/[^\\],/.test(selector.children[0].value)) {
component.error(selector, {
code: 'css-invalid-global-selector',
message: ':global(...) must contain a single selector'
});
}
}
}
}
} }
get_amount_class_specificity_increased() { get_amount_class_specificity_increased() {

@ -0,0 +1,17 @@
[
{
"code": "css-invalid-global-selector",
"message": ":global(...) must contain a single selector",
"start": {
"line": 5,
"column": 5,
"character": 58
},
"end": {
"line": 5,
"column": 24,
"character": 77
},
"pos": 58
}
]

@ -0,0 +1,12 @@
<style>
div :global(.h1\,h2\,h3) {
color: red;
}
div :global(h1, h2, h3) {
color: red;
}
</style>
<div>
<h1>hello world</h1>
</div>
Loading…
Cancel
Save