Skip to content

Commit

Permalink
fixup! Fix #7593: nw2 Window removing listeners on 'loaded' event
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Oct 18, 2020
1 parent a6496dd commit bf12d58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/resources/api_nw_newwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ NWWindow.prototype.on = function (event, callback, record) {
function wrap(cb) {
var fn = (cb || callback).bind(self);
fn.listener = callback;
fn.c_win_id = self.cWindow.id;
callback.__nw_cb = fn;
return fn;
}
Expand Down Expand Up @@ -323,13 +324,17 @@ NWWindow.prototype.removeAllListeners = function (event) {
}
if (wrapEventsMapNewWin.hasOwnProperty(event)) {
for (let l of chrome.windows[wrapEventsMapNewWin[event]].getListeners()) {
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
if (l.c_win_id === this.cWindow.id) {
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
}
}
return this;
}
if (event === 'loaded') {
for (let l of chrome.tabs.onUpdated.getListeners()) {
chrome.tabs.onUpdated.removeListener(l);
if (l.c_win_id === this.cWindow.id) {
chrome.tabs.onUpdated.removeListener(l);
}
}
return this;
}
Expand Down

0 comments on commit bf12d58

Please sign in to comment.