aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-09-08 08:45:22 -0400
committergorhill <rhill@raymondhill.net>2015-09-08 08:45:22 -0400
commit7177d8d0ffa58ce1a44f71c912eadad6915cfa51 (patch)
treea47b8a361e8078598d373d7d8affdd0809d9debc /src/js
parent06f7e3c71131265eaf9d2a3443ad628b84adc82a (diff)
downloaduBlock-7177d8d0ffa58ce1a44f71c912eadad6915cfa51.zip
uBlock-7177d8d0ffa58ce1a44f71c912eadad6915cfa51.tar.gz
uBlock-7177d8d0ffa58ce1a44f71c912eadad6915cfa51.tar.bz2
this addresses #693
Diffstat (limited to 'src/js')
-rw-r--r--src/js/cosmetic-filtering.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js
index f0eeed1..fd51c22 100644
--- a/src/js/cosmetic-filtering.js
+++ b/src/js/cosmetic-filtering.js
@@ -564,26 +564,28 @@ FilterContainer.prototype.reset = function() {
// https://github.com/chrisaljoudi/uBlock/issues/1004
// Detect and report invalid CSS selectors.
-FilterContainer.prototype.div = document.createElement('div');
-
-// Not all browsers support `Element.matches`:
-// http://caniuse.com/#feat=matchesselector
+FilterContainer.prototype.isValidSelector = (function() {
+ var div = document.createElement('div');
+
+ // Not all browsers support `Element.matches`:
+ // http://caniuse.com/#feat=matchesselector
+ if ( typeof div.matches !== 'function' ) {
+ return function() {
+ return true;
+ };
+ }
-if ( typeof FilterContainer.prototype.div.matches === 'function' ) {
- FilterContainer.prototype.isValidSelector = function(s) {
+ return function(s) {
try {
- this.div.matches(s);
+ // https://github.com/gorhill/uBlock/issues/693
+ div.matches(s + ',\n#foo');
} catch (e) {
console.error('uBlock> invalid cosmetic filter:', s);
return false;
}
return true;
};
-} else {
- FilterContainer.prototype.isValidSelector = function() {
- return true;
- };
-}
+})();
/******************************************************************************/