Files
socket.io/lib/xmlhttprequest.ts
yujiosaka 32878ea047 fix: use named export for globalThis shim (#688)
Default export of globalThis seems to have a problem in the "browser"
field when the library is loaded asynchronously with webpack.
2022-05-02 09:47:16 +02:00

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) {}
}
}