-
-
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: prevent infinite loops when pruning CSS (#14474)
fixes #14472 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
- Loading branch information
1 parent
ca3690f
commit a60e837
Showing
6 changed files
with
88 additions
and
3 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: prevent infinite loops when pruning 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
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
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/css/samples/render-tag-loop/_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,20 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "div + div"', | ||
start: { | ||
line: 19, | ||
column: 1, | ||
character: 185 | ||
}, | ||
end: { | ||
line: 19, | ||
column: 10, | ||
character: 194 | ||
} | ||
} | ||
] | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/svelte/tests/css/samples/render-tag-loop/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,10 @@ | ||
|
||
div div.svelte-xyz { | ||
color: green; | ||
} | ||
/* (unused) div + div { | ||
color: red; /* this is marked as unused, but only because we've written an infinite loop - worth fixing? *\/ | ||
}*/ | ||
div.svelte-xyz:has(div:where(.svelte-xyz)) { | ||
color: green; | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/svelte/tests/css/samples/render-tag-loop/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,25 @@ | ||
{#snippet a()} | ||
{@render b()} | ||
<div> | ||
{@render b()} | ||
</div> | ||
{/snippet} | ||
|
||
{#snippet b()} | ||
{@render a()} | ||
<div> | ||
{@render a()} | ||
</div> | ||
{/snippet} | ||
|
||
<style> | ||
div div { | ||
color: green; | ||
} | ||
div + div { | ||
color: red; /* this is marked as unused, but only because we've written an infinite loop - worth fixing? */ | ||
} | ||
div:has(div) { | ||
color: green; | ||
} | ||
</style> |