Skip to content

Commit 8e28099

Browse files
committed
fix: ensure undefined attributes are removed during hydration
Attributes that are `undefined` on the client should be removed during hydration, even if their value hasn't changed compared to `prev_value`.
1 parent 931f211 commit 8e28099

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
@@ -345,7 +345,11 @@ export function set_attributes(element, prev, next, css_hash, skip_warning = fal
345345
}
346346

347347
var prev_value = current[key];
348-
if (value === prev_value) continue;
348+
349+
// Skip if value is unchanged, unless it's `undefined` and the element still has the attribute
350+
if (value === prev_value && !(value === undefined && element.hasAttribute(key))) {
351+
continue;
352+
}
349353

350354
current[key] = value;
351355

0 commit comments

Comments
 (0)