소스 검색

Clickoutside: removing element from the queue

qingwei.li 8 년 전
부모
커밋
56f4167c3c
1개의 변경된 파일8개의 추가작업 그리고 9개의 파일을 삭제
  1. 8 9
      src/utils/clickoutside.js

+ 8 - 9
src/utils/clickoutside.js

@@ -45,15 +45,14 @@ export default {
   },
 
   unbind(el) {
-    nodeList.splice(el[ctx].id, 1);
-    delete el[ctx];
-  },
+    let len = nodeList.length;
 
-  install(Vue) {
-    /* istanbul ignore next */
-    Vue.directive('clickoutside', {
-      bind: this.bind,
-      unbind: this.unbind
-    });
+    for (let i = 0; i < len; i++) {
+      if (nodeList[i][ctx].id === el[ctx].id) {
+        nodeList.splice(i, 1);
+        delete el[ctx];
+        break;
+      }
+    }
   }
 };