mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Default export of globalThis seems to have a problem in the "browser" field when the library is loaded asynchronously with webpack.
24 lines
563 B
TypeScript
24 lines
563 B
TypeScript
// browser shim for xmlhttprequest module
|
|
|
|
import { hasCORS } from "./contrib/has-cors.js";
|
|
import { globalThisShim as globalThis } from "./globalThis.js";
|
|
|
|
export default function(opts) {
|
|
const xdomain = opts.xdomain;
|
|
|
|
// XMLHttpRequest can be disabled on IE
|
|
try {
|
|
if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
|
return new XMLHttpRequest();
|
|
}
|
|
} catch (e) {}
|
|
|
|
if (!xdomain) {
|
|
try {
|
|
return new globalThis[["Active"].concat("Object").join("X")](
|
|
"Microsoft.XMLHTTP"
|
|
);
|
|
} catch (e) {}
|
|
}
|
|
}
|