xmlhttprequest.browser.js 560 B

12345678910111213141516171819
  1. // browser shim for xmlhttprequest module
  2. import hasCORS from "has-cors";
  3. import globalThis from "../globalThis.js";
  4. export default function (opts) {
  5. const xdomain = opts.xdomain;
  6. // XMLHttpRequest can be disabled on IE
  7. try {
  8. if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
  9. return new XMLHttpRequest();
  10. }
  11. }
  12. catch (e) { }
  13. if (!xdomain) {
  14. try {
  15. return new globalThis[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
  16. }
  17. catch (e) { }
  18. }
  19. }