Skip to content

Commit

Permalink
fix: allow global next to & for nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti committed May 25, 2024
1 parent d1f5d5d commit 537ea54
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-panthers-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: allow global next to `&` for nesting
6 changes: 6 additions & 0 deletions packages/svelte/src/compiler/phases/3-transform/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ const visitors = {
}

if (relative_selector.selectors.some((s) => s.type === 'NestingSelector')) {
// clean every global selector attached to Nesting before bailing out
for (const selector of relative_selector.selectors) {
if (selector.type === 'PseudoClassSelector' && selector.name === 'global') {
remove_global_pseudo_class(selector);
}
}
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
warnings: []
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div.svelte-xyz {
&.class{
color: red;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="svelte-xyz">
</div>
10 changes: 10 additions & 0 deletions packages/svelte/tests/css/samples/global-with-nesting/input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<style>
div {
&:global(.class){
color: red;
}
}
</style>

<div>
</div>

0 comments on commit 537ea54

Please sign in to comment.