-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-motion): Add guard to check if globals can be used (#31907)
- Loading branch information
1 parent
0777a2f
commit 0ad7f7c
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-motion-f6019e1f-96a3-4d91-b14a-5263e24433f4.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix: Check if DOM is available before using Element global to avoid breaks in build.", | ||
"packageName": "@fluentui/react-motion", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/react-components/react-motion/library/src/hooks/useAnimateAtoms-node.test.tsx
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,17 @@ | ||
/* | ||
* @jest-environment node | ||
*/ | ||
|
||
// 👆 this is intentionally to test in SSR like environment | ||
|
||
describe('useAnimateAtoms (node)', () => { | ||
it('handles node/server environments', () => { | ||
const win = typeof document === 'object' ? document.defaultView?.window : undefined; | ||
const SUPPORTS_WEB_ANIMATIONS = win && typeof win.Element.prototype.animate === 'function'; | ||
|
||
expect(win).toBe(undefined); | ||
expect(SUPPORTS_WEB_ANIMATIONS).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
export {}; |
5 changes: 4 additions & 1 deletion
5
packages/react-components/react-motion/library/src/hooks/useAnimateAtoms.ts
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