fix binding shadow the array in each block (#1565)

pull/3723/head
Tan Li Hau 5 years ago committed by Conduitry
parent 36ca311500
commit 982a1937db

@ -495,7 +495,10 @@ export default class ElementWrapper extends Wrapper {
this.renderer.component.partly_hoisted.push(b`
function ${handler}(${arg}) {
${group.bindings.map(b => b.handler.mutation)}
${Array.from(dependencies).filter(dep => dep[0] !== '$').map(dep => b`${this.renderer.component.invalidate(dep)};`)}
${Array.from(dependencies)
.filter(dep => dep[0] !== '$')
.filter(dep => !contextual_dependencies.has(dep))
.map(dep => b`${this.renderer.component.invalidate(dep)};`)}
}
`);

@ -0,0 +1,13 @@
export default {
async test({ assert, component, target }) {
assert.equal(target.querySelectorAll('input').length, 3);
const input = target.querySelector('input');
input.value = 'svelte';
await input.dispatchEvent(new window.Event('input'));
assert.equal(target.querySelectorAll('input').length, 3);
assert.deepEqual(component.data, { a: 'svelte', b: 'B', c: 'C' });
assert.deepEqual(component.x, ['a', 'b', 'c']);
},
};

@ -0,0 +1,15 @@
<script>
export let x = ['a', 'b', 'c'];
export let data = {
'a': 'A',
'b': 'B',
'c': 'C',
};
export function getData() {
return data;
}
</script>
{#each x as x}
<input type=text bind:value={data[x]}>
{/each}
Loading…
Cancel
Save