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