mirror of https://github.com/gorhill/uBlock.git
Allow `:upward()` operator to select `html` element
Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/hvwwj0/element_hiding_by_url_not_by_domain_is_it_possible/fyzykw0/
This commit is contained in:
parent
2931b4181f
commit
7dd48a6c8c
|
@ -573,8 +573,12 @@ vAPI.injectScriptlet = function(doc, text) {
|
|||
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;
|
||||
|
@ -583,9 +587,13 @@ vAPI.injectScriptlet = function(doc, text) {
|
|||
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 ( const node of nodes ) {
|
||||
output.push(node);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue