Skip to content
Closed
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ module.exports = {

globals: {
SharedArrayBuffer: true,
globalThis: true,

spyOnDev: true,
spyOnDevAndProd: true,
Expand Down
15 changes: 10 additions & 5 deletions packages/scheduler/src/forks/SchedulerDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,22 @@ var isPerformingWork = false;
var isHostCallbackScheduled = false;
var isHostTimeoutScheduled = false;

// Web Workers can't access window.
// Many browsers provide a globalThis property for this reason.
// For legacy reasons (mostly unit tests) this code prefers window if defined.
const globalObject = typeof window !== 'undefined' ? window : globalThis;

// Capture local references to native APIs, in case a polyfill overrides them.
const setTimeout = window.setTimeout;
const clearTimeout = window.clearTimeout;
const setImmediate = window.setImmediate; // IE and Node.js + jsdom
const setTimeout = globalObject.setTimeout;
const clearTimeout = globalObject.clearTimeout;
const setImmediate = globalObject.setImmediate; // IE and Node.js + jsdom

if (typeof console !== 'undefined') {
// TODO: Scheduler no longer requires these methods to be polyfilled. But
// maybe we want to continue warning if they don't exist, to preserve the
// option to rely on it in the future?
const requestAnimationFrame = window.requestAnimationFrame;
const cancelAnimationFrame = window.cancelAnimationFrame;
const requestAnimationFrame = globalObject.requestAnimationFrame;
const cancelAnimationFrame = globalObject.cancelAnimationFrame;

if (typeof requestAnimationFrame !== 'function') {
// Using console['error'] to evade Babel and ESLint
Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/validate/eslintrc.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
SharedArrayBuffer: true,
Int32Array: true,
ArrayBuffer: true,
globalThis: true,

TaskController: true,

Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/validate/eslintrc.cjs2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
SharedArrayBuffer: true,
Int32Array: true,
ArrayBuffer: true,
globalThis: true,

TaskController: true,

Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/validate/eslintrc.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
SharedArrayBuffer: true,
Int32Array: true,
ArrayBuffer: true,
globalThis: true,

TaskController: true,

Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/validate/eslintrc.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
SharedArrayBuffer: true,
Int32Array: true,
ArrayBuffer: true,
globalThis: true,

TaskController: true,

Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/validate/eslintrc.rn.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
SharedArrayBuffer: true,
Int32Array: true,
ArrayBuffer: true,
globalThis: true,

TaskController: true,

Expand Down