diff --git a/src/compiler/compile/render_dom/wrappers/shared/bind_this.ts b/src/compiler/compile/render_dom/wrappers/shared/bind_this.ts index 078eb1839d..8be44aa023 100644 --- a/src/compiler/compile/render_dom/wrappers/shared/bind_this.ts +++ b/src/compiler/compile/render_dom/wrappers/shared/bind_this.ts @@ -29,7 +29,6 @@ export default function bind_this(component: Component, block: Block, binding: B })); component.partly_hoisted.push(b` function ${fn}($$value, ${params}) { - if (${lhs} === $$value) return; @binding_callbacks[$$value ? 'unshift' : 'push'](() => { ${body} }); diff --git a/test/runtime/samples/binding-this-each-block-property-2/_config.js b/test/runtime/samples/binding-this-each-block-property-2/_config.js new file mode 100644 index 0000000000..eebd754fca --- /dev/null +++ b/test/runtime/samples/binding-this-each-block-property-2/_config.js @@ -0,0 +1,53 @@ +let calls = []; +function callback(refs) { + calls.push(refs.map(({ ref }) => ({ ref }))); +} +export default { + html: ``, + props: { + callback, + }, + after_test() { + calls = []; + }, + async test({ assert, component, target }) { + assert.equal(calls.length, 1); + assert.equal(calls[0].length, 0); + + await component.addItem(); + + let divs = target.querySelectorAll("div"); + + assert.equal(calls.length, 3); + assert.equal(calls[1].length, 1); + assert.equal(calls[1][0].ref, null); + assert.equal(calls[2].length, 1); + assert.equal(calls[2][0].ref, divs[0]); + + await component.addItem(); + + divs = target.querySelectorAll("div"); + + assert.equal(calls.length, 5); + assert.equal(calls[3].length, 2); + assert.equal(calls[3][0].ref, divs[0]); + assert.equal(calls[3][1].ref, null); + assert.equal(calls[4].length, 2); + assert.equal(calls[4][0].ref, divs[0]); + assert.equal(calls[4][1].ref, divs[1]); + + await component.addItem(); + + divs = target.querySelectorAll("div"); + + assert.equal(calls.length, 7); + assert.equal(calls[5].length, 3); + assert.equal(calls[5][0].ref, divs[0]); + assert.equal(calls[5][1].ref, divs[1]); + assert.equal(calls[5][2].ref, null); + assert.equal(calls[6].length, 3); + assert.equal(calls[6][0].ref, divs[0]); + assert.equal(calls[6][1].ref, divs[1]); + assert.equal(calls[6][2].ref, divs[2]); + }, +}; diff --git a/test/runtime/samples/binding-this-each-block-property-2/main.svelte b/test/runtime/samples/binding-this-each-block-property-2/main.svelte new file mode 100644 index 0000000000..a7dd4f971e --- /dev/null +++ b/test/runtime/samples/binding-this-each-block-property-2/main.svelte @@ -0,0 +1,17 @@ + + +{#each refs as xxx} +
+{/each} \ No newline at end of file