mirror of https://github.com/gorhill/uBlock.git
code review: fixed sorting of 1st-party hostnames
This commit is contained in:
parent
e2bc299dc9
commit
da6c7b8b5e
|
@ -78,8 +78,10 @@ window.addEventListener('unload', function() {
|
||||||
vAPI.app.onShutdown();
|
vAPI.app.onShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( var cleanup of cleanupTasks ) {
|
// IMPORTANT: cleanup tasks must be executed using LIFO order.
|
||||||
cleanup();
|
var i = cleanupTasks.length;
|
||||||
|
while ( i-- ) {
|
||||||
|
cleanupTasks[i]();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cleanupTasks.length < expectedNumberOfCleanups ) {
|
if ( cleanupTasks.length < expectedNumberOfCleanups ) {
|
||||||
|
@ -2865,17 +2867,18 @@ vAPI.toolbarButton = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var shutdown = function() {
|
var shutdown = function() {
|
||||||
CustomizableUI.removeListener(CUIEvents);
|
|
||||||
CustomizableUI.destroyWidget(tbb.id);
|
|
||||||
|
|
||||||
for ( var win of winWatcher.getWindows() ) {
|
for ( var win of winWatcher.getWindows() ) {
|
||||||
var panel = win.document.getElementById(tbb.viewId);
|
var panel = win.document.getElementById(tbb.viewId);
|
||||||
|
if ( panel !== null && panel.parentNode !== null ) {
|
||||||
panel.parentNode.removeChild(panel);
|
panel.parentNode.removeChild(panel);
|
||||||
|
}
|
||||||
win.QueryInterface(Ci.nsIInterfaceRequestor)
|
win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDOMWindowUtils)
|
.getInterface(Ci.nsIDOMWindowUtils)
|
||||||
.removeSheet(styleURI, 1);
|
.removeSheet(styleURI, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomizableUI.removeListener(CUIEvents);
|
||||||
|
CustomizableUI.destroyWidget(tbb.id);
|
||||||
|
|
||||||
vAPI.messaging.globalMessageManager.removeMessageListener(
|
vAPI.messaging.globalMessageManager.removeMessageListener(
|
||||||
location.host + ':closePopup',
|
location.host + ':closePopup',
|
||||||
|
|
|
@ -126,10 +126,12 @@ var cachePopupData = function(data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
domain = hostnameDict[hostname].domain;
|
domain = hostnameDict[hostname].domain;
|
||||||
|
prefix = hostname.slice(0, 0 - domain.length);
|
||||||
|
// Prefix with space char for 1st-party hostnames: this ensure these
|
||||||
|
// will come first in list.
|
||||||
if ( domain === popupData.pageDomain ) {
|
if ( domain === popupData.pageDomain ) {
|
||||||
domain = '\u0020';
|
domain = '\u0020';
|
||||||
}
|
}
|
||||||
prefix = hostname.slice(0, 0 - domain.length);
|
|
||||||
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
||||||
}
|
}
|
||||||
return popupData;
|
return popupData;
|
||||||
|
|
Loading…
Reference in New Issue