mirror of
https://github.com/facebook/react.git
synced 2026-02-25 23:15:04 +00:00
* Remove rAF fork **what is the change?:** Undid https://github.com/facebook/react/pull/12837 **why make this change?:** We originally forked rAF because we needed to pull in a particular version of rAF internally at Facebook, to avoid grabbing the default polyfilled version. The longer term solution, until we can get rid of the global polyfill behavior, is to initialize 'schedule' before the polyfilling happens. Now that we have landed and synced https://github.com/facebook/react/pull/12900 successfully, we can initialize 'schedule' before the polyfill runs. So we can remove the rAF fork. Here is how it will work: 1. Land this PR on Github. 2. Flarnie will quickly run a sync getting this change into www. 3. We delete the internal forked version of 'requestAnimationFrameForReact'. 4. We require 'schedule' in the polyfill file itself, before the polyfilling happens. **test plan:** Flarnie will manually try the above steps locally and verify that things work. **issue:** Internal task T29442940 * fix nits * fix tests, fix changes from rebasing * fix lint
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @emails react-core
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
describe('ReactDOMFrameScheduling', () => {
|
|
it('warns when requestAnimationFrame is not polyfilled in the browser', () => {
|
|
const previousRAF = global.requestAnimationFrame;
|
|
try {
|
|
global.requestAnimationFrame = undefined;
|
|
jest.resetModules();
|
|
expect(() => require('react-dom')).toWarnDev(
|
|
"This browser doesn't support requestAnimationFrame.",
|
|
);
|
|
} finally {
|
|
global.requestAnimationFrame = previousRAF;
|
|
}
|
|
});
|
|
|
|
// We're just testing importing, not using it.
|
|
// It is important because even isomorphic components may import it.
|
|
it('can import findDOMNode in Node environment', () => {
|
|
const previousRAF = global.requestAnimationFrame;
|
|
const previousRIC = global.requestIdleCallback;
|
|
const prevWindow = global.window;
|
|
try {
|
|
global.requestAnimationFrame = undefined;
|
|
global.requestIdleCallback = undefined;
|
|
// Simulate the Node environment:
|
|
delete global.window;
|
|
jest.resetModules();
|
|
expect(() => {
|
|
require('react-dom');
|
|
}).not.toThrow();
|
|
} finally {
|
|
global.requestAnimationFrame = previousRAF;
|
|
global.requestIdleCallback = previousRIC;
|
|
global.window = prevWindow;
|
|
}
|
|
});
|
|
});
|