Use native promises (fixes microsoft/monaco-editor#1766)

This commit is contained in:
Alexandru Dima 2020-01-15 16:44:09 +01:00
parent 2ed113477e
commit 71bbf3f7a5
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0

View file

@ -16,7 +16,7 @@
require(['vs/editor/editor.main'], function() { require(['vs/editor/editor.main'], function() {
var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container')); var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
monaco.Promise.join([xhr('original.txt'), xhr('modified.txt')]).then(function(r) { Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function(r) {
var originalTxt = r[0].responseText; var originalTxt = r[0].responseText;
var modifiedTxt = r[1].responseText; var modifiedTxt = r[1].responseText;
@ -30,7 +30,7 @@
<script> <script>
function xhr(url) { function xhr(url) {
var req = null; var req = null;
return new monaco.Promise(function(c,e,p) { return new Promise(function(c,e) {
req = new XMLHttpRequest(); req = new XMLHttpRequest();
req.onreadystatechange = function () { req.onreadystatechange = function () {
if (req._canceled) { return; } if (req._canceled) { return; }
@ -42,8 +42,6 @@
e(req); e(req);
} }
req.onreadystatechange = function () { }; req.onreadystatechange = function () { };
} else {
p(req);
} }
}; };