fix: mark pseudo classes nested inside `:not` as used (#14303)

fixes the css bug part of #14299
pull/14317/head
Simon H 4 days ago committed by GitHub
parent 6373641045
commit efc65d4e0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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