Skip to content

Commit 4b62fa2

Browse files
authored
Merge pull request #3141 from sveltejs/gh-1705
add scoping attribute for pseudo-class selectors without a type/class
2 parents 220515b + 0fd34b1 commit 4b62fa2

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)