This commit is contained in:
Raymond Hill 2017-12-31 16:05:23 -05:00
parent 35eaf267e6
commit ec29c9a127
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
4 changed files with 9 additions and 30 deletions

View file

@ -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 ],

View file

@ -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 ],

View file

@ -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];

View file

@ -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]), ')');