mirror of https://github.com/gorhill/uBlock.git
Prevent `:others()` from hiding `html` tag
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3060
This commit is contained in:
parent
c65dbdbffa
commit
9a104bcbd2
|
@ -30,6 +30,9 @@ if (
|
|||
/******************************************************************************/
|
||||
|
||||
const nonVisualElements = {
|
||||
head: true,
|
||||
link: true,
|
||||
meta: true,
|
||||
script: true,
|
||||
style: true,
|
||||
};
|
||||
|
@ -196,29 +199,28 @@ class PSelectorOthersTask extends PSelectorTask {
|
|||
const toKeep = new Set(this.targets);
|
||||
const toDiscard = new Set();
|
||||
const body = document.body;
|
||||
const head = document.head;
|
||||
let discard = null;
|
||||
for ( let keep of this.targets ) {
|
||||
while ( keep !== null && keep !== body ) {
|
||||
while ( keep !== null && keep !== body && keep !== head ) {
|
||||
toKeep.add(keep);
|
||||
toDiscard.delete(keep);
|
||||
discard = keep.previousElementSibling;
|
||||
while ( discard !== null ) {
|
||||
if (
|
||||
nonVisualElements[discard.localName] !== true &&
|
||||
toKeep.has(discard) === false
|
||||
) {
|
||||
if ( nonVisualElements[discard.localName] !== true ) {
|
||||
if ( toKeep.has(discard) === false ) {
|
||||
toDiscard.add(discard);
|
||||
}
|
||||
}
|
||||
discard = discard.previousElementSibling;
|
||||
}
|
||||
discard = keep.nextElementSibling;
|
||||
while ( discard !== null ) {
|
||||
if (
|
||||
nonVisualElements[discard.localName] !== true &&
|
||||
toKeep.has(discard) === false
|
||||
) {
|
||||
if ( nonVisualElements[discard.localName] !== true ) {
|
||||
if ( toKeep.has(discard) === false ) {
|
||||
toDiscard.add(discard);
|
||||
}
|
||||
}
|
||||
discard = discard.nextElementSibling;
|
||||
}
|
||||
keep = keep.parentElement;
|
||||
|
|
Loading…
Reference in New Issue