Files
socket.io/lib/xmlhttprequest.js
Diga Widyaprana a526395363 Add inline eslint config
- ActiveXObject global in lib/xmlhttprequest.js
- Allow small letter constructor in test/transport.js
2016-03-01 00:41:09 +08:00

41 lines
1.2 KiB
JavaScript

// browser shim for xmlhttprequest module
// Indicate to eslint that ActiveXObject is global
/* global ActiveXObject */
var hasCORS = require('has-cors');
module.exports = function (opts) {
var xdomain = opts.xdomain;
// scheme must be same when usign XDomainRequest
// http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
var xscheme = opts.xscheme;
// XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
// https://github.com/Automattic/engine.io-client/pull/217
var enablesXDR = opts.enablesXDR;
// XMLHttpRequest can be disabled on IE
try {
if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
return new XMLHttpRequest();
}
} catch (e) { }
// Use XDomainRequest for IE8 if enablesXDR is true
// because loading bar keeps flashing when using jsonp-polling
// https://github.com/yujiosaka/socke.io-ie8-loading-example
try {
if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
return new XDomainRequest();
}
} catch (e) { }
if (!xdomain) {
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) { }
}
};