code review

This commit is contained in:
gorhill 2014-09-05 16:13:48 -04:00
parent 852e170586
commit 1f2ad19a22
1 changed files with 9 additions and 7 deletions

View File

@ -501,7 +501,7 @@ var uBlockMessaging = (function(name){
if ( typeof node.querySelectorAll !== 'function' ) { if ( typeof node.querySelectorAll !== 'function' ) {
continue; continue;
} }
if ( ignoreTags[node.tagName] ) { if ( ignoreTags.hasOwnProperty(node.tagName) ) {
continue; continue;
} }
contextNodes.push(node); contextNodes.push(node);
@ -563,13 +563,14 @@ var uBlockMessaging = (function(name){
} }
// If `!important` is not there, going back using history will // If `!important` is not there, going back using history will
// likely cause the hidden element to re-appear. // likely cause the hidden element to re-appear.
elem.style.visibility = 'hidden !important';
if ( collapse ) { if ( collapse ) {
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.removeChild(elem); elem.parentNode.removeChild(elem);
} else { } else {
elem.style.display = 'none !important'; elem.style.setProperty('display', 'none', 'important');
} }
} else {
elem.style.setProperty('visibility', 'hidden', 'important');
} }
selectors.push(tagName + '[' + prop + '="' + src + '"]'); selectors.push(tagName + '[' + prop + '="' + src + '"]');
} }
@ -594,6 +595,7 @@ var uBlockMessaging = (function(name){
var failedElements = { var failedElements = {
'img': 'src', 'img': 'src',
'input': 'src',
'object': 'data' 'object': 'data'
}; };
@ -619,15 +621,15 @@ var uBlockMessaging = (function(name){
} }
// If `!important` is not there, going back using history will // If `!important` is not there, going back using history will
// likely cause the hidden element to re-appear. // likely cause the hidden element to re-appear.
target.style.visibility = 'hidden !important';
if ( details.collapse ) { if ( details.collapse ) {
if ( target.parentNode ) { if ( target.parentNode ) {
target.parentNode.removeChild(target); target.parentNode.removeChild(target);
} else { } else {
target.style.display = 'none !important'; target.style.setProperty('display', 'none', 'important');
} }
} else {
target.style.setProperty('visibility', 'hidden', 'important');
} }
// TODO: investigate injecting as a style. Is overhead worth it?
messaging.tell({ messaging.tell({
what: 'injectedSelectors', what: 'injectedSelectors',
type: 'net', type: 'net',
@ -644,7 +646,7 @@ var uBlockMessaging = (function(name){
}; };
var onResourceFailed = function(ev) { var onResourceFailed = function(ev) {
//console.debug('Failed to load %o[src="%s"]', eev.target.tagName, ev.target.src); //console.debug('Failed to load %s[src="%s"]', ev.target.tagName, ev.target.src);
onResource(ev.target, failedElements); onResource(ev.target, failedElements);
}; };