mirror of https://github.com/sveltejs/svelte
Merge pull request #309 from sveltejs/gh-10
use input events for two-way binding with textareas and non-checkbox/radio inputspull/314/head
commit
8d15078b97
@ -0,0 +1,32 @@
|
||||
export default {
|
||||
data: {
|
||||
value: 'some text'
|
||||
},
|
||||
|
||||
html: `
|
||||
<textarea></textarea>
|
||||
<p>some text</p>
|
||||
`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const textarea = target.querySelector( 'textarea' );
|
||||
assert.equal( textarea.value, 'some text' );
|
||||
|
||||
const event = new window.Event( 'input' );
|
||||
|
||||
textarea.value = 'hello';
|
||||
textarea.dispatchEvent( event );
|
||||
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<textarea></textarea>
|
||||
<p>hello</p>
|
||||
` );
|
||||
|
||||
component.set({ value: 'goodbye' });
|
||||
assert.equal( textarea.value, 'goodbye' );
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<textarea></textarea>
|
||||
<p>goodbye</p>
|
||||
` );
|
||||
}
|
||||
};
|
@ -0,0 +1,2 @@
|
||||
<textarea bind:value></textarea>
|
||||
<p>{{value}}</p>
|
Loading…
Reference in new issue