1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

different fix for #762, which does not create a regression of 435

This commit is contained in:
gorhill 2015-10-14 16:49:57 -04:00
parent 135ad95d61
commit ea4d5a9710
2 changed files with 20 additions and 8 deletions

View File

@ -474,21 +474,27 @@ var uBlockCollapser = (function() {
var elem, shadow; var elem, shadow;
while ( i-- ) { while ( i-- ) {
elem = elems[i]; elem = elems[i];
// https://github.com/gorhill/uBlock/issues/762 shadow = elem.shadowRoot;
// Always hide using inline style.
elem.style.setProperty('display', 'none', 'important');
// https://www.chromestatus.com/features/4668884095336448 // https://www.chromestatus.com/features/4668884095336448
// "Multiple shadow roots is being deprecated." // "Multiple shadow roots is being deprecated."
if ( elem.shadowRoot !== null ) { if ( shadow !== null ) {
if ( shadow.className !== sessionId ) {
elem.style.setProperty('display', 'none', 'important');
}
continue; continue;
} }
// https://github.com/gorhill/uBlock/pull/555 // https://github.com/gorhill/uBlock/pull/555
// Not all nodes can be shadowed: // Not all nodes can be shadowed:
// https://github.com/w3c/webcomponents/issues/102 // https://github.com/w3c/webcomponents/issues/102
// https://github.com/gorhill/uBlock/issues/762
// Remove display style that might get in the way of the shadow
// node doing its magic.
try { try {
shadow = elem.createShadowRoot(); shadow = elem.createShadowRoot();
shadow.className = sessionId; shadow.className = sessionId;
elem.style.removeProperty('display');
} catch (ex) { } catch (ex) {
elem.style.setProperty('display', 'none', 'important');
} }
} }
}; };

View File

@ -183,21 +183,27 @@ var hideElements = function(selectors) {
var elem, shadow; var elem, shadow;
while ( i-- ) { while ( i-- ) {
elem = elems[i]; elem = elems[i];
// https://github.com/gorhill/uBlock/issues/762 shadow = elem.shadowRoot;
// Always hide using inline style.
elem.style.setProperty('display', 'none', 'important');
// https://www.chromestatus.com/features/4668884095336448 // https://www.chromestatus.com/features/4668884095336448
// "Multiple shadow roots is being deprecated." // "Multiple shadow roots is being deprecated."
if ( elem.shadowRoot !== null ) { if ( shadow !== null ) {
if ( shadow.className !== sessionId ) {
elem.style.setProperty('display', 'none', 'important');
}
continue; continue;
} }
// https://github.com/gorhill/uBlock/pull/555 // https://github.com/gorhill/uBlock/pull/555
// Not all nodes can be shadowed: // Not all nodes can be shadowed:
// https://github.com/w3c/webcomponents/issues/102 // https://github.com/w3c/webcomponents/issues/102
// https://github.com/gorhill/uBlock/issues/762
// Remove display style that might get in the way of the shadow
// node doing its magic.
try { try {
shadow = elem.createShadowRoot(); shadow = elem.createShadowRoot();
shadow.className = sessionId; shadow.className = sessionId;
elem.style.removeProperty('display');
} catch (ex) { } catch (ex) {
elem.style.setProperty('display', 'none', 'important');
} }
} }
}; };