From 2efae794b893d4b852cfd0a1ad656f2d6ad83d03 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:25:49 +0200 Subject: [PATCH] fix: add more robust check for `Element` prototype (#13744) fixes #13691 fixes #13414 fixes #13726 --- .changeset/gorgeous-vans-sparkle.md | 5 +++++ .../svelte/src/internal/client/dom/elements/attributes.js | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/gorgeous-vans-sparkle.md diff --git a/.changeset/gorgeous-vans-sparkle.md b/.changeset/gorgeous-vans-sparkle.md new file mode 100644 index 0000000000..9df0360fe9 --- /dev/null +++ b/.changeset/gorgeous-vans-sparkle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add more robust check for `Element` prototype diff --git a/packages/svelte/src/internal/client/dom/elements/attributes.js b/packages/svelte/src/internal/client/dom/elements/attributes.js index 802d45153d..91aa1aee65 100644 --- a/packages/svelte/src/internal/client/dom/elements/attributes.js +++ b/packages/svelte/src/internal/client/dom/elements/attributes.js @@ -1,7 +1,6 @@ import { DEV } from 'esm-env'; import { hydrating } from '../hydration.js'; import { get_descriptors, get_prototype_of } from '../../../shared/utils.js'; -import { NAMESPACE_SVG } from '../../../../constants.js'; import { create_event, delegate } from './events.js'; import { add_form_reset_listener, autofocus } from './misc.js'; import * as w from '../../warnings.js'; @@ -318,9 +317,11 @@ function get_setters(element) { setters_cache.set(element.nodeName, (setters = [])); var descriptors; var proto = get_prototype_of(element); + var element_proto = Element.prototype; // Stop at Element, from there on there's only unnecessary setters we're not interested in - while (proto.constructor.name !== 'Element') { + // Do not use contructor.name here as that's unreliable in some browser environments + while (element_proto !== proto) { descriptors = get_descriptors(proto); for (var key in descriptors) {