Skip to content

Commit 4a6ea8b

Browse files
committed
fix validation (we were mutating the wrong array)
1 parent b90635b commit 4a6ea8b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

packages/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import * as b from '#compiler/builders';
99
* @param {ComponentContext} context
1010
*/
1111
export function SnippetBlock(node, context) {
12-
const body = /** @type {BlockStatement} */ (context.visit(node.body));
13-
14-
if (dev) {
15-
body.body.unshift(b.stmt(b.call('$.validate_snippet_args', b.id('$$payload'))));
16-
}
17-
1812
let fn = b.function_declaration(
1913
node.expression,
2014
[b.id('$$payload'), ...node.parameters],
@@ -27,6 +21,7 @@ export function SnippetBlock(node, context) {
2721
const push_to = node.metadata.can_hoist ? context.state.hoisted : context.state.init;
2822

2923
if (dev) {
24+
fn.body.body.unshift(b.stmt(b.call('$.validate_snippet_args', b.id('$$payload'))));
3025
push_to.push(b.stmt(b.call('$.prevent_snippet_stringification', fn.id)));
3126
}
3227

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
compileOptions: {
5+
dev: true
6+
},
7+
8+
error: 'invalid_snippet_arguments'
9+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
test();
3+
</script>
4+
5+
{#snippet test()}
6+
<p>hello</p>
7+
{/snippet}

0 commit comments

Comments
 (0)