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

Rename variables to remove references to 'global' global #12931

Merged
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
14 changes: 7 additions & 7 deletions packages/react-scheduler/src/ReactScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated.
// We want to be using a consistent implementation.
const Date = global.Date;
const setTimeout = global.setTimeout;
const clearTimeout = global.clearTimeout;
const localDate = Date;
const localSetTimeout = setTimeout;
const localClearTimeout = clearTimeout;

const hasNativePerformanceNow =
typeof performance === 'object' && typeof performance.now === 'function';
Expand All @@ -62,7 +62,7 @@ if (hasNativePerformanceNow) {
};
} else {
now = function() {
return Date.now();
return localDate.now();
};
}

Expand All @@ -86,7 +86,7 @@ if (!ExecutionEnvironment.canUseDOM) {
next: null,
prev: null,
};
const timeoutId = setTimeout(() => {
const timeoutId = localSetTimeout(() => {
callback({
timeRemaining() {
return Infinity;
Expand All @@ -101,7 +101,7 @@ if (!ExecutionEnvironment.canUseDOM) {
const callback = callbackId.scheduledCallback;
const timeoutId = timeoutIds.get(callback);
timeoutIds.delete(callbackId);
clearTimeout(timeoutId);
localClearTimeout(timeoutId);
};
} else {
let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
Expand Down Expand Up @@ -232,7 +232,7 @@ if (!ExecutionEnvironment.canUseDOM) {
};
// Assumes that we have addEventListener in this environment. Might need
// something better for old IE.
global.addEventListener('message', idleTick, false);
window.addEventListener('message', idleTick, false);

const animationTick = function(rafTime) {
isAnimationFrameScheduled = false;
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/requestAnimationFrameForReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import warning from 'fbjs/lib/warning';
// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated.
// We want to be using a consistent implementation.
const requestAnimationFrame = global.requestAnimationFrame;
const localRequestAnimationFrame = requestAnimationFrame;

if (__DEV__) {
if (
ExecutionEnvironment.canUseDOM &&
typeof requestAnimationFrame !== 'function'
typeof localRequestAnimationFrame !== 'function'
) {
warning(
false,
Expand All @@ -30,4 +30,4 @@ if (__DEV__) {
}
}

export default requestAnimationFrame;
export default localRequestAnimationFrame;