Skip to content

Commit 7f67120

Browse files
committed
chore: support openerTabId
1 parent 82f3f3c commit 7f67120

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/utils/common.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import browser from 'webextension-polyfill';
22

33
const getText = browser.i18n.getMessage;
44

5-
function createTab(url, {index, active = true} = {}) {
5+
async function createTab(
6+
url,
7+
{index = null, active = true, openerTabId = null} = {}
8+
) {
69
const props = {url, active};
7-
if (typeof index !== 'undefined') {
10+
if (index !== null) {
811
props.index = index;
912
}
13+
if (
14+
openerTabId !== null &&
15+
openerTabId !== browser.tabs.TAB_ID_NONE &&
16+
!(await isAndroid())
17+
) {
18+
props.openerTabId = openerTabId;
19+
}
1020
return browser.tabs.create(props);
1121
}
1222

@@ -18,4 +28,9 @@ async function getActiveTab() {
1828
return tab;
1929
}
2030

31+
async function isAndroid() {
32+
const {os} = await browser.runtime.getPlatformInfo();
33+
return os === 'android';
34+
}
35+
2136
export {getText, createTab, getActiveTab};

0 commit comments

Comments
 (0)