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

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/12083/head
Dominic Gannaway 2 years ago committed by GitHub
parent 599619ebf7
commit 648805639f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,14 +32,18 @@ export function remove_input_attr_defaults(dom) {
if (already_removed) return;
already_removed = true;
var value_attribute = dom.getAttribute('value');
var value = dom.value;
set_attribute(dom, 'value', null);
set_attribute(dom, 'checked', null);
// We want to set the value back to the latest actual input value, rather than the attribute as
// this might have been changed during hydration.
if (value_attribute) dom.value = value;
// Remove the attributes but preserve the values
if (dom.hasAttribute('value')) {
var value = dom.value;
set_attribute(dom, 'value', null);
dom.value = value;
}
if (dom.hasAttribute('checked')) {
var checked = dom.checked;
set_attribute(dom, 'checked', null);
dom.checked = checked;
}
};
// @ts-expect-error

Loading…
Cancel
Save