elliott/add-variadic-snippets
S. Elliott Johnson 1 year ago
parent e8153dcbbc
commit 9b0199946b

@ -592,10 +592,8 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
const child_scope = state.scope.child(); const child_scope = state.scope.child();
scopes.set(node, child_scope); scopes.set(node, child_scope);
if (node.context) { for (const id of extract_identifiers(node.context)) {
for (const id of extract_identifiers(node.context)) { child_scope.declare(id, 'each', 'let');
child_scope.declare(id, 'each', 'let');
}
} }
context.next({ scope: child_scope }); context.next({ scope: child_scope });

@ -2843,16 +2843,16 @@ export function sanitize_slots(props) {
/** /**
* @param {() => Function} get_snippet * @param {() => Function} get_snippet
* @param {Node} node * @param {Node} node
* @param {() => any} args * @param {(() => any)[]} args
* @returns {void} * @returns {void}
*/ */
export function snippet_effect(get_snippet, node, args) { export function snippet_effect(get_snippet, node, ...args) {
const block = create_snippet_block(); const block = create_snippet_block();
render_effect(() => { render_effect(() => {
// Only rerender when the snippet function itself changes, // Only rerender when the snippet function itself changes,
// not when an eagerly-read prop inside the snippet function changes // not when an eagerly-read prop inside the snippet function changes
const snippet = get_snippet(); const snippet = get_snippet();
untrack(() => snippet(node, args)); untrack(() => snippet(node, ...args));
return () => { return () => {
if (block.d !== null) { if (block.d !== null) {
remove(block.d); remove(block.d);

Loading…
Cancel
Save