[Pkg-javascript-commits] [sockjs-client] 397/434: Fix #63 - delay xhr-streaming until onload

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:28 UTC 2014


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

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

commit aff2c515b20c09968c941cbfdc1959273d780097
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Mon Apr 23 17:14:52 2012 +0100

    Fix #63 - delay xhr-streaming until onload
---
 lib/sockjs.js    | 4 +++-
 lib/trans-xhr.js | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index 1c68120..5b384f3 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -178,7 +178,9 @@ SockJS.prototype._try_next_protocol = function(close_event) {
         // the `head`?
         if (SockJS[protocol] &&
             SockJS[protocol].need_body === true &&
-            !_document.body) {
+            (!_document.body ||
+             (typeof _document.readyState !== 'undefined'
+              && _document.readyState !== 'complete'))) {
             that._protocols.unshift(protocol);
             that.protocol = 'waiting-for-load';
             utils.attachEvent('load', function(){
diff --git a/lib/trans-xhr.js b/lib/trans-xhr.js
index f7ac933..7594290 100644
--- a/lib/trans-xhr.js
+++ b/lib/trans-xhr.js
@@ -43,6 +43,11 @@ XhrStreamingTransport.enabled = function() {
 };
 XhrStreamingTransport.roundTrips = 2; // preflight, ajax
 
+// Safari gets confused when a streaming ajax request is started
+// before onload. This causes the load indicator to spin indefinetely.
+XhrStreamingTransport.need_body = true;
+
+
 // According to:
 //   http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests
 //   http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/

-- 
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