0

I'm very new to cross-browser web development. Not quiet understand this:

    (function(doc) {
     var matches; 
     matches = doc.matchesSelector || 
     doc.webkitMatchesSelector || 
     doc.mozMatchesSelector || 
     doc.oMatchesSelector || 
     doc.msMatchesSelector;
    })(document.documentElement);

   window.addEventListener('click', function(e) { 
       if ( matches.call(e.target, 'ul a') ) {
       alert('Event delegation and matchesSelector are BFFs'); 
       e.preventDefault();}
   },false);

So what does document.documentElement.matchesSelector return? What's the meaning of matches=doc.matchesSelector if every vendor prefixes are included after?

Janice Zhong
  • 836
  • 7
  • 16
  • @Phil then what does ms stand for? – Janice Zhong Feb 05 '18 at 01:40
  • Sorry, I got that wrong. `matchesSelector` would just be the un-prefixed version of all the others. It would be the preferable implementation to use if `matches` was not defined, followed by any defined vendor prefixed version. See https://developer.mozilla.org/en-US/docs/Web/API/Element/matches – Phil Feb 05 '18 at 01:41

0 Answers0