fix: mark pseudo classes nested inside `:not` as used

fixes the css bug part of #14299
pull/14303/head
Simon Holthausen 2 years ago
parent 312dd51acc
commit 85e54e0f4a

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: mark pseudo classes nested inside `:not` as used

@ -150,8 +150,9 @@ const css_visitors = {
// So that nested selectors like `:root:not(.x)` are not marked as unused
for (const child of node.selectors) {
walk(/** @type {Css.Node} */ (child), null, {
ComplexSelector(node) {
ComplexSelector(node, context) {
node.metadata.used = true;
context.next();
}
});
}

@ -531,7 +531,12 @@ function relative_selector_might_apply_to_node(relative_selector, rule, element,
// with descendants, in which case we scope them all.
if (name === 'not' && selector.args) {
for (const complex_selector of selector.args.children) {
complex_selector.metadata.used = true;
walk(complex_selector, null, {
ComplexSelector(node, context) {
node.metadata.used = true;
context.next();
}
});
const relative = truncate(complex_selector);
if (complex_selector.children.length > 1) {

@ -29,3 +29,7 @@
span.svelte-xyz:not(:focus) {
color: green;
}
p.svelte-xyz:not(:has(span)) {
color: green;
}

@ -36,4 +36,8 @@
span:not(:focus) {
color: green;
}
p:not(:has(span)) {
color: green;
}
</style>
Loading…
Cancel
Save