From be0ef10d4fced3b29806840113e489f1af22fb93 Mon Sep 17 00:00:00 2001 From: Pierre CM <114198641+pierre-cm@users.noreply.github.com> Date: Mon, 20 Feb 2023 01:32:18 +0100 Subject: [PATCH] [fix] undefined parent_component in Component.ts This change fixes an issue in Component.ts where an error occurs when the parent_component parameter is undefined, causing the following error: "Cannot read properties of undefined (reading '$$')". The proposed solution is to add a null check to the parent_component parameter before accessing the $$ property. This change ensures that the code works even when parent_component is not defined, as is the case when importing a module dynamically. --- src/runtime/internal/Component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 5aec24c651f7..6be97b4906fc 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -97,7 +97,7 @@ export function init(component, options, instance, create_fragment, not_equal, p callbacks: blank_object(), dirty, skip_bound: false, - root: options.target || parent_component.$$.root + root: options.target || parent_component?.$$.root }; append_styles && append_styles($$.root);