fix: bump specificity on all members of a selector list (#10730)

Previously, only `div span` in `div span, div div { .. }` would've gotten the specificity bump
pull/10716/head
Simon H 2 years ago committed by GitHub
parent b1267b03b6
commit 304db0d5b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: bump specificity on all members of a selector list

@ -191,6 +191,8 @@ const visitors = {
next({ ...state, specificity });
},
ComplexSelector(node, context) {
const before_bumped = context.state.specificity.bumped;
/** @param {import('#compiler').Css.SimpleSelector} selector */
function remove_global_pseudo_class(selector) {
context.state.code
@ -261,6 +263,8 @@ const visitors = {
}
context.next();
context.state.specificity.bumped = before_bumped;
},
PseudoClassSelector(node, context) {
if (node.name === 'is' || node.name === 'where') {

@ -0,0 +1,6 @@
div.svelte-xyz {
color: red;
}
div.svelte-xyz span:where(.svelte-xyz), div.svelte-xyz div:where(.svelte-xyz) {
color: blue;
}

@ -0,0 +1 @@
<div class="svelte-xyz"><span class="svelte-xyz">text</span><div class="svelte-xyz">text</div></div>

@ -0,0 +1,13 @@
<div>
<span>text</span>
<div>text</div>
</div>
<style>
div {
color: red;
}
div span, div div {
color: blue;
}
</style>
Loading…
Cancel
Save