pull/15450/head
Rich Harris 1 year ago
parent 5e0b8ced33
commit e8b5f686e6

@ -207,10 +207,11 @@ const css_visitors = {
Rule(node, context) {
node.metadata.parent_rule = context.state.rule;
// if this rule has a ComplexSelector whose RelativeSelector children
// are all `:global(...)`
// if this rule has a ComplexSelector whose RelativeSelector children are all
// `:global(...)`, and the rule contains declarations (rather than just
// nested rules) then the component as a whole includes global CSS
context.state.has_global.value ||=
node.block.children.length > 0 &&
node.block.children.filter((child) => child.type === 'Declaration').length > 0 &&
node.prelude.children.some((selector) => selector.children.every(is_global)) &&
is_unscoped_global(context.path);

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
hasGlobal: false
});

@ -0,0 +1,12 @@
div.svelte-xyz {
.whatever {
color: green;
}
}
.whatever {
div.svelte-xyz {
color: green;
}
}

@ -0,0 +1,15 @@
<div>{@html whatever}</div>
<style>
div {
:global(.whatever) {
color: green;
}
}
:global(.whatever) {
div {
color: green;
}
}
</style>

@ -3,5 +3,5 @@ import { test } from '../../test';
export default test({
warnings: [],
hasGlobal: true
hasGlobal: false
});

Loading…
Cancel
Save