From cb1358cc417effeb2e747f811260936c11b8923d Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 19 Jul 2023 09:39:45 +0200 Subject: [PATCH] fix: don't add accessor twice (#8996) In dev mode, Svelte creates a setter to throw an error noting that you can't set that readonly prop, which resulted in the accessor getting applied twice to the custom element wrapper, causing an error fixes #8971 --- .changeset/ten-gifts-design.md | 5 +++++ packages/svelte/src/compiler/compile/render_dom/index.js | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/ten-gifts-design.md diff --git a/.changeset/ten-gifts-design.md b/.changeset/ten-gifts-design.md new file mode 100644 index 0000000000..a4e154fc9c --- /dev/null +++ b/.changeset/ten-gifts-design.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: don't add accessor twice diff --git a/packages/svelte/src/compiler/compile/render_dom/index.js b/packages/svelte/src/compiler/compile/render_dom/index.js index b2d02bb78c..0627e7e0cb 100644 --- a/packages/svelte/src/compiler/compile/render_dom/index.js +++ b/packages/svelte/src/compiler/compile/render_dom/index.js @@ -583,7 +583,11 @@ export default function dom(component, options) { }, {}); const slots_str = [...component.slots.keys()].map((key) => `"${key}"`).join(','); const accessors_str = accessors - .filter((accessor) => !writable_props.some((prop) => prop.export_name === accessor.key.name)) + .filter( + (accessor) => + accessor.kind === 'get' && + !writable_props.some((prop) => prop.export_name === accessor.key.name) + ) .map((accessor) => `"${accessor.key.name}"`) .join(','); const use_shadow_dom =