fix binding when updating through accessors (#6523)

pull/6560/head
Tan Li Hau 3 years ago committed by GitHub
parent c8cdc73464
commit f906180435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -148,7 +148,7 @@ export default function dom(
kind: 'set', kind: 'set',
key: { type: 'Identifier', name: prop.export_name }, key: { type: 'Identifier', name: prop.export_name },
value: x`function(${prop.name}) { value: x`function(${prop.name}) {
this.$set({ ${prop.export_name}: ${prop.name} }); this.$$set({ ${prop.export_name}: ${prop.name} });
@flush(); @flush();
}` }`
}); });

@ -0,0 +1,5 @@
<script>
export let value;
</script>
<input bind:value />

@ -0,0 +1,18 @@
export default {
async test({ assert, component, target, window }) {
const [input1, input2] = target.querySelectorAll('input');
assert.equal(input1.value, 'something');
assert.equal(input2.value, 'something');
input1.value = 'abc';
await input1.dispatchEvent(new window.Event('input'));
assert.equal(input1.value, 'abc');
assert.equal(input2.value, 'abc');
await target.querySelector('button').dispatchEvent(new window.MouseEvent('click'));
assert.equal(input1.value, 'Reset');
assert.equal(input2.value, 'Reset');
}
};

@ -0,0 +1,12 @@
<script>
import Nested from './Nested.svelte';
let value = 'something'
let c;
</script>
<Nested bind:this={c} bind:value />
<input bind:value />
<button on:click={() => {
c.value = 'Reset';
}}>Reset</button>
Loading…
Cancel
Save