Skip to content

Commit 1ebe1b0

Browse files
committed
runtime(js): refactor caml_xmlhttprequest_create
Signed-off-by: Sora Morimoto <[email protected]>
1 parent b6f5674 commit 1ebe1b0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

runtime/js/jslib_js_of_ocaml.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ function caml_js_get_console() {
7272
//Requires: caml_failwith
7373
//Weakdef
7474
function caml_xmlhttprequest_create(unit) {
75-
if (typeof globalThis.XMLHttpRequest !== "undefined") {
76-
try {
77-
return new globalThis.XMLHttpRequest();
78-
} catch (e) {}
75+
try {
76+
return new globalThis.XMLHttpRequest();
77+
} catch {
78+
caml_failwith("Cannot create a XMLHttpRequest");
7979
}
80-
caml_failwith("Cannot create a XMLHttpRequest");
8180
}
8281

8382
//Provides: caml_js_error_of_exception

0 commit comments

Comments
 (0)