react to array mutation in each block with static content

pull/4853/head
Billy Levin 5 years ago
parent 0cd40b79c8
commit e79ee34c25

@ -96,6 +96,19 @@ export default class EachBlockWrapper extends Wrapper {
bindings: new Map(block.bindings) bindings: new Map(block.bindings)
}); });
const reassigned_deps: Set<string> = new Set();
block.dependencies.forEach(dep => {
const info = renderer.context_lookup.get(dep);
if (info && info.variable.reassigned) {
reassigned_deps.add(dep);
}
});
if (reassigned_deps.size) {
this.block.add_dependencies(reassigned_deps);
}
// TODO this seems messy // TODO this seems messy
this.block.has_animation = this.node.has_animation; this.block.has_animation = this.node.has_animation;

@ -0,0 +1,7 @@
export default {
html: ``,
test({ assert, target }) {
assert.htmlEqual(target.innerHTML, `staticstatic`);
}
};

@ -0,0 +1,13 @@
<script>
import { onMount } from 'svelte';
let arr = [1];
onMount(() => {
arr.push(arr.length + 1);
arr = arr;
});
</script>
{#each arr as num}
static
{/each}
Loading…
Cancel
Save