'invalidate' flattens array of nodes

pull/8846/head
Nguyen Tran 3 years ago
parent d3297e2a25
commit 309ffcbcbe

@ -7,7 +7,7 @@ import { x } from 'code-red';
* @param {import('estree').Node} node * @param {import('estree').Node} node
* @param {Set<string>} names * @param {Set<string>} names
* @param {boolean} main_execution_context * @param {boolean} main_execution_context
* @returns {any} * @returns {import('estree').Node}
*/ */
export function invalidate(renderer, scope, node, names, main_execution_context = false) { export function invalidate(renderer, scope, node, names, main_execution_context = false) {
const { component } = renderer; const { component } = renderer;
@ -83,6 +83,8 @@ export function invalidate(renderer, scope, node, names, main_execution_context
if (head.subscribable && head.reassigned) { if (head.subscribable && head.reassigned) {
const subscribe = `$$subscribe_${head.name}`; const subscribe = `$$subscribe_${head.name}`;
invalidate = x`${subscribe}(${invalidate})`; invalidate = x`${subscribe}(${invalidate})`;
} else if (Array.isArray(invalidate)) {
invalidate = invalidate.reduce((lhs, rhs) => x`${lhs}, ${rhs}`);
} }
return invalidate; return invalidate;
} }

@ -0,0 +1,13 @@
<script>
import { readable } from 'svelte/store'
let store, nonStore;
const getExports = () => ({ nonStore: true, store: readable(true) });
({ nonStore, store } = getExports());
</script>
{#if $store}
{nonStore}
{/if}
Loading…
Cancel
Save