Skip to content

Commit bbe22d2

Browse files
committed
ensure Element is available before polyfilling
1 parent 5ca68a9 commit bbe22d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/@headlessui-react/src/hooks/use-transition.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { useIsoMorphicEffect } from './use-iso-morphic-effect'
77
if (
88
typeof process !== 'undefined' &&
99
typeof globalThis !== 'undefined' &&
10+
typeof Element !== 'undefined' &&
1011
// Strange string concatenation is on purpose to prevent `esbuild` from
1112
// replacing `process.env.NODE_ENV` with `production` in the build output,
1213
// eliminating this whole branch.
1314
process?.env?.['NODE' + '_' + 'ENV'] === 'test'
1415
) {
15-
if (typeof Element.prototype.getAnimations === 'undefined') {
16+
if (typeof Element?.prototype?.getAnimations === 'undefined') {
1617
Element.prototype.getAnimations = function getAnimationsPolyfill() {
1718
console.warn(
1819
[

0 commit comments

Comments
 (0)