From 0501c0712ac968b17bf072de161e5573c0861c86 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 6 Dec 2014 15:00:31 -0200 Subject: [PATCH] this fixes #399 --- src/js/contentscript-end.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 4cd84bc2a..25c620053 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -501,11 +501,9 @@ var messager = vAPI.messaging.channel('contentscript-end.js'); // If `!important` is not there, going back using history will // likely cause the hidden element to re-appear. if ( details.collapse ) { - if ( target.parentNode ) { - target.parentNode.removeChild(target); - } else { - target.style.setProperty('display', 'none', 'important'); - } + // https://github.com/gorhill/uBlock/issues/399 + // Never remove elements from the DOM, just hide them + target.style.setProperty('display', 'none', 'important'); } else { target.style.setProperty('visibility', 'hidden', 'important'); } @@ -570,11 +568,9 @@ var messager = vAPI.messaging.channel('contentscript-end.js'); request = requests[i]; elem = elements[request.index]; if ( collapse ) { - if ( elem.parentNode ) { - elem.parentNode.removeChild(elem); - } else { - elem.style.setProperty('display', 'none', 'important'); - } + // https://github.com/gorhill/uBlock/issues/399 + // Never remove elements from the DOM, just hide them + elem.style.setProperty('display', 'none', 'important'); } else { elem.style.setProperty('visibility', 'hidden', 'important'); }