From bad600fb1fb70238f42767c56f01256470fa3c15 Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Thu, 21 Jul 2011 00:40:05 +0200 Subject: [PATCH 1/6] This hack kills the loading indicator in FF --- lib/transports/jsonp-polling.js | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/transports/jsonp-polling.js b/lib/transports/jsonp-polling.js index 782329b4..96c590dd 100644 --- a/lib/transports/jsonp-polling.js +++ b/lib/transports/jsonp-polling.js @@ -6,6 +6,15 @@ */ (function (exports, io) { + /** + * There is a way to hide the loading indicator in Firefox. If you create and + * remove a iframe it will stop showing the current loading indicator. + * Unfortunatly we can't feature detect that and UA sniffing is evil. + * + * @api private + */ + + var indicator = "MozAppearance" in document.documentElement.style; /** * Expose constructor. @@ -153,6 +162,14 @@ var insertAt = document.getElementsByTagName('script')[0] insertAt.parentNode.insertBefore(script, insertAt); this.script = script; + + if (indicator) { + setTimeout(function () { + var iframe = document.createElement('iframe'); + document.body.appendChild(iframe); + document.body.removeChild(iframe); + }, 100); + } }; /** @@ -170,6 +187,23 @@ return this; }; + /** + * The indicator hack only works after onload + * + * @param {Socket} socket The socket instance that needs a transport + * @param {Function} fn The callback + * @api private + */ + + JSONPPolling.prototype.ready = function (socket, fn) { + var self = this; + if (!indicator) return fn.call(this); + + io.util.load(function () { + fn.call(self); + }); + }; + /** * Checks if browser supports this transport. * From 964be4cd7aa2fee26bb9594d5f9a9086d1b4f29c Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Thu, 21 Jul 2011 00:42:33 +0200 Subject: [PATCH 2/6] Fixed spelling mistake --- lib/transports/jsonp-polling.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transports/jsonp-polling.js b/lib/transports/jsonp-polling.js index 96c590dd..48414f82 100644 --- a/lib/transports/jsonp-polling.js +++ b/lib/transports/jsonp-polling.js @@ -9,7 +9,7 @@ /** * There is a way to hide the loading indicator in Firefox. If you create and * remove a iframe it will stop showing the current loading indicator. - * Unfortunatly we can't feature detect that and UA sniffing is evil. + * Unfortunately we can't feature detect that and UA sniffing is evil. * * @api private */ From a39f2a1464611f1ee852097f399f8bae846ceb88 Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Fri, 5 Aug 2011 12:29:47 +0200 Subject: [PATCH 3/6] We totally missed the `ascii_only` option, so no more filty hacks --- bin/builder.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/bin/builder.js b/bin/builder.js index 3206f043..c19dcaa4 100755 --- a/bin/builder.js +++ b/bin/builder.js @@ -209,18 +209,11 @@ var builder = module.exports = function () { // check if we need to process it any further if (settings.minify) { - // uglify hate unicode chars... - var separator = '@@OMGYUCHANGEME@@@'; - code = code.replace(/(\\ufffd)/g, separator); - var ast = uglify.parser.parse(code); ast = uglify.uglify.ast_mangle(ast); ast = uglify.uglify.ast_squeeze(ast); - code = production + uglify.uglify.gen_code(ast); - - // restore the code - code = code.replace(new RegExp('('+ separator + ')', 'g'), '\\ufffd'); + code = production + uglify.uglify.gen_code(ast, {ascii_only: true}); } callback(error, code); From 6379e086553f85ce1179fe5777520423376313cb Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Fri, 5 Aug 2011 12:33:40 +0200 Subject: [PATCH 4/6] code style --- bin/builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/builder.js b/bin/builder.js index c19dcaa4..8b1b680d 100755 --- a/bin/builder.js +++ b/bin/builder.js @@ -213,7 +213,7 @@ var builder = module.exports = function () { ast = uglify.uglify.ast_mangle(ast); ast = uglify.uglify.ast_squeeze(ast); - code = production + uglify.uglify.gen_code(ast, {ascii_only: true}); + code = production + uglify.uglify.gen_code(ast, { ascii_only: true }); } callback(error, code); From da060de77a508040f59015e259c58e1a0efb8974 Mon Sep 17 00:00:00 2001 From: Leonid Khachaturov Date: Thu, 29 Sep 2011 11:12:57 +0200 Subject: [PATCH 5/6] Fix warning when compressing with Google Closure Compiler: WARNING - If this if/for/while really shouldnt have a body, use {} for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0; ^ --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 06d66aa0..e13a7915 100644 --- a/lib/util.js +++ b/lib/util.js @@ -306,7 +306,7 @@ } for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0; - i < j && arr[i] !== o; i++); + i < j && arr[i] !== o; i++) {} return j <= i ? -1 : i; }; From 283b0119d6ac9a74a2775f25024b716c0ddd1da3 Mon Sep 17 00:00:00 2001 From: Daniel Beardsley Date: Thu, 6 Oct 2011 00:23:34 -0700 Subject: [PATCH 6/6] Make underlying Transport disconnection trigger immediate socket.io disconnection This solves the frustration of a client being aable to tell it's connection has been severed. --- lib/transport.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/transport.js b/lib/transport.js index 82128393..7f2b718d 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -101,7 +101,7 @@ */ Transport.prototype.onDisconnect = function () { - if (this.close) this.close(); + if (this.close && this.open) this.close(); this.clearTimeouts(); this.socket.onDisconnect(); return this; @@ -196,8 +196,8 @@ }, this.socket.options['reopen delay']);*/ this.open = false; - this.setCloseTimeout(); this.socket.onClose(); + this.onDisconnect(); }; /**