mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
This commit allows to: - provide an ESM version of those modules ([1]) - reduce the attack surface in case of supply chain attacks - reduce the size of the bundle with tree-shaking As a downside, we won't receive security updates for those modules anymore. [1]: https://github.com/socketio/socket.io-client/issues/1536
24 lines
541 B
TypeScript
24 lines
541 B
TypeScript
// browser shim for xmlhttprequest module
|
|
|
|
import { hasCORS } from "./contrib/has-cors.js";
|
|
import 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) {}
|
|
}
|
|
}
|