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

Remove IE specific hacks #477

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
22 changes: 0 additions & 22 deletions src/fake-timers-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@

/**
* @typedef RequestAnimationFrame
* @property {function(number):void} requestAnimationFrame

Check warning on line 50 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @Property "requestAnimationFrame" description
* @returns {number} - the id
*/

/**
* @typedef Performance
* @property {function(): number} now

Check warning on line 56 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @Property "now" description
*/

/* eslint-disable jsdoc/require-property-description */
Expand Down Expand Up @@ -143,8 +143,6 @@
* @returns {FakeTimers}
*/
function withGlobal(_global) {
const userAgent = _global.navigator && _global.navigator.userAgent;
const isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1;
const maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint
const idCounterStart = 1e12; // arbitrarily large number to avoid collisions with native timer IDs
const NOOP = function () {
Expand Down Expand Up @@ -188,26 +186,6 @@
_global.setImmediate && typeof _global.setImmediate === "function";
const intlPresent = _global.Intl && typeof _global.Intl === "object";

// Make properties writable in IE, as per
// https://www.adequatelygood.com/Replacing-setTimeout-Globally.html
/* eslint-disable no-self-assign */
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
if (setImmediatePresent) {
_global.setImmediate = _global.setImmediate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node actually has setImmediate as well

Copy link
Contributor Author

@fatso83 fatso83 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, not removing that. Just the IE (IE 8 and below) specific x=x hack/workaround to make the prop writable. See https://www.adequatelygood.com/Replacing-setTimeout-Globally.html

setImmediate is still added to the timers way below (line 1032)

_global.clearImmediate = _global.clearImmediate;
}

/* eslint-enable no-self-assign */

_global.clearTimeout(timeoutResult);

const NativeDate = _global.Date;
Expand Down Expand Up @@ -329,7 +307,7 @@
return timer && timer.callAt >= from && timer.callAt <= to;
}

/**

Check warning on line 310 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns declaration
* @param {Clock} clock
* @param {Timer} job
*/
Expand Down Expand Up @@ -665,7 +643,7 @@
}

/* eslint consistent-return: "off" */
/**

Check warning on line 646 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

JSDoc @returns declaration present but return expression not available in function
* Timer comparitor
*
* @param {Timer} a
Expand Down Expand Up @@ -797,7 +775,7 @@
}
}

/**

Check warning on line 778 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns declaration
* Gets clear handler name for a given timer type
*
* @param {string} ttype
Expand All @@ -809,7 +787,7 @@
return `clear${ttype}`;
}

/**

Check warning on line 790 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns declaration
* Gets schedule handler name for a given timer type
*
* @param {string} ttype
Expand All @@ -821,7 +799,7 @@
return `set${ttype}`;
}

/**

Check warning on line 802 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns declaration
* Creates an anonymous function to warn only once
*/
function createWarnOnce() {
Expand All @@ -833,7 +811,7 @@
}
const warnOnce = createWarnOnce();

/**

Check warning on line 814 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns declaration
* @param {Clock} clock
* @param {number} timerId
* @param {string} ttype
Expand Down Expand Up @@ -1022,8 +1000,8 @@

/**
* @typedef {object} Timers
* @property {setTimeout} setTimeout

Check warning on line 1003 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @Property "setTimeout" description
* @property {clearTimeout} clearTimeout

Check warning on line 1004 in src/fake-timers-src.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @Property "clearTimeout" description
* @property {setInterval} setInterval
* @property {clearInterval} clearInterval
* @property {Date} Date
Expand Down