Files
material-ui/test/setupAnimationEvent.ts
code-infra-renovate[bot]andZeeshanTamboli 0a0a94ab0f Bump MUI infra packages (#49298)
Co-authored-by: code-infra-renovate[bot] <290386390+code-infra-renovate[bot]@users.noreply.github.com>
Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
2026-10-06 05:47:34 +00:00

22 lines
807 B
TypeScript

// jsdom has no `AnimationEvent`, and jsdom 29+ exposes `WebkitAnimation` on
// `CSSStyleDeclaration`. React reads both to pick an event name, so it listens for
// `webkitAnimationStart` and plain `animationstart` never reaches `onAnimationStart`.
if (typeof globalThis.AnimationEvent === 'undefined') {
class AnimationEventPolyfill extends Event implements AnimationEvent {
declare animationName: string;
declare elapsedTime: number;
declare pseudoElement: string;
constructor(type: string, options: AnimationEventInit = {}) {
super(type, options);
this.animationName = options.animationName ?? '';
this.elapsedTime = options.elapsedTime ?? 0;
this.pseudoElement = options.pseudoElement ?? '';
}
}
globalThis.AnimationEvent = AnimationEventPolyfill;
}