From d098edf2e32e58760d54e719e5bd5b6df38e4afa Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 16 Mar 2015 15:07:24 -0400 Subject: [PATCH] be ready for when Element.matches is not supported --- src/js/cosmetic-filtering.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 3781b6d2d..4c4195033 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -239,7 +239,15 @@ var FilterParser = function() { this.invalid = false; this.cosmetic = true; this.reParser = /^\s*([^#]*)(##|#@#)(.+)\s*$/; + + // Not all browsers support `Element.matches`: + // http://caniuse.com/#feat=matchesselector this.div = document.createElement('div'); + if ( typeof this.div.matches !== 'function' ) { + this.div = { + matches: function() { return true; } + }; + } }; /******************************************************************************/