[Pkg-javascript-commits] [sockjs-client] 107/350: Replace window with global. Prefix document with global.
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:03:48 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 ee1e00193a105d9b79566d500b343f550e656466
Author: Bryce Kahle <bkahle at gmail.com>
Date: Fri Oct 10 12:24:57 2014 -0400
Replace window with global. Prefix document with global.
---
lib/main.js | 4 ++--
lib/transport/receiver/htmlfile.js | 6 +++---
lib/transport/sender/jsonp.js | 14 +++++++-------
lib/utils/iframe.js | 18 ++++++++++--------
4 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/lib/main.js b/lib/main.js
index 3f445d0..5aa38fa 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -158,8 +158,8 @@ SockJS.prototype._receiveInfo = function(info, rtt) {
SockJS.prototype._connect = function() {
for (var Transport = this._transports.shift(); Transport; Transport = this._transports.shift()) {
if (Transport.needBody) {
- if (!document.body ||
- (typeof document.readyState !== 'undefined' && document.readyState !== 'complete')) {
+ if (!global.document.body ||
+ (typeof global.document.readyState !== 'undefined' && global.document.readyState !== 'complete')) {
this._transports.unshift(Transport);
// TODO attach to load event to call _connect
return;
diff --git a/lib/transport/receiver/htmlfile.js b/lib/transport/receiver/htmlfile.js
index db91d85..7db4e60 100644
--- a/lib/transport/receiver/htmlfile.js
+++ b/lib/transport/receiver/htmlfile.js
@@ -10,7 +10,7 @@ var util = require('util')
var _isIeHtmlfileCapable;
var isIeHtmlfileCapable = function() {
if (_isIeHtmlfileCapable === undefined) {
- if ('ActiveXObject' in window) {
+ if ('ActiveXObject' in global) {
try {
_isIeHtmlfileCapable = !!new ActiveXObject('htmlfile');
} catch (x) {}
@@ -35,7 +35,7 @@ function HtmlfileReceiver(url) {
utils.createHtmlfile : utils.createIframe;
var iframeObj;
- window[utils.WPrefix][this.id] = {
+ global[utils.WPrefix][this.id] = {
start: function () {
iframeObj.loaded();
},
@@ -49,7 +49,7 @@ function HtmlfileReceiver(url) {
this.iframeClose = function(e, abortReason) {
iframeObj.cleanup();
self.iframeClose = iframeObj = null;
- delete window[utils.WPrefix][self.id];
+ delete global[utils.WPrefix][self.id];
self.dispatchEvent(new SimpleEvent('close', {reason: abortReason}));
};
iframeObj = constructor(url, function() {
diff --git a/lib/transport/sender/jsonp.js b/lib/transport/sender/jsonp.js
index f178f5d..0484526 100644
--- a/lib/transport/sender/jsonp.js
+++ b/lib/transport/sender/jsonp.js
@@ -4,12 +4,12 @@ var random = require('../../utils/random')
;
module.exports = function (url, payload, callback) {
- var form = window._sendForm;
- var area = window._sendArea;
+ var form = global._sendForm;
+ var area = global._sendArea;
if (!form) {
- form = window._sendForm = document.createElement('form');
- area = window._sendArea = document.createElement('textarea');
+ form = global._sendForm = global.document.createElement('form');
+ area = global._sendArea = global.document.createElement('textarea');
area.name = 'd';
form.style.display = 'none';
form.style.position = 'absolute';
@@ -17,7 +17,7 @@ module.exports = function (url, payload, callback) {
form.enctype = 'application/x-www-form-urlencoded';
form.acceptCharset = 'UTF-8';
form.appendChild(area);
- document.body.appendChild(form);
+ global.document.body.appendChild(form);
}
var id = 'a' + random.string(8);
form.target = id;
@@ -26,9 +26,9 @@ module.exports = function (url, payload, callback) {
var iframe;
try {
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
- iframe = document.createElement('<iframe name="' + id + '">');
+ iframe = global.document.createElement('<iframe name="' + id + '">');
} catch(x) {
- iframe = document.createElement('iframe');
+ iframe = global.document.createElement('iframe');
iframe.name = id;
}
iframe.id = id;
diff --git a/lib/utils/iframe.js b/lib/utils/iframe.js
index 28eaeb8..0ab1f7d 100644
--- a/lib/utils/iframe.js
+++ b/lib/utils/iframe.js
@@ -1,5 +1,7 @@
'use strict';
+var eventUtils = require('./event');
+
module.exports = {
WPrefix: '_jp'
@@ -10,7 +12,7 @@ module.exports = {
}
, createIframe: function (iframeUrl, errorCallback) {
- var iframe = document.createElement('iframe');
+ var iframe = global.document.createElement('iframe');
var tref, unloadRef;
var unattach = function() {
clearTimeout(tref);
@@ -30,7 +32,7 @@ module.exports = {
}
iframe = null;
}, 0);
- utils.unloadDel(unloadRef);
+ eventUtils.unloadDel(unloadRef);
}
};
var onerror = function(r) {
@@ -61,9 +63,9 @@ module.exports = {
clearTimeout(tref);
tref = setTimeout(function(){onerror('onload timeout');}, 2000);
};
- document.body.appendChild(iframe);
+ global.document.body.appendChild(iframe);
tref = setTimeout(function(){onerror('timeout');}, 15000);
- unloadRef = utils.unloadAdd(cleanup);
+ unloadRef = eventUtils.unloadAdd(cleanup);
return {
post: post,
cleanup: cleanup,
@@ -72,7 +74,7 @@ module.exports = {
}
/* jshint undef: false, newcap: false */
-/* eslint no-undef: [0], new-cap: [0] */
+/* eslint no-undef: 0, new-cap: 0 */
, createHtmlfile: function (iframeUrl, errorCallback) {
var doc = new ActiveXObject('htmlfile');
var tref, unloadRef;
@@ -83,7 +85,7 @@ module.exports = {
var cleanup = function() {
if (doc) {
unattach();
- utils.unloadDel(unloadRef);
+ eventUtils.unloadDel(unloadRef);
iframe.parentNode.removeChild(iframe);
iframe = doc = null;
CollectGarbage();
@@ -112,14 +114,14 @@ module.exports = {
'document.domain="' + document.domain + '";' +
'</s' + 'cript></html>');
doc.close();
- doc.parentWindow[utils.WPrefix] = window[utils.WPrefix];
+ doc.parentWindow[this.WPrefix] = global[this.WPrefix];
var c = doc.createElement('div');
doc.body.appendChild(c);
iframe = doc.createElement('iframe');
c.appendChild(iframe);
iframe.src = iframeUrl;
tref = setTimeout(function(){onerror('timeout');}, 15000);
- unloadRef = utils.unloadAdd(cleanup);
+ unloadRef = eventUtils.unloadAdd(cleanup);
return {
post: post,
cleanup: cleanup,
--
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