Blame view

天文台pc/tianwentai-ui/node_modules/dom-helpers/cjs/matches.js 611 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  "use strict";
  
  exports.__esModule = true;
  exports.default = matches;
  var matchesImpl;
  /**
   * Checks if a given element matches a selector.
   * 
   * @param node the element
   * @param selector the selector
   */
  
  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);
  }
  
  module.exports = exports["default"];