Skip to content

Commit 0fd34b1

Browse files
committed
add scoping attribute for pseudo-class selectors without a type/class - fixes #1705
1 parent 220515b commit 0fd34b1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/compiler/compile/css/Selector.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export default class Selector {
6161
let i = block.selectors.length;
6262
while (i--) {
6363
const selector = block.selectors[i];
64-
if (selector.type === 'PseudoElementSelector' || selector.type === 'PseudoClassSelector') continue;
64+
if (selector.type === 'PseudoElementSelector' || selector.type === 'PseudoClassSelector') {
65+
if (i === 0) code.prependRight(selector.start, attr);
66+
continue;
67+
}
6568

6669
if (selector.type === 'TypeSelector' && selector.name === '*') {
6770
code.overwrite(selector.start, selector.end, attr);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.svelte-xyz:not(.foo){color:red}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p class="foo">foo</p>
2+
<p class="bar">bar</p>
3+
4+
<style>
5+
:not(.foo) {
6+
color: red;
7+
}
8+
</style>

0 commit comments

Comments
 (0)