소스 검색

fix: add event spare path

zhangyuhan 3 년 전
부모
커밋
2bb2b2e463
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      src/utils/util.js

+ 6 - 1
src/utils/util.js

@@ -241,9 +241,14 @@ export function objToArray(obj) {
 }
 
 export function calcShadowRootEvent(e) {
+  if (!e) return;
   let event = e.target;
   if (e.target.shadowRoot && e.target.shadowRoot.toString() === '[object ShadowRoot]') {
-    event = e.composedPath()[0];
+    let eventPath = e.composedPath();
+    if (!eventPath.length) {
+      eventPath = e.path;
+    }
+    event = eventPath[0];
   }
   return event;
 }