mirror of https://github.com/sveltejs/svelte
Fix: consider component and its snippets during css pruning (#15630)
* fix: consider component and its snippets during css pruning * add changeset * fix: avoid iterator.map --------- Co-authored-by: 7nik <kifiranet@gmail.com>pull/15659/head
parent
c822f9b0bf
commit
e035e2838f
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: better consider component and its snippets during css pruning
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let { foo } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{@render foo()}
|
@ -0,0 +1,20 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
warnings: [
|
||||||
|
{
|
||||||
|
code: 'css_unused_selector',
|
||||||
|
message: 'Unused CSS selector "n + m"',
|
||||||
|
end: {
|
||||||
|
character: 468,
|
||||||
|
column: 6,
|
||||||
|
line: 36
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
character: 463,
|
||||||
|
column: 1,
|
||||||
|
line: 36
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
x.svelte-xyz + y:where(.svelte-xyz) { color: green; }
|
||||||
|
x.svelte-xyz + v:where(.svelte-xyz) { color: green; }
|
||||||
|
x.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||||
|
y.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||||
|
v.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||||
|
.component + z.svelte-xyz { color: green; }
|
||||||
|
|
||||||
|
/* (unused) n + m { color: red; }*/
|
@ -0,0 +1,37 @@
|
|||||||
|
<script>
|
||||||
|
import Child from './Child.svelte';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<x></x>
|
||||||
|
<Child>
|
||||||
|
<y></y>
|
||||||
|
{#snippet foo()}
|
||||||
|
<v></v>
|
||||||
|
{/snippet}
|
||||||
|
</Child>
|
||||||
|
<z></z>
|
||||||
|
|
||||||
|
<Child>
|
||||||
|
<span>
|
||||||
|
<n></n>
|
||||||
|
</span>
|
||||||
|
{#snippet foo()}
|
||||||
|
<span>
|
||||||
|
<n></n>
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
|
</Child>
|
||||||
|
<m></m>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
x + y { color: green; }
|
||||||
|
x + v { color: green; }
|
||||||
|
x + z { color: green; }
|
||||||
|
y + z { color: green; }
|
||||||
|
v + z { color: green; }
|
||||||
|
:global(.component) + z { color: green; }
|
||||||
|
|
||||||
|
n + m { color: red; }
|
||||||
|
</style>
|
Loading…
Reference in new issue