some progress

pull/10491/head
Rich Harris 3 years ago
parent 4b0a0c67ff
commit aaf9fd22ca

@ -167,7 +167,17 @@ const visitors = {
state.code.appendLeft(last, '*/');
}
const specificity = path.at(-1)?.type === 'Rule' ? { bumped: false } : state.specificity;
// if we're in a `:is(...)` or whatever, keep existing specificity bump state
let specificity = state.specificity;
// if this selector list belongs to a rule, require a specificity bump for the
// first scoped selector but only if we're at the top level
// TODO this isn't quite right, it would break with `:global(x) {...}`
const parent = path.at(-1);
if (parent?.type === 'Rule') {
specificity = { bumped: !!parent.metadata.parent_rule };
}
next({ ...state, specificity });
},
ComplexSelector(node, context) {

@ -13,13 +13,13 @@
/* (unused) .unused {
color: red;
.c:where(.svelte-xyz) {
.c {
color: red;
}
}*/
}
/* (empty) .d:where(.svelte-xyz) {
/* (empty) .d {
.unused {
color: red;
}
@ -29,7 +29,7 @@
& .b:where(.svelte-xyz) {
color: green;
/* (empty) .c:where(.svelte-xyz) {
/* (empty) .c {
& & {
color: red;
}
@ -42,7 +42,7 @@
/* silly but valid */
&& {
color: rebeccapurple;
color: green;
}
.container:where(.svelte-xyz) & {

@ -56,7 +56,7 @@
/* silly but valid */
&& {
color: rebeccapurple;
color: green;
}
.container & {

Loading…
Cancel
Save