Browse Source

fix: safely remove helpers in vDistanceTo and vLightHelper directives (#919)

Alvaro Saburido 3 months ago
parent
commit
f512b1a129
2 changed files with 6 additions and 2 deletions
  1. 3 1
      src/directives/vDistanceTo.ts
  2. 3 1
      src/directives/vLightHelper.ts

+ 3 - 1
src/directives/vDistanceTo.ts

@@ -33,6 +33,8 @@ export const vDistanceTo = {
   },
   unmounted: (el: TresObject) => {
     arrowHelper?.dispose()
-    el.parent.remove(arrowHelper)
+    if (el.parent) {
+      el.parent.remove(arrowHelper)
+    }
   },
 }

+ 3 - 1
src/directives/vLightHelper.ts

@@ -56,6 +56,8 @@ export const vLightHelper = {
     if (currentInstance && currentInstance.dispose) {
       currentInstance.dispose()
     }
-    el.parent.remove(currentInstance)
+    if (el.parent) {
+      el.parent.remove(currentInstance)
+    }
   },
 }