mirror of https://github.com/sveltejs/svelte
parent
6f03561ae4
commit
829be3d611
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: take snippets into account when scoping CSS
|
@ -0,0 +1,20 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
warnings: [
|
||||
{
|
||||
code: 'css_unused_selector',
|
||||
message: 'Unused CSS selector "span div"',
|
||||
start: {
|
||||
line: 31,
|
||||
column: 1,
|
||||
character: 461
|
||||
},
|
||||
end: {
|
||||
line: 31,
|
||||
column: 9,
|
||||
character: 469
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
|
||||
div.svelte-xyz > span:where(.svelte-xyz) {
|
||||
color: green;
|
||||
}
|
||||
div.svelte-xyz span:where(.svelte-xyz) {
|
||||
color: green;
|
||||
}
|
||||
div.svelte-xyz span {
|
||||
color: green;
|
||||
}
|
||||
p.svelte-xyz span:where(.svelte-xyz) {
|
||||
color: green;
|
||||
}
|
||||
p.svelte-xyz .foo:where(.svelte-xyz) {
|
||||
color: purple; /* doesn't match, but our static analysis doesn't handle this currently */
|
||||
}
|
||||
/* (unused) span div {
|
||||
color: red;
|
||||
}*/
|
@ -0,0 +1,2 @@
|
||||
<div class="svelte-xyz"><span class="svelte-xyz">Hello world</span></div>
|
||||
<p class="svelte-xyz"><strong><span class="svelte-xyz">Hello world</span></strong></p>
|
@ -0,0 +1,34 @@
|
||||
{#snippet my_snippet()}
|
||||
<span>Hello world</span>
|
||||
{/snippet}
|
||||
|
||||
<div>{@render my_snippet()}</div>
|
||||
|
||||
<p>
|
||||
{#snippet my_snippet()}
|
||||
<span>Hello world</span>
|
||||
{/snippet}
|
||||
|
||||
<strong>{@render my_snippet()}</strong>
|
||||
</p>
|
||||
|
||||
<style>
|
||||
div > span {
|
||||
color: green;
|
||||
}
|
||||
div span {
|
||||
color: green;
|
||||
}
|
||||
div :global(span) {
|
||||
color: green;
|
||||
}
|
||||
p span {
|
||||
color: green;
|
||||
}
|
||||
p .foo {
|
||||
color: purple; /* doesn't match, but our static analysis doesn't handle this currently */
|
||||
}
|
||||
span div {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
Loading…
Reference in new issue