Skip to content

Commit 610b85c

Browse files
committed
Use new event.getListeners()
Fix nwjs#7077
1 parent 94c6a05 commit 610b85c

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/resources/api_nw_newwin.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,24 @@ NWWindow.prototype.on = function (event, callback, record) {
252252
NWWindow.prototype.removeListener = function (event, callback) {
253253
if (nwWinEventsMap.hasOwnProperty(event)) {
254254
for (let l of this[nwWinEventsMap[event]].getListeners()) {
255-
if (l.callback.listener && l.callback.listener === callback) {
256-
this[nwWinEventsMap[event]].removeListener(l.callback);
255+
if (l.listener && l.listener === callback) {
256+
this[nwWinEventsMap[event]].removeListener(l);
257257
return this;
258258
}
259259
}
260260
}
261261
if (nwWrapEventsMap.hasOwnProperty(event)) {
262262
for (let l of this[nwWrapEventsMap[event]].getListeners()) {
263-
if (l.callback.listener && l.callback.listener === callback) {
264-
this[nwWrapEventsMap[event]].removeListener(l.callback);
263+
if (l.listener && l.listener === callback) {
264+
this[nwWrapEventsMap[event]].removeListener(l);
265265
return this;
266266
}
267267
}
268268
}
269269
if (wrapEventsMapNewWin.hasOwnProperty(event)) {
270270
for (let l of chrome.windows[wrapEventsMapNewWin[event]].getListeners()) {
271-
if (l.callback.listener && l.callback.listener === callback) {
272-
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l.callback);
271+
if (l.listener && l.listener === callback) {
272+
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
273273
return this;
274274
}
275275
}
@@ -289,19 +289,19 @@ NWWindow.prototype.removeAllListeners = function (event) {
289289
}
290290
if (nwWinEventsMap.hasOwnProperty(event)) {
291291
for (let l of this[nwWinEventsMap[event]].getListeners()) {
292-
this[nwWinEventsMap[event]].removeListener(l.callback);
292+
this[nwWinEventsMap[event]].removeListener(l);
293293
}
294294
return this;
295295
}
296296
if (nwWrapEventsMap.hasOwnProperty(event)) {
297297
for (let l of this[nwWrapEventsMap[event]].getListeners()) {
298-
this[nwWrapEventsMap[event]].removeListener(l.callback);
298+
this[nwWrapEventsMap[event]].removeListener(l);
299299
}
300300
return this;
301301
}
302302
if (wrapEventsMapNewWin.hasOwnProperty(event)) {
303303
for (let l of chrome.windows[wrapEventsMapNewWin[event]].getListeners()) {
304-
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l.callback);
304+
chrome.windows[wrapEventsMapNewWin[event]].removeListener(l);
305305
}
306306
return this;
307307
}

src/resources/api_nw_window.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,24 +268,24 @@ apiBridge.registerCustomHook(function(bindingsAPI) {
268268
nwNatives.callInWindow(bgPage, "__nw_removeOuterEventCB", this, event, callback);
269269
if (appWinEventsMap.hasOwnProperty(event)) {
270270
for (let l of this.appWindow[appWinEventsMap[event]].getListeners()) {
271-
if (l.callback.listener && l.callback.listener === callback) {
272-
this.appWindow[appWinEventsMap[event]].removeListener(l.callback);
271+
if (l.listener && l.listener === callback) {
272+
this.appWindow[appWinEventsMap[event]].removeListener(l);
273273
return this;
274274
}
275275
}
276276
}
277277
if (nwWinEventsMap.hasOwnProperty(event)) {
278278
for (let l of this[nwWinEventsMap[event]].getListeners()) {
279-
if (l.callback.listener && l.callback.listener === callback) {
280-
this[nwWinEventsMap[event]].removeListener(l.callback);
279+
if (l.listener && l.listener === callback) {
280+
this[nwWinEventsMap[event]].removeListener(l);
281281
return this;
282282
}
283283
}
284284
}
285285
if (nwWrapEventsMap.hasOwnProperty(event)) {
286286
for (let l of this[nwWrapEventsMap[event]].getListeners()) {
287-
if (l.callback.listener && l.callback.listener === callback) {
288-
this[nwWrapEventsMap[event]].removeListener(l.callback);
287+
if (l.listener && l.listener === callback) {
288+
this[nwWrapEventsMap[event]].removeListener(l);
289289
return this;
290290
}
291291
}
@@ -316,19 +316,19 @@ apiBridge.registerCustomHook(function(bindingsAPI) {
316316
nwNatives.callInWindow(bgPage, "__nw_remove_all_listeners", this, event);
317317
if (appWinEventsMap.hasOwnProperty(event)) {
318318
for (let l of this.appWindow[appWinEventsMap[event]].getListeners()) {
319-
this.appWindow[appWinEventsMap[event]].removeListener(l.callback);
319+
this.appWindow[appWinEventsMap[event]].removeListener(l);
320320
}
321321
return this;
322322
}
323323
if (nwWinEventsMap.hasOwnProperty(event)) {
324324
for (let l of this[nwWinEventsMap[event]].getListeners()) {
325-
this[nwWinEventsMap[event]].removeListener(l.callback);
325+
this[nwWinEventsMap[event]].removeListener(l);
326326
}
327327
return this;
328328
}
329329
if (nwWrapEventsMap.hasOwnProperty(event)) {
330330
for (let l of this[nwWrapEventsMap[event]].getListeners()) {
331-
this[nwWrapEventsMap[event]].removeListener(l.callback);
331+
this[nwWrapEventsMap[event]].removeListener(l);
332332
}
333333
return this;
334334
}

0 commit comments

Comments
 (0)