-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disallow mounting a snippet (#11347)
fixes #11264
- Loading branch information
1 parent
d3949a6
commit 7d19e5b
Showing
4 changed files
with
40 additions
and
0 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: disallow mounting a snippet |
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
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/mount-snippet-error/_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,12 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
compileOptions: { | ||
dev: true | ||
}, | ||
async test({ assert, target }) { | ||
const div = target.querySelector('div'); | ||
assert.htmlEqual(div?.innerHTML || '', ''); | ||
}, | ||
runtime_error: 'snippet_used_as_component\nA snippet must be rendered with `{@render ...}`' | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/runtime-runes/samples/mount-snippet-error/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 { onMount, mount } from 'svelte'; | ||
let el; | ||
onMount(() => { | ||
mount(foo, { target: el }); | ||
}); | ||
</script> | ||
|
||
<div bind:this={el}></div> | ||
{#snippet foo()} | ||
shouldnt be rendered | ||
{/snippet} |