Firefox: improve vAPI.tabs.getTabId

This commit is contained in:
Deathamns 2014-12-19 21:26:10 +01:00
parent c45b7c75e2
commit 85ee514ebc
1 changed files with 9 additions and 2 deletions

View File

@ -360,8 +360,15 @@ vAPI.tabs.getTabId = function(target) {
return target.linkedPanel.slice(6);
}
var gBrowser = target.ownerDocument.defaultView.gBrowser;
var i = gBrowser.browsers.indexOf(target);
var i, gBrowser = target.ownerDocument.defaultView.gBrowser;
// This should be more efficient from version 35
if (gBrowser.getTabForBrowser) {
i = gBrowser.getTabForBrowser(target);
return i ? i.linkedPanel.slice(6) : -1;
}
i = gBrowser.browsers.indexOf(target);
if (i !== -1) {
i = gBrowser.tabs[i].linkedPanel.slice(6);