bugfix: exempt the :root selector from prefix

- the change in #1705 introduced a small bug for users who were relying on assigning global CSS variables via the :root selector
- this change adds a small exemption to avoid prefixing :root with the random prefix that svelte adds
pull/3250/head
David Mosher 5 years ago
parent 2664260527
commit 1909bb43d9

@ -62,7 +62,9 @@ export default class Selector {
while (i--) {
const selector = block.selectors[i];
if (selector.type === 'PseudoElementSelector' || selector.type === 'PseudoClassSelector') {
if (i === 0) code.prependRight(selector.start, attr);
if (selector.name !== 'root') {
if (i === 0) code.prependRight(selector.start, attr);
}
continue;
}

@ -1 +1 @@
div.svelte-xyz{--test:10}
:root{--root-test:20}div.svelte-xyz{--test:10}

@ -1,7 +1,10 @@
<div></div>
<style>
:root {
--root-test: 20;
}
div {
--test: 10;
}
</style>
</style>

Loading…
Cancel
Save