Skip to content

Commit 4197d43

Browse files
committed
nw2: Fix Window.close event
Ref nwjs#5875
1 parent f0a907b commit 4197d43

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/resources/api_nw_newwin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ var nwWinEventsMap = {
5757
'restore': 'onRestore',
5858
'enter-fullscreen': 'onFullscreen',
5959
'zoom': 'onZoom',
60-
'close': 'onClose',
6160
'resize': 'onResized'
6261
};
6362

@@ -71,7 +70,8 @@ var wrapEventsMapNewWin = {
7170
'move': 'onMove',
7271
'focus': 'onFocusChanged',
7372
'blur': 'onFocusChanged',
74-
'closed': 'onRemoved'
73+
'closed': 'onRemoved',
74+
'close': 'onRemoving'
7575
};
7676

7777
nw_internal.registerCustomHook(function(bindingsAPI) {
@@ -197,7 +197,12 @@ NWWindow.prototype.on = function (event, callback, record) {
197197
}
198198

199199
if (event === 'close') {
200-
this.onClose.addListener(wrap(), {instanceId: currentWidgetRoutingID});
200+
var cbc = wrap(function(windowId, flag) {
201+
if (self.cWindow.id !== windowId)
202+
return;
203+
callback.call(self, flag);
204+
});
205+
chrome.windows.onRemoving.addListener(cbc, {instanceId: self.cWindow.id});
201206
return this;
202207
}
203208
switch (event) {

0 commit comments

Comments
 (0)