Browse Source

监听全局点击事件没有意义了,因为现在超链接一出现就会自动调整 URL

zjcqoo 6 years ago
parent
commit
479658d014
1 changed files with 2 additions and 30 deletions
  1. 2 30
      browser/proxy/src/nav.js

+ 2 - 30
browser/proxy/src/nav.js

@@ -111,44 +111,16 @@ export function init(win, hook) {
     }
     }
   }
   }
 
 
-  function processForm(el) {
-    processElem(el, 'action')
-  }
-
-  function processLink(el) {
-    processElem(el, 'href')
-  }
-
-  win.addEventListener('click', e => {
-    let el = e.target
-    while (el) {
-      let tag = el.tagName
-      if (tag === 'A' || tag === 'AREA') {
-        processLink(el)
-        break
-      }
-      el = el.parentNode
-    }
-  }, true)
-
-  win.addEventListener('submit', e => {
-    let el = e.target
-    if (el.tagName === 'FORM') {
-      processForm(el)
-    }
-  }, true)
-
-
   function linkClickHook(oldFn) {
   function linkClickHook(oldFn) {
     return function() {
     return function() {
-      processLink(this)
+      processElem(el, 'href')
       return apply(oldFn, this, arguments)
       return apply(oldFn, this, arguments)
     }
     }
   }
   }
   hook.func(linkProto, 'click', linkClickHook)
   hook.func(linkProto, 'click', linkClickHook)
   hook.func(areaProto, 'click', linkClickHook)
   hook.func(areaProto, 'click', linkClickHook)
   hook.func(formProto, 'submit', oldFn => function() {
   hook.func(formProto, 'submit', oldFn => function() {
-    processForm(this)
+    processElem(el, 'action')
     return apply(oldFn, this, arguments)
     return apply(oldFn, this, arguments)
   })
   })