Browse Source

fix: add event spare path

zhangyuhan 3 năm trước cách đây
mục cha
commit
2bb2b2e463
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  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;
 }