mirror of https://github.com/sveltejs/svelte
commit
4cc4611f1a
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: preserve select selection when spread attributes omit value
|
||||
@ -0,0 +1,25 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client', 'hydrate'],
|
||||
|
||||
async test({ assert, component, target }) {
|
||||
const select = target.querySelector('select');
|
||||
ok(select);
|
||||
|
||||
assert.equal(select.selectedIndex, 0);
|
||||
|
||||
component.toggle();
|
||||
flushSync();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.equal(select.selectedIndex, 0);
|
||||
|
||||
component.toggle();
|
||||
flushSync();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.equal(select.selectedIndex, 0);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let show_extra = false;
|
||||
const attributes = { 'aria-label': 'choice' };
|
||||
|
||||
export function toggle() {
|
||||
show_extra = !show_extra;
|
||||
}
|
||||
</script>
|
||||
|
||||
<select {...attributes}>
|
||||
<option value="">Choose an option</option>
|
||||
<option value="first">First</option>
|
||||
{#if show_extra}
|
||||
<option value="extra">Extra</option>
|
||||
{/if}
|
||||
</select>
|
||||
Loading…
Reference in new issue