From 3aa2ec081350f5f62725f9f918cee3b1efe9f180 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 19 Sep 2024 20:17:37 -0400 Subject: [PATCH] fix: only set attribute as property if element has setter (#13341) --- .changeset/beige-clocks-notice.md | 5 +++++ .../svelte/src/internal/client/dom/elements/attributes.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/beige-clocks-notice.md diff --git a/.changeset/beige-clocks-notice.md b/.changeset/beige-clocks-notice.md new file mode 100644 index 0000000000..be133078d4 --- /dev/null +++ b/.changeset/beige-clocks-notice.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: only set attribute as property if element has setter diff --git a/packages/svelte/src/internal/client/dom/elements/attributes.js b/packages/svelte/src/internal/client/dom/elements/attributes.js index 10e5c43b31..9f92c59d15 100644 --- a/packages/svelte/src/internal/client/dom/elements/attributes.js +++ b/packages/svelte/src/internal/client/dom/elements/attributes.js @@ -113,7 +113,7 @@ export function set_attribute(element, attribute, value, skip_warning) { if (value == null) { element.removeAttribute(attribute); - } else if (attribute in element && typeof value !== 'string') { + } else if (typeof value !== 'string' && get_setters(element).includes(attribute)) { // @ts-ignore element[attribute] = value; } else {