mirror of https://github.com/sveltejs/svelte
Merge pull request #304 from sveltejs/gh-301
Initialise <select> elements with two-way bindingpull/305/head
commit
0d29d46dfa
@ -0,0 +1,29 @@
|
|||||||
|
export default {
|
||||||
|
skip: true, // selectedOptions doesn't work in JSDOM???
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<p>selected: b</p>
|
||||||
|
|
||||||
|
<select>
|
||||||
|
<option>a</option>
|
||||||
|
<option>b</option>
|
||||||
|
<option>c</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<p>selected: b</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
selected: 'b'
|
||||||
|
},
|
||||||
|
|
||||||
|
test ( assert, component, target ) {
|
||||||
|
const select = target.querySelector( 'select' );
|
||||||
|
const options = [ ...target.querySelectorAll( 'option' ) ];
|
||||||
|
|
||||||
|
assert.equal( select.value, 'b' );
|
||||||
|
assert.ok( options[1].selected );
|
||||||
|
|
||||||
|
component.teardown();
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,9 @@
|
|||||||
|
<p>selected: {{selected}}</p>
|
||||||
|
|
||||||
|
<select bind:value='selected'>
|
||||||
|
<option value="a">a</option>
|
||||||
|
<option value="b">b</option>
|
||||||
|
<option value="c">c</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<p>selected: {{selected}}</p>
|
Loading…
Reference in new issue