Skip to content

Commit a6496dd

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

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/resources/api_nw_newwin.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ var nwWinEventsMap = {
5454
};
5555

5656
var nwWrapEventsMap = {
57-
'loaded': 'LoadingStateChanged',
5857
'new-win-policy': 'onNewWinPolicy',
5958
'navigation': 'onNavigation'
6059
};
@@ -265,6 +264,14 @@ NWWindow.prototype.on = function (event, callback, record) {
265264
return this;
266265
};
267266
NWWindow.prototype.removeListener = function (event, callback) {
267+
if (event === 'loaded') {
268+
for (let l of chrome.tabs.onUpdated.getListeners()) {
269+
if (l.listener && l.listener === callback) {
270+
chrome.tabs.onUpdated.removeListener(l);
271+
return this;
272+
}
273+
}
274+
}
268275
if (nwWinEventsMap.hasOwnProperty(event)) {
269276
for (let l of this[nwWinEventsMap[event]].getListeners()) {
270277
if (l.listener && l.listener === callback) {
@@ -320,6 +327,12 @@ NWWindow.prototype.removeAllListeners = function (event) {
320327
}
321328
return this;
322329
}
330+
if (event === 'loaded') {
331+
for (let l of chrome.tabs.onUpdated.getListeners()) {
332+
chrome.tabs.onUpdated.removeListener(l);
333+
}
334+
return this;
335+
}
323336
return this;
324337
};
325338

0 commit comments

Comments
 (0)