diff --git a/lib/internal/streams/next-tick-browser.js b/lib/internal/streams/next-tick-browser.js index edf3e7aba8..23abcad79c 100644 --- a/lib/internal/streams/next-tick-browser.js +++ b/lib/internal/streams/next-tick-browser.js @@ -10,14 +10,20 @@ module.exports = function (cb) { // Base on https://github.com/feross/queue-microtask/blob/master/index.js by feross if(typeof queueMicrotask === 'function') { - queueMicrotask(()=>{ + queueMicrotask(function () { cb.apply(null, args) }); - } else { + } else if (global.Promise !== undefined) { Promise.resolve() - .then(() => { - cb.apply(null, args) + .then(function () { + cb.apply(null, args); }) - .catch(err => setTimeout(() => { throw err }, 0)) + .catch(function (err) { + setTimeout(function () { throw err }, 0); + }); + } else { + setTimeout(function () { + cb.apply(null, args); + }, 0); } }; \ No newline at end of file