From 0d3dd3d2ec4a288061c7999ea79d7f245ac305aa Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 17 Dec 2014 10:47:52 -0500 Subject: [PATCH] code review for #420: mind that the rule can apply everywhere --- src/js/cosmetic-filtering.js | 14 +++++++++----- src/js/ublock.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 9e86b1f7c..1aac13e37 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -929,12 +929,16 @@ FilterContainer.prototype.addToSelectorCache = function(details) { /******************************************************************************/ -FilterContainer.prototype.removeFromSelectorCache = function(hostname, type) { - var entry = this.selectorCache[hostname]; - if ( entry === undefined ) { - return; +FilterContainer.prototype.removeFromSelectorCache = function(targetHostname, type) { + for ( var hostname in this.selectorCache ) { + if ( this.selectorCache.hasOwnProperty(hostname) === false ) { + continue; + } + if ( targetHostname !== '*' && hostname !== targetHostname ) { + continue; + } + this.selectorCache[hostname].remove(type); } - entry.remove(type); }; /******************************************************************************/ diff --git a/src/js/ublock.js b/src/js/ublock.js index 2b926a672..2c3f2a3cd 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -323,7 +323,7 @@ var matchWhitelistDirective = function(url, hostname, directive) { // https://github.com/gorhill/uBlock/issues/420 if ( details.requestType === 'sub_frame' && !details.block ) { - this.cosmeticFilteringEngine.removeFromSelectorCache(details.pageHostname, 'net'); + this.cosmeticFilteringEngine.removeFromSelectorCache(details.hostname, 'net'); } };