Blame view

天文台pc/tianwentai-ui/node_modules/dom-helpers/esm/matches.js 519 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  var matchesImpl;
  /**
   * Checks if a given element matches a selector.
   * 
   * @param node the element
   * @param selector the selector
   */
  
  export default function matches(node, selector) {
    if (!matchesImpl) {
      var body = document.body;
      var nativeMatch = body.matches || body.matchesSelector || body.webkitMatchesSelector || body.mozMatchesSelector || body.msMatchesSelector;
  
      matchesImpl = function matchesImpl(n, s) {
        return nativeMatch.call(n, s);
      };
    }
  
    return matchesImpl(node, selector);
  }