mirror of https://github.com/gorhill/uBlock.git
fix #3382
This commit is contained in:
parent
35eaf267e6
commit
ec29c9a127
|
@ -374,19 +374,6 @@ vAPI.DOMFilterer = (function() {
|
|||
|
||||
// 'P' stands for 'Procedural'
|
||||
|
||||
var PSelectorHasTask = function(task) {
|
||||
this.selector = task[1];
|
||||
};
|
||||
PSelectorHasTask.prototype.exec = function(input) {
|
||||
var output = [];
|
||||
for ( var node of input ) {
|
||||
if ( node.querySelector(this.selector) !== null ) {
|
||||
output.push(node);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
var PSelectorHasTextTask = function(task) {
|
||||
var arg0 = task[1], arg1;
|
||||
if ( Array.isArray(task[1]) ) {
|
||||
|
@ -486,7 +473,7 @@ vAPI.DOMFilterer = (function() {
|
|||
var PSelector = function(o) {
|
||||
if ( PSelector.prototype.operatorToTaskMap === undefined ) {
|
||||
PSelector.prototype.operatorToTaskMap = new Map([
|
||||
[ ':has', PSelectorHasTask ],
|
||||
[ ':has', PSelectorIfTask ],
|
||||
[ ':has-text', PSelectorHasTextTask ],
|
||||
[ ':if', PSelectorIfTask ],
|
||||
[ ':if-not', PSelectorIfNotTask ],
|
||||
|
|
|
@ -34,19 +34,6 @@
|
|||
discardedCount = 0,
|
||||
docRegister, loggerRegister;
|
||||
|
||||
var PSelectorHasTask = function(task) {
|
||||
this.selector = task[1];
|
||||
};
|
||||
PSelectorHasTask.prototype.exec = function(input) {
|
||||
var output = [];
|
||||
for ( var node of input ) {
|
||||
if ( node.querySelector(this.selector) !== null ) {
|
||||
output.push(node);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
var PSelectorHasTextTask = function(task) {
|
||||
var arg0 = task[1], arg1;
|
||||
if ( Array.isArray(task[1]) ) {
|
||||
|
@ -117,7 +104,7 @@
|
|||
var PSelector = function(o) {
|
||||
if ( PSelector.prototype.operatorToTaskMap === undefined ) {
|
||||
PSelector.prototype.operatorToTaskMap = new Map([
|
||||
[ ':has', PSelectorHasTask ],
|
||||
[ ':has', PSelectorIfTask ],
|
||||
[ ':has-text', PSelectorHasTextTask ],
|
||||
[ ':if', PSelectorIfTask ],
|
||||
[ ':if-not', PSelectorIfNotTask ],
|
||||
|
|
|
@ -589,7 +589,12 @@ var elementsFromSpecialSelector = function(selector) {
|
|||
var out = [], i;
|
||||
var matches = /^(.+?):has\((.+?)\)$/.exec(selector);
|
||||
if ( matches !== null ) {
|
||||
var nodes = document.querySelectorAll(matches[1]);
|
||||
var nodes;
|
||||
try {
|
||||
nodes = document.querySelectorAll(matches[1]);
|
||||
} catch(ex) {
|
||||
nodes = [];
|
||||
}
|
||||
i = nodes.length;
|
||||
while ( i-- ) {
|
||||
var node = nodes[i];
|
||||
|
|
|
@ -236,7 +236,6 @@
|
|||
for ( var i = 0, n = tasks.length, task; i < n; i++ ) {
|
||||
task = tasks[i];
|
||||
switch ( task[0] ) {
|
||||
case ':has':
|
||||
case ':xpath':
|
||||
raw.push(task[0], '(', task[1], ')');
|
||||
break;
|
||||
|
@ -264,6 +263,7 @@
|
|||
}
|
||||
raw.push(task[0], '(', task[1].name, ': ', value, ')');
|
||||
break;
|
||||
case ':has':
|
||||
case ':if':
|
||||
case ':if-not':
|
||||
raw.push(task[0], '(', decompile(task[1]), ')');
|
||||
|
|
Loading…
Reference in New Issue