Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sinonjs/sinon#1143: Only overwrite globals when running in IE #87

Merged
merged 4 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions lolex.js
Original file line number Diff line number Diff line change
@@ -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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global){
/*global global, window*/
/**
* @author Christian Johansen ([email protected]) 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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 10 additions & 13 deletions src/lolex-src.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
/*global global, window*/
/**
* @author Christian Johansen ([email protected]) 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
Expand Down