forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes facebook#9102 by fake polyfilling rAF (and rIC)
- Loading branch information
1 parent
d12c41c
commit 0729812
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/renderers/shared/__tests__/ReactDOMFrameScheduling-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); | ||
const describeFiber = ReactDOMFeatureFlags.useFiber ? describe : xdescribe; | ||
|
||
describeFiber('ReactDOMFrameScheduling', () => { | ||
it('throws when requestAnimationFrame is not polyfilled in the browser.', () => { | ||
const previousRAF = global.requestAnimationFrame; | ||
global.requestAnimationFrame = undefined; | ||
jest.resetModules(); | ||
expect(() => { | ||
require('ReactDOM'); | ||
}).toThrow( | ||
'React depends on requestAnimationFrame. Make sure that you load a ' + | ||
'polyfill in older browsers.' | ||
); | ||
global.requestAnimationFrame = previousRAF; | ||
}); | ||
|
||
it('can import findDOMNode in Node environment.', () => { | ||
const previousRAF = global.requestAnimationFrame; | ||
const previousRIC = global.requestIdleCallback; | ||
global.requestAnimationFrame = undefined; | ||
global.requestIdleCallback = undefined; | ||
const prevWindow = global.window; | ||
delete global.window; | ||
jest.resetModules(); | ||
require('ReactDOM'); | ||
global.requestAnimationFrame = previousRAF; | ||
global.requestIdleCallback = previousRIC; | ||
global.window = prevWindow; | ||
}); | ||
}); |