diff --git a/bin/builder.js b/bin/builder.js index 3206f043..8b1b680d 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); 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(); }; /** diff --git a/lib/transports/jsonp-polling.js b/lib/transports/jsonp-polling.js index c69643bd..016d3f01 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. + * Unfortunately we can't feature detect that and UA sniffing is evil. + * + * @api private + */ + + var indicator = "MozAppearance" in document.documentElement.style; /** * Expose constructor. @@ -164,6 +173,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); + } }; /** @@ -181,6 +198,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. * diff --git a/lib/util.js b/lib/util.js index e09bbba2..4401aeba 100644 --- a/lib/util.js +++ b/lib/util.js @@ -304,7 +304,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; };