-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: better sibling selector handling (#11096)
Keep sibling selectors when dealing with slots/render tags/`svelte:element` tags fixes #9274
- Loading branch information
1 parent
3462c54
commit ed9bab9
Showing
11 changed files
with
199 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: keep sibling selectors when dealing with slots/render tags/`svelte:element` tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-rendertag-global/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
// TODO | ||
// { | ||
// code: 'css-unused-selector', | ||
// message: 'Unused CSS selector ".a ~ .b"', | ||
// start: { character: 111, column: 1, line: 10 }, | ||
// end: { character: 118, column: 8, line: 10 } | ||
// }, | ||
] | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-rendertag-global/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
.before.svelte-xyz + .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .bar:where(.svelte-xyz) { color: green; } | ||
|
||
.x + .foo.svelte-xyz { color: green; } | ||
.x + .foo.svelte-xyz span:where(.svelte-xyz) { color: green; } | ||
.x ~ .foo.svelte-xyz { color: green; } | ||
.x ~ .foo.svelte-xyz span:where(.svelte-xyz) { color: green; } | ||
.x ~ .bar.svelte-xyz { color: green; } | ||
|
||
/* no match */ | ||
/* (unused) :global(.x) + .bar { color: green; }*/ |
23 changes: 23 additions & 0 deletions
23
packages/svelte/tests/css/samples/general-siblings-combinator-rendertag-global/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div> | ||
<p class="before">before</p> | ||
{@render children()} | ||
<p class="foo"> | ||
<span>foo</span> | ||
</p> | ||
<p class="bar">bar</p> | ||
</div> | ||
|
||
<style> | ||
.before + .foo { color: green; } | ||
.before ~ .foo { color: green; } | ||
.before ~ .bar { color: green; } | ||
:global(.x) + .foo { color: green; } | ||
:global(.x) + .foo span { color: green; } | ||
:global(.x) ~ .foo { color: green; } | ||
:global(.x) ~ .foo span { color: green; } | ||
:global(.x) ~ .bar { color: green; } | ||
/* no match */ | ||
:global(.x) + .bar { color: green; } | ||
</style> |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-slot-global/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
// TODO | ||
// { | ||
// code: 'css-unused-selector', | ||
// message: 'Unused CSS selector ".a ~ .b"', | ||
// start: { character: 111, column: 1, line: 10 }, | ||
// end: { character: 118, column: 8, line: 10 } | ||
// }, | ||
] | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-slot-global/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
.before.svelte-xyz + .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .bar:where(.svelte-xyz) { color: green; } | ||
|
||
.x + .foo.svelte-xyz { color: green; } | ||
.x + .foo.svelte-xyz span:where(.svelte-xyz) { color: green; } | ||
.x ~ .foo.svelte-xyz { color: green; } | ||
.x ~ .foo.svelte-xyz span:where(.svelte-xyz) { color: green; } | ||
.x ~ .bar.svelte-xyz { color: green; } | ||
|
||
/* no match */ | ||
/* (unused) :global(.x) + .bar { color: green; }*/ |
23 changes: 23 additions & 0 deletions
23
packages/svelte/tests/css/samples/general-siblings-combinator-slot-global/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div> | ||
<p class="before">before</p> | ||
<slot></slot> | ||
<p class="foo"> | ||
<span>foo</span> | ||
</p> | ||
<p class="bar">bar</p> | ||
</div> | ||
|
||
<style> | ||
.before + .foo { color: green; } | ||
.before ~ .foo { color: green; } | ||
.before ~ .bar { color: green; } | ||
:global(.x) + .foo { color: green; } | ||
:global(.x) + .foo span { color: green; } | ||
:global(.x) ~ .foo { color: green; } | ||
:global(.x) ~ .foo span { color: green; } | ||
:global(.x) ~ .bar { color: green; } | ||
/* no match */ | ||
:global(.x) + .bar { color: green; } | ||
</style> |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-svelteelement/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
// TODO | ||
// { | ||
// code: 'css-unused-selector', | ||
// message: 'Unused CSS selector ".a ~ .b"', | ||
// start: { character: 111, column: 1, line: 10 }, | ||
// end: { character: 118, column: 8, line: 10 } | ||
// }, | ||
] | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/css/samples/general-siblings-combinator-svelteelement/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
.before.svelte-xyz + .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .foo:where(.svelte-xyz) { color: green; } | ||
.before.svelte-xyz ~ .bar:where(.svelte-xyz) { color: green; } | ||
|
||
.x.svelte-xyz + .foo:where(.svelte-xyz) { color: green; } | ||
.x.svelte-xyz + .foo:where(.svelte-xyz) span:where(.svelte-xyz) { color: green; } | ||
.x.svelte-xyz ~ .foo:where(.svelte-xyz) { color: green; } | ||
.x.svelte-xyz ~ .foo:where(.svelte-xyz) span:where(.svelte-xyz) { color: green; } | ||
.x.svelte-xyz ~ .bar:where(.svelte-xyz) { color: green; } | ||
|
||
/* no match */ | ||
/* (unused) .x + .bar { color: green; }*/ |
27 changes: 27 additions & 0 deletions
27
packages/svelte/tests/css/samples/general-siblings-combinator-svelteelement/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script> | ||
let tag = 'div' | ||
</script> | ||
|
||
<div> | ||
<p class="before">before</p> | ||
<svelte:element class="x" this={tag}></svelte:element> | ||
<p class="foo"> | ||
<span>foo</span> | ||
</p> | ||
<p class="bar">bar</p> | ||
</div> | ||
|
||
<style> | ||
.before + .foo { color: green; } | ||
.before ~ .foo { color: green; } | ||
.before ~ .bar { color: green; } | ||
.x + .foo { color: green; } | ||
.x + .foo span { color: green; } | ||
.x ~ .foo { color: green; } | ||
.x ~ .foo span { color: green; } | ||
.x ~ .bar { color: green; } | ||
/* no match */ | ||
.x + .bar { color: green; } | ||
</style> |