diff --git a/lolex.js b/lolex.js index dca19f4d..66fc9d69 100644 --- a/lolex.js +++ b/lolex.js @@ -3,13 +3,18 @@ (function (global) { "use strict"; + var userAgent = global.navigator && global.navigator.userAgent; + var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; + // Make properties writable in IE, as per // http://www.adequatelygood.com/Replacing-setTimeout-Globally.html - global.setTimeout = global.setTimeout; - global.clearTimeout = global.clearTimeout; - global.setInterval = global.setInterval; - global.clearInterval = global.clearInterval; - global.Date = global.Date; + if (isRunningInIE) { + global.setTimeout = global.setTimeout; + global.clearTimeout = global.clearTimeout; + global.setInterval = global.setInterval; + global.clearInterval = global.clearInterval; + global.Date = global.Date; + } // setImmediate is not a standard function // avoid adding the prop to the window object if not present diff --git a/src/lolex-src.js b/src/lolex-src.js index e8fd3a34..631823da 100644 --- a/src/lolex-src.js +++ b/src/lolex-src.js @@ -1,13 +1,18 @@ (function (global) { "use strict"; + var userAgent = global.navigator && global.navigator.userAgent; + var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; + // Make properties writable in IE, as per // http://www.adequatelygood.com/Replacing-setTimeout-Globally.html - global.setTimeout = global.setTimeout; - global.clearTimeout = global.clearTimeout; - global.setInterval = global.setInterval; - global.clearInterval = global.clearInterval; - global.Date = global.Date; + if (isRunningInIE) { + global.setTimeout = global.setTimeout; + global.clearTimeout = global.clearTimeout; + global.setInterval = global.setInterval; + global.clearInterval = global.clearInterval; + global.Date = global.Date; + } // setImmediate is not a standard function // avoid adding the prop to the window object if not present