Skip to main content
react-md

Polyfills

All the polyfills are included by default when following the quickstart guide. This page is mostly for informational purposes only.

By importing the @react-md/core/test-utils/polyfills, all the following polyfills will be applied. You can also manually import the specific polyfills instead.

matchMedia

import "@react-md/core/test-utils/polyfills/matchMedia";

This updates window.matchMedia to default to desktop when typeof window.matchMedia === "undefined".

ResizeObserver

import "@react-md/core/test-utils/polyfills/ResizeObserver";

This sets the window.ResizeObserver to the ResizeObserverMock when it is undefined. See the ResizeObserverMock for more details.

IntersectionObserver

import "@react-md/core/test-utils/polyfills/IntersectionObserver";

This sets the window.IntersectionObserver to the IntersectionObserverMock when it is undefined. See the IntersectionObserverMock for more details.

TextEncoder

import "@react-md/core/test-utils/polyfills/TextEncoder";

This sets the global.TextEncoder to node:util TextEncoder when it is undefined.

TextDecoder

import "@react-md/core/test-utils/polyfills/TextDecoder";

This sets the global.TextDecoder to node:util TextDecoder when it is undefined.

offsetParent

import "@react-md/core/test-utils/polyfills/offsetParent";

This polyfill was added for the tree keyboard movement behavior since offsetParent might return the incorrect value in jsdom.

scrollIntoView

import "@react-md/core/test-utils/polyfills/scrollIntoView";

This polyfill adds no-op behavior to the HTMLElement.prototype.scrollIntoView if it is undefined.