소스 검색

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

Alvaro Saburido 5 달 전
부모
커밋
f512b1a129
2개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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)
+    }
   },
 }