[Pkg-javascript-commits] [sockjs-client] 85/350: Use `window.location` instead of `document.location` If a frame, image, or form is named "location" then document.location will refer to that element instead of being an alias for `window.location` see https://github.com/meteor/meteor/issues/2380

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:45 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 315e2cddb629cbca9196f2ca6b854d1f41e53829
Author: Maxime Quandalle <maxime.quandalle at gmail.com>
Date:   Mon Sep 8 23:08:54 2014 +0200

    Use `window.location` instead of `document.location`
    If a frame, image, or form is named "location" then document.location
    will refer to that element instead of being an alias for `window.location`
    see https://github.com/meteor/meteor/issues/2380
---
 lib/sockjs.js                    | 4 ++--
 lib/utils.js                     | 2 +-
 tests/html/iframe.html           | 2 +-
 tests/html/lib/endtoendtests.js  | 2 +-
 tests/html/lib/unittests.js      | 2 +-
 tests/html/sockjs-in-head.html   | 2 +-
 tests/html/sockjs-in-parent.html | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index 62da157..9f313ca 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -213,7 +213,7 @@ SockJS.prototype._try_next_protocol = function(close_event) {
             utils.attachEvent('load', tryNextProtocol);
             return true;
         }
-        
+
         var roundTrips = Protocol.roundTrips || 1;
         var to = ((that._rto || 0) * roundTrips) || 5000;
         that._transport_tref = setTimeout(timeoutFunction, to);
@@ -266,7 +266,7 @@ utils.parent_origin = undefined;
 
 SockJS.bootstrap_iframe = function() {
     var facade;
-    utils.curr_window_id = document.location.hash.slice(1);
+    utils.curr_window_id = window.location.hash.slice(1);
     var onMessage = function(e) {
         if(e.source !== parent) return;
         if(typeof utils.parent_origin === 'undefined')
diff --git a/lib/utils.js b/lib/utils.js
index 5631950..a395590 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -153,7 +153,7 @@ utils.flatUrl = function(url) {
 };
 
 utils.amendUrl = function(url) {
-    var dl = document.location;
+    var dl = window.location;
     if (!url) {
         throw new Error('Wrong url for SockJS');
     }
diff --git a/tests/html/iframe.html b/tests/html/iframe.html
index 9f1ef2f..2176f2c 100644
--- a/tests/html/iframe.html
+++ b/tests/html/iframe.html
@@ -12,7 +12,7 @@
   <h2>Don't panic!</h2>
   <script>
     c = parent._sockjs_global;
-    window_id = document.location.hash.slice(1);
+    window_id = window.location.hash.slice(1);
     hook = c(window_id);
     hook.callback = function(code) {eval(code);};
     hook.open();
diff --git a/tests/html/lib/endtoendtests.js b/tests/html/lib/endtoendtests.js
index af1eccd..259aa6d 100644
--- a/tests/html/lib/endtoendtests.js
+++ b/tests/html/lib/endtoendtests.js
@@ -42,7 +42,7 @@ test("invalid url port", function(done) {
   this.runnable().globals(['_sockjs_global']);
   var dl, r;
   //expect(4);
-  dl = document.location;
+  dl = window.location;
   r = testutils.newSockJS(dl.protocol + '//' + dl.hostname + ':1079', 'jsonp-polling');
   assert.ok(r);
   r.onopen = function(e) {
diff --git a/tests/html/lib/unittests.js b/tests/html/lib/unittests.js
index 0cc9bb0..9809cd5 100644
--- a/tests/html/lib/unittests.js
+++ b/tests/html/lib/unittests.js
@@ -110,7 +110,7 @@ test('bind', function() {
 
 test('amendUrl', function() {
   var dl, t;
-  dl = document.location;
+  dl = window.location;
   assert.equal(u.amendUrl('//blah:1/abc'), dl.protocol + '//blah:1/abc');
   assert.equal(u.amendUrl('/abc'), dl.protocol + '//' + dl.host + '/abc');
   assert.equal(u.amendUrl('/'), dl.protocol + '//' + dl.host);
diff --git a/tests/html/sockjs-in-head.html b/tests/html/sockjs-in-head.html
index c8c851a..9e798f2 100644
--- a/tests/html/sockjs-in-head.html
+++ b/tests/html/sockjs-in-head.html
@@ -9,7 +9,7 @@
   <script src="/lib/sockjs.js?no=cache"></script>
   <script>
     c = parent._sockjs_global;
-    window_id = document.location.hash.slice(1);
+    window_id = window.location.hash.slice(1);
     hook = c(window_id);
     hook.callback = function(code) {eval(code);};
     hook.open();
diff --git a/tests/html/sockjs-in-parent.html b/tests/html/sockjs-in-parent.html
index e207a2c..d06e3ad 100755
--- a/tests/html/sockjs-in-parent.html
+++ b/tests/html/sockjs-in-parent.html
@@ -8,7 +8,7 @@
   </script>
   <script>
     c = parent._sockjs_global;
-    window_id = document.location.hash.slice(1);
+    window_id = window.location.hash.slice(1);
     hook = c(window_id);
     hook.callback = function(code) {eval(code);};
     hook.open();

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