Skip to content
Permalink
Browse files
Allow :upward() operator to select html element
  • Loading branch information
gorhill authored and hawkeye116477 committed Aug 11, 2020
1 parent 1a53571 commit c79db5c2c44f01f431913786853eda7255587d05
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/js/contentscript.js
@@ -430,8 +430,12 @@ vAPI.DOMFilterer = (function() {
const PSelectorSpathTask = class {
constructor(task) {
this.spath = task[1];
this.nth = /^(?:\s*[+~]|:)/.test(this.spath);
}
transpose(node, output) {
qsa(node) {
if ( this.nth === false ) {
return node.querySelectorAll(this.spath);
}
const parent = node.parentElement;
if ( parent === null ) { return; }
let pos = 1;
@@ -440,9 +444,13 @@ vAPI.DOMFilterer = (function() {
if ( node === null ) { break; }
pos += 1;
}
const nodes = parent.querySelectorAll(
return parent.querySelectorAll(
`:scope > :nth-child(${pos})${this.spath}`
);
}
transpose(node, output) {
const nodes = this.qsa(node);
if ( nodes === undefined ) { return; }
for ( let node of nodes ) {
output.push(node);
}

0 comments on commit c79db5c

Please sign in to comment.