mirror of https://github.com/sveltejs/svelte
Merge pull request #1923 from sveltejs/gh-1919
make event handler names unique across componentspull/1928/head
commit
11e8270963
@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
foo: 'a',
|
||||||
|
items: ['x'],
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<div><input><p>a</p></div>
|
||||||
|
<div><input><p>x</p></div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
ssrHtml: `
|
||||||
|
<div><input value=a><p>a</p></div>
|
||||||
|
<div><input value=x><p>x</p></div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const inputs = [...target.querySelectorAll('input')];
|
||||||
|
const items = component.items;
|
||||||
|
const event = new window.Event('input');
|
||||||
|
|
||||||
|
assert.equal(inputs[0].value, 'a');
|
||||||
|
|
||||||
|
inputs[0].value = 'b';
|
||||||
|
inputs[1].value = 'y';
|
||||||
|
await inputs[0].dispatchEvent(event);
|
||||||
|
await inputs[1].dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(component.foo, 'b');
|
||||||
|
assert.equal(component.items[0], 'y');
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<div><input><p>b</p></div>
|
||||||
|
<div><input><p>y</p></div>
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<div><input bind:value={foo}><p>{foo}</p></div>
|
||||||
|
|
||||||
|
{#each items as bar}
|
||||||
|
<div><input bind:value={bar}><p>{bar}</p></div>
|
||||||
|
{/each}
|
Loading…
Reference in new issue