From 719c224fb23ebeffbcec9f02e36bbd22138f2263 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 6 Jan 2016 17:11:42 +0100 Subject: [PATCH] Increase compatiblity with sinon.useFakeTimers() By caching reference to the global setImmediate and setTimeout we can ensure that promise-polyfill still works as excpected when sinon.useFakeTimers() replaces them with fake versions. --- Promise.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Promise.js b/Promise.js index 47453e5..5a82a56 100644 --- a/Promise.js +++ b/Promise.js @@ -1,4 +1,7 @@ (function(root) { + // Store setTimeout reference so promise-polyfill will be unaffected by + // other code modifying setTimeout (like sinon.useFakeTimers()) + var setTimeout = setTimeout; // Use polyfill for setImmediate for performance gains var asap = (typeof setImmediate === 'function' && setImmediate) || @@ -187,4 +190,4 @@ root.Promise = Promise; } -})(this); \ No newline at end of file +})(this);