mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove rAF fork (#12980)
* 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
This commit is contained in:
+1
-1
@@ -440,7 +440,7 @@ describe('ReactDOM', () => {
|
||||
global.requestAnimationFrame = undefined;
|
||||
jest.resetModules();
|
||||
expect(() => require('react-dom')).toWarnDev(
|
||||
'React depends on requestAnimationFrame.',
|
||||
"This browser doesn't support requestAnimationFrame.",
|
||||
);
|
||||
} finally {
|
||||
global.requestAnimationFrame = previousRAF;
|
||||
|
||||
+16
-22
@@ -41,11 +41,24 @@ type CallbackConfigType = {|
|
||||
|
||||
export type CallbackIdType = CallbackConfigType;
|
||||
|
||||
import requestAnimationFrameForReact from 'shared/requestAnimationFrameForReact';
|
||||
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
import warning from 'fbjs/lib/warning';
|
||||
|
||||
if (__DEV__) {
|
||||
if (
|
||||
ExecutionEnvironment.canUseDOM &&
|
||||
typeof requestAnimationFrame !== 'function'
|
||||
) {
|
||||
warning(
|
||||
false,
|
||||
// TODO: reword this when schedule is a stand-alone module
|
||||
"This browser doesn't support requestAnimationFrame. " +
|
||||
'Make sure that you load a ' +
|
||||
'polyfill in older browsers. https://fb.me/react-polyfills',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
@@ -106,26 +119,7 @@ if (!ExecutionEnvironment.canUseDOM) {
|
||||
localClearTimeout(timeoutId);
|
||||
};
|
||||
} else {
|
||||
if (__DEV__) {
|
||||
if (typeof requestAnimationFrameForReact !== 'function') {
|
||||
warning(
|
||||
false,
|
||||
'React depends on requestAnimationFrame. Make sure that you load a ' +
|
||||
'polyfill in older browsers. https://fb.me/react-polyfills',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let localRequestAnimationFrame =
|
||||
typeof requestAnimationFrameForReact === 'function'
|
||||
? requestAnimationFrameForReact
|
||||
: function(callback: Function) {
|
||||
invariant(
|
||||
false,
|
||||
'React depends on requestAnimationFrame. Make sure that you load a ' +
|
||||
'polyfill in older browsers. https://fb.me/react-polyfills',
|
||||
);
|
||||
};
|
||||
const localRequestAnimationFrame = requestAnimationFrame;
|
||||
|
||||
let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
|
||||
let tailOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('ReactDOMFrameScheduling', () => {
|
||||
global.requestAnimationFrame = undefined;
|
||||
jest.resetModules();
|
||||
expect(() => require('react-dom')).toWarnDev(
|
||||
'React depends on requestAnimationFrame.',
|
||||
"This browser doesn't support requestAnimationFrame.",
|
||||
);
|
||||
} finally {
|
||||
global.requestAnimationFrame = previousRAF;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2013-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export default require('requestAnimationFrameForReact');
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2013-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.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// 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 localRequestAnimationFrame =
|
||||
typeof requestAnimationFrame === 'function'
|
||||
? requestAnimationFrame
|
||||
: undefined;
|
||||
|
||||
// The callsites should check if the requestAnimationFrame imported from this module is a function,
|
||||
// fire a developer warning if it doesn't exist, and substitute it by a shim in that case
|
||||
// (e.g. that throws on call).
|
||||
|
||||
export default localRequestAnimationFrame;
|
||||
@@ -81,18 +81,6 @@ const forks = Object.freeze({
|
||||
return null;
|
||||
},
|
||||
|
||||
// This logic is forked on www to use the 'acrossTransitions' version.
|
||||
// This will be removed soon, see internal task T29442940
|
||||
'shared/requestAnimationFrameForReact': (bundleType, entry) => {
|
||||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
return 'shared/forks/requestAnimationFrameForReact.www.js';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
'shared/ReactScheduler': (bundleType, entry) => {
|
||||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
|
||||
Reference in New Issue
Block a user