From ac84c458f117a44d31cfad3300b4063810b1b7b4 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 4 Jan 2019 12:51:13 -0800 Subject: [PATCH] Don't dispatch window close on HTML5, since mobile browsers might not have really closed the browser page --- .../backend/html5/HTML5Application.hx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lime/_internal/backend/html5/HTML5Application.hx b/src/lime/_internal/backend/html5/HTML5Application.hx index 10e942363..3a8db4404 100644 --- a/src/lime/_internal/backend/html5/HTML5Application.hx +++ b/src/lime/_internal/backend/html5/HTML5Application.hx @@ -386,17 +386,25 @@ class HTML5Application { case "beforeunload": - if (!event.defaultPrevented) { + // Mobile Chrome dispatches 'beforeunload' after device sleep, + // but returns later without reloading the page. This triggers + // a window.onClose(), without us creating the window again. + // + // For now, let focus in/out and activate/deactivate trigger + // on blur and focus, and do not dispatch a closed window event + // since it may actually never close. - parent.window.onClose.dispatch (); + // if (!event.defaultPrevented) { - if (parent.window != null && parent.window.onClose.canceled && event.cancelable) { + // parent.window.onClose.dispatch (); - event.preventDefault (); + // if (parent.window != null && parent.window.onClose.canceled && event.cancelable) { - } + // event.preventDefault (); - } + // } + + // } }