mirror of https://github.com/sveltejs/svelte
when value is null in that selectedIndex set same as selected but in that that it should be -1.pull/6874/head
parent
08fc888515
commit
369468ab8a
@ -0,0 +1,17 @@
|
||||
// This test make sure if value is bind value is (void 0) then
|
||||
// it should set to same as the selected option value
|
||||
export default {
|
||||
async test({ assert, target }) {
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>selected: c</p>
|
||||
|
||||
<select>
|
||||
<option value='a'>a</option>
|
||||
<option value='b'>b</option>
|
||||
<option value='c' selected>c</option>
|
||||
</select>
|
||||
|
||||
<p>selected: c</p>
|
||||
`);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
export let selected;
|
||||
export let o3;
|
||||
</script>
|
||||
|
||||
<p>selected: {selected}</p>
|
||||
|
||||
<select bind:value={selected}>
|
||||
<option>a</option>
|
||||
<option>b</option>
|
||||
<option bind:this={o3} selected>c</option>
|
||||
</select>
|
||||
|
||||
<p>selected: {selected}</p>
|
||||
@ -0,0 +1,18 @@
|
||||
export default {
|
||||
html: `
|
||||
<p>selected: undefined</p>
|
||||
|
||||
<select>
|
||||
<option value='a'>a</option>
|
||||
<option value='b'>b</option>
|
||||
<option value='c' selected>c</option>
|
||||
</select>
|
||||
|
||||
<p>selected: undefined</p>
|
||||
`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const select = target.querySelector('select');
|
||||
assert.equal(select.value, 'c');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
export let selected;
|
||||
export let o3;
|
||||
</script>
|
||||
|
||||
<p>selected: {selected}</p>
|
||||
|
||||
<select {...{}}>
|
||||
<option>a</option>
|
||||
<option>b</option>
|
||||
<option bind:this={o3} selected>c</option>
|
||||
</select>
|
||||
|
||||
<p>selected: {selected}</p>
|
||||
Loading…
Reference in new issue