From 4f1063723e9ca0d10bc57592086ddd90e98911be Mon Sep 17 00:00:00 2001 From: mimbrown Date: Thu, 15 Jun 2023 01:03:17 +0530 Subject: [PATCH] fix: Don't break in `attributeChangedCallback` if `$$component` does not exist yet (#8701) Since the custom element class waits one tick before instantiating the `$$component` field, it's possibly undefined when `attributeChangedCallback` is called. --- packages/svelte/src/runtime/internal/Component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/svelte/src/runtime/internal/Component.js b/packages/svelte/src/runtime/internal/Component.js index 4512b3ab35f8..878251e08a38 100644 --- a/packages/svelte/src/runtime/internal/Component.js +++ b/packages/svelte/src/runtime/internal/Component.js @@ -287,7 +287,7 @@ if (typeof HTMLElement === 'function') { this.$$props_definition, 'toProp' ); - this.$$component.$set({ [attr]: this.$$data[attr] }); + this.$$component?.$set({ [attr]: this.$$data[attr] }); } disconnectedCallback() {