File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed
packages/svelte/src/internal/shared Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change 1
1
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' ;
12
3
13
4
/**
14
5
* Validate that the function handed to `{@render ...}` is a snippet function, and not some other kind of function.
15
6
* @param {any } snippet_fn
16
7
*/
17
8
export function validate_snippet ( snippet_fn ) {
18
- if ( snippet_fn && snippet_fn [ snippet_symbol ] !== true ) {
9
+ if ( snippet_fn && ! is_snippet ( snippet_fn ) ) {
19
10
throw new Error (
20
11
'The argument to `{@render ...}` must be a snippet function, not a component or some other kind of function. ' +
21
12
'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) {
29
20
* @param {any } component_fn
30
21
*/
31
22
export function validate_component ( component_fn ) {
32
- if ( component_fn ?. [ snippet_symbol ] === true ) {
23
+ if ( is_snippet ( component_fn ) ) {
33
24
throw new Error ( 'A snippet must be rendered with `{@render ...}`' ) ;
34
25
}
35
26
return component_fn ;
You can’t perform that action at this time.
0 commit comments