Skip to content

Commit bf12d58

Browse files
committed
fixup! Fix nwjs#7593: nw2 Window removing listeners on 'loaded' event
1 parent a6496dd commit bf12d58

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/resources/api_nw_newwin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ NWWindow.prototype.on = function (event, callback, record) {
149149
function wrap(cb) {
150150
var fn = (cb || callback).bind(self);
151151
fn.listener = callback;
152+
fn.c_win_id = self.cWindow.id;
152153
callback.__nw_cb = fn;
153154
return fn;
154155
}
@@ -323,13 +324,17 @@ NWWindow.prototype.removeAllListeners = function (event) {
323324
}
324325
if (wrapEventsMapNewWin.hasOwnProperty(event)) {
325326
for (let l of chrome.windows[wrapEventsMapNewWin[event]].getListeners()) {
326-
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
327+
if (l.c_win_id === this.cWindow.id) {
328+
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
329+
}
327330
}
328331
return this;
329332
}
330333
if (event === 'loaded') {
331334
for (let l of chrome.tabs.onUpdated.getListeners()) {
332-
chrome.tabs.onUpdated.removeListener(l);
335+
if (l.c_win_id === this.cWindow.id) {
336+
chrome.tabs.onUpdated.removeListener(l);
337+
}
333338
}
334339
return this;
335340
}

0 commit comments

Comments
 (0)