mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
fix binding shadow the array in each block (#1565)
This commit is contained in:
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)};`)}
|
||||
}
|
||||
`);
|
||||
|
||||
|
13
test/runtime/samples/each-block-scope-shadow-self/_config.js
Normal file
13
test/runtime/samples/each-block-scope-shadow-self/_config.js
Normal file
@ -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…
Reference in New Issue
Block a user