Created
          July 6, 2012 21:51 
        
      - 
      
- 
        Save jonathantneal/3062955 to your computer and use it in GitHub Desktop. 
    matchesSelector Polyfill // returns whether an element matches a selector
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | this.Element && function(ElementPrototype) { | |
| ElementPrototype.matchesSelector = ElementPrototype.matchesSelector || | |
| ElementPrototype.mozMatchesSelector || | |
| ElementPrototype.msMatchesSelector || | |
| ElementPrototype.oMatchesSelector || | |
| ElementPrototype.webkitMatchesSelector || | |
| function (selector) { | |
| var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1; | |
| while (nodes[++i] && nodes[i] != node); | |
| return !!nodes[i]; | |
| } | |
| }(Element.prototype); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | this.Element&&function(e){e.matchesSelector=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector||function(e){var t=this,n=(t.parentNode||t.document).querySelectorAll(e),r=-1;while(n[++r]&&n[r]!=t);return!!n[r]}}(Element.prototype) | 
can someone tell where to write this code like in polyfill.ts under all imports or anywhere else?
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
For those who need this code and don't know its license, there is a free-to-use polyfill with the same effect on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches