Fix null option being selected when it doesn't match the bound value

pull/9550/head
Theodore Brown 3 years ago
parent bd1bff8ec0
commit 5e9a205fa7

@ -458,7 +458,7 @@ export function select_option(select, value, mounting) {
}
}
if (!mounting || value !== undefined) {
select.value = '';
select.selectedIndex = -1; // no option should be selected
}
}

@ -24,5 +24,11 @@ export default test({
component.foo = items[0];
assert.equal(options[0].selected, false);
assert.equal(options[1].selected, true);
component.foo = { id: 'c' }; // doesn't match an option
assert.equal(select.value, '');
assert.equal(select.selectedIndex, -1);
assert.equal(options[0].selected, false);
assert.equal(options[1].selected, false);
}
});

Loading…
Cancel
Save