mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
this fixes #269
This commit is contained in:
parent
10740a28ff
commit
d724fb23bd
1 changed files with 27 additions and 5 deletions
|
@ -609,13 +609,15 @@ vAPI.tabs._remove = function(tab, tabBrowser) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.tabs.remove = function(tabId) {
|
vAPI.tabs.remove = function(tabId) {
|
||||||
var tabs = tabWatcher.browserFromTabId(tabId);
|
var browser = tabWatcher.browserFromTabId(tabId);
|
||||||
if ( tabs.length === 0 ) {
|
if ( !browser ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for ( var tab of tabs ) {
|
var tab = tabWatcher.tabFromBrowser(browser);
|
||||||
this._remove(tab, getTabBrowser(getOwnerWindow(tab)));
|
if ( !tab ) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this._remove(tab, getTabBrowser(getOwnerWindow(browser)));
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -713,6 +715,25 @@ var tabWatcher = (function() {
|
||||||
return indexFromBrowser(browserFromTarget(target));
|
return indexFromBrowser(browserFromTarget(target));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var tabFromBrowser = function(browser) {
|
||||||
|
var i = indexFromBrowser(browser);
|
||||||
|
if ( i === -1 ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var win = getOwnerWindow(browser);
|
||||||
|
if ( !win ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var tabbrowser = getTabBrowser(win);
|
||||||
|
if ( !tabbrowser ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ( !tabbrowser.tabs || i >= tabbrowser.tabs.length ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tabbrowser.tabs[i];
|
||||||
|
};
|
||||||
|
|
||||||
var browserFromTarget = function(target) {
|
var browserFromTarget = function(target) {
|
||||||
if ( !target ) {
|
if ( !target ) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -921,7 +942,8 @@ var tabWatcher = (function() {
|
||||||
tabs: function() { return browserToTabIdMap.keys(); },
|
tabs: function() { return browserToTabIdMap.keys(); },
|
||||||
tabIdFromTarget: tabIdFromTarget,
|
tabIdFromTarget: tabIdFromTarget,
|
||||||
browserFromTabId: browserFromTabId,
|
browserFromTabId: browserFromTabId,
|
||||||
indexFromTarget: indexFromTarget
|
indexFromTarget: indexFromTarget,
|
||||||
|
tabFromBrowser: tabFromBrowser
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue