Skip to content

Commit e8f1a16

Browse files
committed
fix
1 parent 08f1441 commit e8f1a16

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

packages/svelte/src/internal/shared/validate.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import { is_void } from '../../compiler/phases/1-parse/utils/names.js';
2-
3-
const snippet_symbol = Symbol.for('svelte.snippet');
4-
5-
/**
6-
* @param {any} fn
7-
*/
8-
export function add_snippet_symbol(fn) {
9-
fn[snippet_symbol] = true;
10-
return fn;
11-
}
2+
import { is_snippet } from '../client/dom/blocks/snippet.js';
123

134
/**
145
* Validate that the function handed to `{@render ...}` is a snippet function, and not some other kind of function.
156
* @param {any} snippet_fn
167
*/
178
export function validate_snippet(snippet_fn) {
18-
if (snippet_fn && snippet_fn[snippet_symbol] !== true) {
9+
if (snippet_fn && !is_snippet(snippet_fn)) {
1910
throw new Error(
2011
'The argument to `{@render ...}` must be a snippet function, not a component or some other kind of function. ' +
2112
'If you want to dynamically render one snippet or another, use `$derived` and pass its result to `{@render ...}`.'
@@ -29,7 +20,7 @@ export function validate_snippet(snippet_fn) {
2920
* @param {any} component_fn
3021
*/
3122
export function validate_component(component_fn) {
32-
if (component_fn?.[snippet_symbol] === true) {
23+
if (is_snippet(component_fn)) {
3324
throw new Error('A snippet must be rendered with `{@render ...}`');
3425
}
3526
return component_fn;

0 commit comments

Comments
 (0)