diff --git a/lolex.js b/lolex.js index b49929af..16eb0b03 100644 --- a/lolex.js +++ b/lolex.js @@ -1,23 +1,20 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lolex = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o -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 @@ -175,7 +172,7 @@ timer.id = uniqueTimerId++; timer.createdAt = clock.now; - timer.callAt = clock.now + (timer.delay || (clock.duringTick ? 1 : 0)); + timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0)); clock.timers[timer.id] = timer; diff --git a/package.json b/package.json index 20c7d546..0c0caf7d 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "prepublish": "npm run bundle" }, "devDependencies": { - "eslint": "^3.0.1", "browserify": "^13.0.1", - "mocha": "^2.5.3", + "eslint": "^3.0.1", + "mocha": "^3.1.2", "mochify": "^2.18.0", "referee": "^1.2.0", "sinon": "^1.17.4" diff --git a/src/lolex-src.js b/src/lolex-src.js index 8ee5b341..6fe865cf 100644 --- a/src/lolex-src.js +++ b/src/lolex-src.js @@ -1,21 +1,18 @@ -/*global global, window*/ -/** - * @author Christian Johansen (christian@cjohansen.no) and contributors - * @license BSD - * - * Copyright (c) 2010-2014 Christian Johansen - */ - (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