Skip to content

Commit 6ea0425

Browse files
committed
handle select reset case
1 parent c613a57 commit 6ea0425

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ export function set_checked(element, checked) {
9393
*/
9494
export function set_selected(element, selected) {
9595
if (selected) {
96-
element.setAttribute('selected', '');
96+
// The selected option could've changed via user selection, and
97+
// setting the value without this check would set it back.
98+
if (!element.hasAttribute('selected')) {
99+
element.setAttribute('selected', '');
100+
}
97101
} else {
98102
element.removeAttribute('selected');
99103
}

0 commit comments

Comments
 (0)