Skip to content

Commit aaa8812

Browse files
committed
fix: treat undefined and null the same for the initial input value
Fixes #14558
1 parent 4b802db commit aaa8812

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/cool-clocks-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: treat `undefined` and `null` the same for the initial input value

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export function set_value(element, value) {
6161
// @ts-expect-error
6262
var attributes = (element.__attributes ??= {});
6363
if (
64-
attributes.value === (attributes.value = value) ||
64+
attributes.value ===
65+
(attributes.value =
66+
// treat null and undefined the same for the initial value
67+
value ?? undefined) ||
6568
// @ts-expect-error
6669
// `progress` elements always need their value set when its `0`
6770
(element.value === value && (value !== 0 || element.nodeName !== 'PROGRESS'))

0 commit comments

Comments
 (0)