Skip to content

Commit b946ec9

Browse files
committed
fix panel creation only if inspectedWindow.tabId present
1 parent 477b000 commit b946ec9

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/js/jsdiff-devtools.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
chrome.devtools.panels.create(
2-
'JSDiff',
3-
'/src/img/panel-icon28.png',
4-
'/src/jsdiff-panel.html',
5-
(panel) => {
6-
panel.onSearch.addListener(async (cmd, query) => {
7-
await chrome.runtime.sendMessage({
8-
source: 'jsdiff-panel-search',
9-
params: { cmd, query },
10-
});
11-
});
12-
}
13-
);
14-
151
// tabId may be null if user opened the devtools of the devtools
162
if (chrome.devtools.inspectedWindow.tabId !== null) {
3+
chrome.devtools.panels.create(
4+
'JSDiff',
5+
'/src/img/panel-icon28.png',
6+
'/src/jsdiff-panel.html',
7+
(panel) => {
8+
panel.onSearch.addListener(async (cmd, query) => {
9+
await chrome.runtime.sendMessage({
10+
source: 'jsdiff-panel-search',
11+
params: { cmd, query },
12+
});
13+
});
14+
}
15+
);
16+
1717
injectScripts();
18-
}
1918

20-
// listen on tabs page reload
21-
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
22-
if ('complete' === changeInfo.status) {
23-
injectScripts();
24-
}
25-
});
19+
// listen on tabs page reload
20+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
21+
if ('complete' === changeInfo.status) {
22+
injectScripts();
23+
}
24+
});
2625

27-
// track api invocation - (api can be invoked prior opening of jsdiff panel)
28-
chrome.runtime.onMessage.addListener(async (req) => {
29-
if ('jsdiff-devtools-extension-api' === req.source) {
30-
await chrome.storage.local.set({ lastApiReq: req });
31-
}
32-
});
26+
// track api invocation - (api can be invoked prior opening of jsdiff panel)
27+
chrome.runtime.onMessage.addListener(async (req) => {
28+
if ('jsdiff-devtools-extension-api' === req.source) {
29+
await chrome.storage.local.set({ lastApiReq: req });
30+
}
31+
});
32+
}
3333

3434
// Inject console api and messaging proxy
3535
// us shown at: https://developer.chrome.com/extensions/devtools#content-script-to-devtools

0 commit comments

Comments
 (0)