|
|
|
@ -2,26 +2,25 @@ import { add_snippet_symbol } from '../../../shared/validate.js';
|
|
|
|
|
import { EFFECT_TRANSPARENT } from '../../constants.js';
|
|
|
|
|
import { branch, block, destroy_effect } from '../../reactivity/effects.js';
|
|
|
|
|
import {
|
|
|
|
|
current_component_context,
|
|
|
|
|
dev_current_component_function,
|
|
|
|
|
set_dev_current_component_function
|
|
|
|
|
} from '../../runtime.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @template {(node: import('#client').TemplateNode, ...args: any[]) => import('#client').Dom} SnippetFn
|
|
|
|
|
* @param {import('#client').TemplateNode} anchor
|
|
|
|
|
* @param {() => SnippetFn | null | undefined} get_snippet
|
|
|
|
|
* @param {import('#client').TemplateNode} node
|
|
|
|
|
* @param {(() => any)[]} args
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
export function snippet(get_snippet, node, ...args) {
|
|
|
|
|
export function snippet(anchor, get_snippet, ...args) {
|
|
|
|
|
/** @type {SnippetFn | null | undefined} */
|
|
|
|
|
var snippet;
|
|
|
|
|
|
|
|
|
|
/** @type {import('#client').Effect | null} */
|
|
|
|
|
var snippet_effect;
|
|
|
|
|
|
|
|
|
|
block(null, EFFECT_TRANSPARENT, () => {
|
|
|
|
|
block(anchor, EFFECT_TRANSPARENT, () => {
|
|
|
|
|
if (snippet === (snippet = get_snippet())) return;
|
|
|
|
|
|
|
|
|
|
if (snippet_effect) {
|
|
|
|
@ -30,7 +29,7 @@ export function snippet(get_snippet, node, ...args) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (snippet) {
|
|
|
|
|
snippet_effect = branch(() => /** @type {SnippetFn} */ (snippet)(node, ...args));
|
|
|
|
|
snippet_effect = branch(() => /** @type {SnippetFn} */ (snippet)(anchor, ...args));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|