-
-
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.
feat: allow const tag inside
svelte:boundary
(#14993)
* feat: allow const tag inside `svelte:boundary` * chore: add better test * docs: update docs for `@const`
- Loading branch information
1 parent
efa5acf
commit a129592
Showing
9 changed files
with
70 additions
and
5 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 | ||
--- | ||
|
||
feat: allow const tag inside `svelte:boundary` |
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
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
3 changes: 3 additions & 0 deletions
3
packages/svelte/tests/runtime-runes/samples/const-tag-boundary/FlakyComponent.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,3 @@ | ||
<script> | ||
throw new Error(); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
packages/svelte/tests/runtime-runes/samples/const-tag-boundary/_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,17 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: '<button></button><p>2</p>', | ||
mode: ['client'], | ||
test({ target, assert }) { | ||
const btn = target.querySelector('button'); | ||
const p = target.querySelector('p'); | ||
|
||
flushSync(() => { | ||
btn?.click(); | ||
}); | ||
|
||
assert.equal(p?.innerHTML, '4'); | ||
} | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/runtime-runes/samples/const-tag-boundary/main.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,14 @@ | ||
<script> | ||
import FlakyComponent from "./FlakyComponent.svelte"; | ||
let test=$state(1); | ||
</script> | ||
|
||
<button onclick={()=>test++}></button> | ||
|
||
<svelte:boundary> | ||
{@const double = test * 2} | ||
{#snippet failed()} | ||
<p>{double}</p> | ||
{/snippet} | ||
<FlakyComponent /> | ||
</svelte:boundary> |
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/validator/samples/const-tag-placement-svelte-boundary/errors.json
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 @@ | ||
[] |
11 changes: 11 additions & 0 deletions
11
packages/svelte/tests/validator/samples/const-tag-placement-svelte-boundary/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,11 @@ | ||
<script> | ||
let a = $state(""); | ||
</script> | ||
|
||
<svelte:boundary> | ||
{@const x = a} | ||
{#snippet failed()} | ||
{x} | ||
{/snippet} | ||
<FlakyComponent /> | ||
</svelte:boundary> |