Skip to content

Commit

Permalink
Merge pull request sveltejs#3250 from davemo/fix/1705-root-pseudo-sel…
Browse files Browse the repository at this point in the history
…ector-prefix-exemption

bugfix: exempt the :root psuedo-selector from the random css prefix
  • Loading branch information
Rich-Harris authored Jul 23, 2019
2 parents 15c57e1 + 1909bb4 commit 8c1f48f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/compiler/compile/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/css-vars/expected.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
div.svelte-xyz{--test:10}
:root{--root-test:20}div.svelte-xyz{--test:10}
5 changes: 4 additions & 1 deletion test/css/samples/css-vars/input.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<div></div>

<style>
:root {
--root-test: 20;
}
div {
--test: 10;
}
</style>
</style>

0 comments on commit 8c1f48f

Please sign in to comment.