From a3f840504f6e76a1810b4d9b654b55798d466f88 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 11 Apr 2014 12:38:08 +0200 Subject: [PATCH 1/6] polling-xhr: fix a comment and remove unneeded `document` reference --- lib/transports/polling-xhr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/transports/polling-xhr.js b/lib/transports/polling-xhr.js index b18becbd..a1916339 100755 --- a/lib/transports/polling-xhr.js +++ b/lib/transports/polling-xhr.js @@ -286,15 +286,15 @@ Request.prototype.abort = function(){ }; /** - * Cleanup is needed for IE that leaks memory unless we abort the request - * before unload. It is also needed to prevent spurious errors from being - * emimtted. + * Aborts pending requests when unloading the window. This is needed to prevent + * memory leaks (e.g. when using IE) and to ensure that no spurious error is + * emitted. */ if (global.document) { Request.requestsCount = 0; Request.requests = {}; - if (global.document.attachEvent) { + if (global.attachEvent) { global.attachEvent('onunload', unloadHandler); } else if (global.addEventListener) { global.addEventListener('beforeunload', unloadHandler); From d8b331075974350775ad0320f00fd8d3300a87b2 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sat, 12 Apr 2014 11:42:09 -0700 Subject: [PATCH 2/6] README: more tweaks (thanks @mokesmokes) --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 34740530..7a0704c7 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ socket.on('open', function(){ binary is encoded into base64 strings, and decoded when binary types are supported. - With browsers that don't support ArrayBuffer, an object { base64: true, - data: dataAsBase64String } is emitted in onmessage + data: dataAsBase64String } is emitted on the `message` event. ## API @@ -111,12 +111,6 @@ Exposed as `eio` in the browser standalone build. #### Properties - `protocol` _(Number)_: protocol revision number -- `onopen` (_Function_) - - `open` event handler -- `onmessage` (_Function_) - - `message` event handler -- `onclose` (_Function_) - - `message` event handler - `binaryType` _(String)_ : can be set to 'arraybuffer' or 'blob' in browsers, and `buffer` or `arraybuffer` in Node. Blob is only used in browser if it's supported. From 3fcc9fb43800d68057b49e919b4ab39a733d07e8 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 12 Apr 2014 15:25:13 +0200 Subject: [PATCH 3/6] polling-jsonp: prevent spurious errors from being emitted when the window is unloaded --- lib/transports/polling-jsonp.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/transports/polling-jsonp.js b/lib/transports/polling-jsonp.js index d55631db..46f632b0 100644 --- a/lib/transports/polling-jsonp.js +++ b/lib/transports/polling-jsonp.js @@ -67,6 +67,13 @@ function JSONPPolling (opts) { // append to query string this.query.j = this.index; + + // prevent spurious errors from being emitted when the window is unloaded + if (global.document && global.addEventListener) { + global.addEventListener('beforeunload', function () { + if (self.script) self.script.onerror = empty; + }); + } } /** @@ -82,7 +89,7 @@ util.inherits(JSONPPolling, Polling); JSONPPolling.prototype.supportsBinary = false; /** - * Closes the socket + * Closes the socket. * * @api private */ @@ -108,7 +115,7 @@ JSONPPolling.prototype.doClose = function () { */ JSONPPolling.prototype.doPoll = function () { - var self = this; + var self = this; var script = document.createElement('script'); if (this.script) { @@ -126,7 +133,6 @@ JSONPPolling.prototype.doPoll = function () { insertAt.parentNode.insertBefore(script, insertAt); this.script = script; - if (util.ua.gecko) { setTimeout(function () { var iframe = document.createElement('iframe'); From d477098b3966a335eeb62775c5fff354b86a413e Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sun, 13 Apr 2014 12:05:59 -0700 Subject: [PATCH 4/6] package: bump `engine.io-parser` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9aecc13..531491ce 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "xmlhttprequest": "https://github.com/LearnBoost/node-XMLHttpRequest/archive/0f36d0b5ebc03d85f860d42a64ae9791e1daa433.tar.gz", "emitter": "http://github.com/component/emitter/archive/1.0.1.tar.gz", "indexof": "0.0.1", - "engine.io-parser": "1.0.3", + "engine.io-parser": "1.0.4", "debug": "0.7.4", "parseuri": "0.0.2", "parsejson": "0.0.1", From e46d36e6730673ea493dd679d4f249ad6be6fd60 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sun, 13 Apr 2014 12:21:58 -0700 Subject: [PATCH 5/6] rebuild --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7a0704c7..3fd364b3 100644 --- a/README.md +++ b/README.md @@ -240,3 +240,4 @@ See the `Tests` section above for how to run tests before submitting any patches ## License MIT - Copyright (c) 2014 Automattic, Inc. + From c93da98c8ebcc389a4bd233cdc6565f407f766ac Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sun, 13 Apr 2014 12:28:04 -0700 Subject: [PATCH 6/6] rebuild --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3fd364b3..7a0704c7 100644 --- a/README.md +++ b/README.md @@ -240,4 +240,3 @@ See the `Tests` section above for how to run tests before submitting any patches ## License MIT - Copyright (c) 2014 Automattic, Inc. -