Adam Shaw 8 年之前
父节点
当前提交
9689ecf310
共有 1 个文件被更改,包括 1 次插入17 次删除
  1. 1 17
      src/util/dom.ts

+ 1 - 17
src/util/dom.ts

@@ -100,7 +100,6 @@ export function listenViaDelegation(container: HTMLElement, eventType, childClas
 }
 }
 
 
 // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
 // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
-// TODO: research leaner fallback
 const matchesMethod =
 const matchesMethod =
   Element.prototype.matches ||
   Element.prototype.matches ||
   (Element.prototype as any).matchesSelector ||
   (Element.prototype as any).matchesSelector ||
@@ -109,28 +108,13 @@ const matchesMethod =
   (Element.prototype as any).oMatchesSelector ||
   (Element.prototype as any).oMatchesSelector ||
   (Element.prototype as any).webkitMatchesSelector
   (Element.prototype as any).webkitMatchesSelector
 
 
-;[
-  'matches',
-  'matchesSelector',
-  'mozMatchesSelector',
-  'msMatchesSelector',
-  'oMatchesSelector',
-  'webkitMatchesSelector'
-].forEach(function(name) {
-  if (Element.prototype[name]) {
-    console.log(name + ' exists')
-  } else {
-    console.log(name + ' does NOT exist')
-  }
-})
-
 const closestMethod = Element.prototype.closest || function(selector) {
 const closestMethod = Element.prototype.closest || function(selector) {
   let el = this
   let el = this
   if (!document.documentElement.contains(el)) {
   if (!document.documentElement.contains(el)) {
     return null
     return null
   }
   }
   do {
   do {
-    if (matchesMethod.call(el, selector)) {
+    if (elementMatches(el, selector)) {
       return el
       return el
     }
     }
     el = el.parentElement || el.parentNode
     el = el.parentElement || el.parentNode