[Pkg-javascript-commits] [sockjs-client] 310/350: Fix #223 don't register unload event in chrome packaged app

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:33 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit c69722becbdf6e44a81176ea3cfeb7165bb5067f
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Fri May 29 23:27:55 2015 -0400

    Fix #223 don't register unload event in chrome packaged app
    
    Also don’t add listeners to hash
---
 lib/utils/event.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/utils/event.js b/lib/utils/event.js
index e673cfc..9c3bab6 100644
--- a/lib/utils/event.js
+++ b/lib/utils/event.js
@@ -4,6 +4,8 @@ var random = require('./random');
 
 var onUnload = {}
   , afterUnload = false
+    // detect google chrome packaged apps because they don't allow the 'unload' event
+  , isChromePackagedApp = global.chrome && global.chrome.app && global.chrome.app.runtime
   ;
 
 module.exports = {
@@ -30,6 +32,10 @@ module.exports = {
   }
 
 , unloadAdd: function(listener) {
+    if (isChromePackagedApp) {
+      return null;
+    }
+
     var ref = random.string(8);
     onUnload[ref] = listener;
     if (afterUnload) {
@@ -62,4 +68,6 @@ var unloadTriggered = function() {
 
 // 'unload' alone is not reliable in opera within an iframe, but we
 // can't use `beforeunload` as IE fires it on javascript: links.
-module.exports.attachEvent('unload', unloadTriggered);
+if (!isChromePackagedApp) {
+  module.exports.attachEvent('unload', unloadTriggered);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list