From 608f9889a5a96503e47dab91b8ad136a174a7a8e Mon Sep 17 00:00:00 2001 From: valtron Date: Wed, 21 Dec 2016 23:34:44 -0700 Subject: [PATCH] Fix #1489: PromisePolyfill always overwrites `window.Promise` --- promise/promise.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/promise/promise.js b/promise/promise.js index f24766d1..53aefecc 100644 --- a/promise/promise.js +++ b/promise/promise.js @@ -95,9 +95,12 @@ PromisePolyfill.race = function(list) { }) } -if (typeof Promise === "undefined") { - if (typeof window !== "undefined") window.Promise = PromisePolyfill - else if (typeof global !== "undefined") global.Promise = PromisePolyfill +if (typeof window !== "undefined") { + if (typeof window.Promise === "undefined") window.Promise = PromisePolyfill + module.exports = window.Promise +} else if (typeof global !== "undefined") { + if (typeof global.Promise === "undefined") global.Promise = PromisePolyfill + module.exports = global.Promise +} else { + module.exports = PromisePolyfill } - -module.exports = typeof Promise !== "undefined" ? Promise : PromisePolyfill \ No newline at end of file