Skip to content

[core] Deprecate ponyfillGlobal #45606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/mui-styles/src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* eslint-disable import/export */
import { ponyfillGlobal } from '@mui/utils';

/* Warning if there are several instances of @mui/styles */
if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test' &&
typeof window !== 'undefined'
) {
ponyfillGlobal['__@mui/styles-init__'] = ponyfillGlobal['__@mui/styles-init__'] || 0;
globalThis['__@mui/styles-init__'] = globalThis['__@mui/styles-init__'] || 0;

if (ponyfillGlobal['__@mui/styles-init__'] === 1) {
if (globalThis['__@mui/styles-init__'] === 1) {
console.warn(
[
'It looks like there are several instances of `@mui/styles` initialized in this application.',
Expand All @@ -21,7 +20,7 @@ if (
);
}

ponyfillGlobal['__@mui/styles-init__'] += 1;
globalThis['__@mui/styles-init__'] += 1;
}

export { default as createGenerateClassName } from './createGenerateClassName';
Expand Down
5 changes: 4 additions & 1 deletion packages/mui-utils/src/ponyfillGlobal/ponyfillGlobal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint-disable */
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
/**
* https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
* @deprecated Use `globalThis` instead.
*/
export default typeof window != 'undefined' && window.Math == Math
? window
: typeof self != 'undefined' && self.Math == Math
Expand Down