mirror of https://github.com/sveltejs/svelte
fix indirect bindings on elements with spreads (#4398)
parent
c3232826d4
commit
b6d80f485a
@ -0,0 +1,44 @@
|
||||
export default {
|
||||
skip_if_ssr: true,
|
||||
async test({ assert, component, target, window }) {
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
const [radio1, radio2, radio3] = target.querySelectorAll('input[type=radio]');
|
||||
|
||||
assert.ok(!radio1.checked);
|
||||
assert.ok(radio2.checked);
|
||||
assert.ok(!radio3.checked);
|
||||
|
||||
component.radio = 'radio1';
|
||||
|
||||
assert.ok(radio1.checked);
|
||||
assert.ok(!radio2.checked);
|
||||
assert.ok(!radio3.checked);
|
||||
|
||||
await radio3.dispatchEvent(event);
|
||||
|
||||
assert.equal(component.radio, 'radio3');
|
||||
assert.ok(!radio1.checked);
|
||||
assert.ok(!radio2.checked);
|
||||
assert.ok(radio3.checked);
|
||||
|
||||
const [check1, check2, check3] = target.querySelectorAll('input[type=checkbox]');
|
||||
|
||||
assert.ok(!check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(!check3.checked);
|
||||
|
||||
component.check = ['check1', 'check2'];
|
||||
|
||||
assert.ok(check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(!check3.checked);
|
||||
|
||||
await check3.dispatchEvent(event);
|
||||
|
||||
assert.deepEqual(component.check, ['check1', 'check2', 'check3']);
|
||||
assert.ok(check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(check3.checked);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let radio = 'radio2';
|
||||
export let check = ['check2'];
|
||||
</script>
|
||||
|
||||
<input type='radio' bind:group={radio} value='radio1' {...{}}>
|
||||
<input type='radio' bind:group={radio} value='radio2' {...{}}>
|
||||
<input type='radio' bind:group={radio} value='radio3' {...{}}>
|
||||
|
||||
<input type='checkbox' bind:group={check} value='check1' {...{}}>
|
||||
<input type='checkbox' bind:group={check} value='check2' {...{}}>
|
||||
<input type='checkbox' bind:group={check} value='check3' {...{}}>
|
Loading…
Reference in new issue