mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
Merge pull request #3583 from madcodelife/main
Fix 'Hover Provider Example' incorrect Promise syntax
This commit is contained in:
commit
3b800d8192
1 changed files with 25 additions and 28 deletions
|
|
@ -31,35 +31,32 @@ monaco.editor.create(document.getElementById("container"), {
|
||||||
|
|
||||||
function xhr(url) {
|
function xhr(url) {
|
||||||
var req = null;
|
var req = null;
|
||||||
return new Promise(
|
return new Promise(function (c, e) {
|
||||||
function (c, e) {
|
req = new XMLHttpRequest();
|
||||||
req = new XMLHttpRequest();
|
req.onreadystatechange = function () {
|
||||||
req.onreadystatechange = function () {
|
if (req._canceled) {
|
||||||
if (req._canceled) {
|
return;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if (req.readyState === 4) {
|
||||||
|
if (
|
||||||
|
(req.status >= 200 && req.status < 300) ||
|
||||||
|
req.status === 1223
|
||||||
|
) {
|
||||||
|
c(req);
|
||||||
|
} else {
|
||||||
|
e(req);
|
||||||
}
|
}
|
||||||
|
req.onreadystatechange = function () {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (req.readyState === 4) {
|
req.open("GET", url, true);
|
||||||
if (
|
req.responseType = "";
|
||||||
(req.status >= 200 && req.status < 300) ||
|
|
||||||
req.status === 1223
|
|
||||||
) {
|
|
||||||
c(req);
|
|
||||||
} else {
|
|
||||||
e(req);
|
|
||||||
}
|
|
||||||
req.onreadystatechange = function () {};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
req.open("GET", url, true);
|
req.send(null);
|
||||||
req.responseType = "";
|
}).catch(function () {
|
||||||
|
req._canceled = true;
|
||||||
req.send(null);
|
req.abort();
|
||||||
},
|
});
|
||||||
function () {
|
|
||||||
req._canceled = true;
|
|
||||||
req.abort();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue