Skip to content
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

[core] Begin removing IE 11-related code #41709

Merged
merged 9 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
60 changes: 0 additions & 60 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,66 +72,6 @@ safari 15.4
samsung 23
samsung 22

[legacy]
ie 11
and_chr 122
and_chr 121
and_ff 123
and_ff 122
and_qq 14.9
and_uc 15.5
android 122
android 121
chrome 122
chrome 121
chrome 120
chrome 119
chrome 109
edge 122
edge 121
firefox 123
firefox 122
firefox 115
ios_saf 17.4
ios_saf 17.3
ios_saf 17.2
ios_saf 17.1
ios_saf 17.0
ios_saf 16.6-16.7
ios_saf 16.5
ios_saf 16.4
ios_saf 16.3
ios_saf 16.2
ios_saf 16.1
ios_saf 16.0
ios_saf 15.6-15.8
ios_saf 15.5
ios_saf 15.4
kaios 3.0-3.1
kaios 2.5
op_mini all
op_mob 80
opera 108
opera 107
opera 106
safari 17.4
safari 17.3
safari 17.2
safari 17.1
safari 17.0
safari 16.6
safari 16.5
safari 16.4
safari 16.3
safari 16.2
safari 16.1
safari 16.0
safari 15.6
safari 15.5
safari 15.4
samsung 23
samsung 22

# snapshot of `npx browserslist "maintained node versions"`
# On update check all #stable-snapshot markers
[node]
Expand Down
8 changes: 1 addition & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const productionPlugins = [
];

module.exports = function getBabelConfig(api) {
const useESModules = api.env(['regressions', 'legacy', 'modern', 'stable', 'rollup']);
const useESModules = api.env(['regressions', 'modern', 'stable', 'rollup']);

const defaultAlias = {
'@mui/material': resolveAliasPath('./packages/mui-material/src'),
Expand Down Expand Up @@ -153,12 +153,6 @@ module.exports = function getBabelConfig(api) {
],
],
},
legacy: {
plugins: [
// IE11 support
'@babel/plugin-transform-object-assign',
],
},
test: {
sourceMaps: 'both',
plugins: [
Expand Down
2 changes: 0 additions & 2 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ module.exports = {
},
],
'babel-plugin-optimize-clsx',
// for IE11 support
'@babel/plugin-transform-object-assign',
],
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
Expand Down
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/plugin-transform-object-assign": "^7.24.1",
"@babel/runtime": "^7.24.4",
"@babel/runtime-corejs2": "^7.24.1",
"@docsearch/react": "^3.6.0",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-object-assign": "^7.24.1",
"@babel/plugin-transform-react-constant-elements": "^7.24.1",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.4",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
24 changes: 5 additions & 19 deletions packages/mui-base/src/useAutocomplete/useAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import {
} from '@mui/utils';

// https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
// Give up on IE11 support for this feature
function stripDiacritics(string) {
return typeof string.normalize !== 'undefined'
? string.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
: string;
return string.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}

export function createFilterOptions(config = {}) {
Expand Down Expand Up @@ -56,17 +53,6 @@ export function createFilterOptions(config = {}) {
};
}

// To replace with .findIndex() once we stop IE11 support.
function findIndex(array, comp) {
for (let i = 0; i < array.length; i += 1) {
if (comp(array[i])) {
return i;
}
}

return -1;
}

const defaultFilterOptions = createFilterOptions();

// Number of options to jump in list box when `Page Up` and `Page Down` keys are used.
Expand Down Expand Up @@ -498,7 +484,7 @@ export function useAutocomplete(props) {
const previousHighlightedOption = previousProps.filteredOptions[highlightedIndexRef.current];

if (previousHighlightedOption) {
return findIndex(filteredOptions, (option) => {
return filteredOptions.findIndex((option) => {
return getOptionLabel(option) === getOptionLabel(previousHighlightedOption);
});
}
Expand Down Expand Up @@ -539,12 +525,12 @@ export function useAutocomplete(props) {
if (
multiple &&
currentOption &&
findIndex(value, (val) => isOptionEqualToValue(currentOption, val)) !== -1
value.findIndex((val) => isOptionEqualToValue(currentOption, val)) !== -1
) {
return;
}

const itemIndex = findIndex(filteredOptions, (optionItem) =>
const itemIndex = filteredOptions.findIndex((optionItem) =>
isOptionEqualToValue(optionItem, valueItem),
);
if (itemIndex === -1) {
Expand Down Expand Up @@ -685,7 +671,7 @@ export function useAutocomplete(props) {
}
}

const itemIndex = findIndex(newValue, (valueItem) => isOptionEqualToValue(option, valueItem));
const itemIndex = newValue.findIndex((valueItem) => isOptionEqualToValue(option, valueItem));

if (itemIndex === -1) {
newValue.push(option);
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-base/src/useSnackbar/useSnackbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export function useSnackbar(parameters: UseSnackbarParameters = {}): UseSnackbar
*/
function handleKeyDown(nativeEvent: KeyboardEvent) {
if (!nativeEvent.defaultPrevented) {
// IE11, Edge (prior to using Blink?) use 'Esc'
if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {
if (nativeEvent.key === 'Escape') {
// not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar
onClose?.(nativeEvent, 'escapeKeyDown');
}
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
},
"homepage": "https://github.com/mui/material-ui/tree/master/packages/mui-docs",
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "echo 'Skip modern build'",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
1 change: 0 additions & 1 deletion packages/mui-icons-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"build": "shx cp -r lib/ build/ && pnpm build:typings && pnpm build:copy-files",
"build:lib": "pnpm build:node && pnpm build:stable",
"build:lib:clean": "rimraf lib/ && pnpm build:lib",
"build:legacy": "echo 'Skip legacy build'",
"build:modern": "echo 'Skip modern build'",
"build:node": "node ../../scripts/build.mjs node --largeFiles --outDir lib",
"build:stable": "node ../../scripts/build.mjs stable --largeFiles --outDir lib",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-joy/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}

function handleKeyDown(nativeEvent: KeyboardEvent) {
// IE11, Edge (prior to using Bink?) use 'Esc'
if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {
if (nativeEvent.key === 'Escape') {
handleClose(nativeEvent);
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-lab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:umd && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:umd && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
* @param {KeyboardEvent} nativeEvent
*/
function handleKeyDown(nativeEvent) {
// IE11, Edge (prior to using Bink?) use 'Esc'
if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {
if (nativeEvent.key === 'Escape') {
handleClose(nativeEvent);
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-material/src/styles/createTransitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export default function createTransitions(inputTransitions) {

if (process.env.NODE_ENV !== 'production') {
const isString = (value) => typeof value === 'string';
// IE11 support, replace with Number.isNaN
// eslint-disable-next-line no-restricted-globals
const isNumber = (value) => !isNaN(parseFloat(value));
const isNumber = (value) => !Number.isNaN(parseFloat(value));
if (!isString(props) && !Array.isArray(props)) {
console.error('MUI: Argument "props" must be a string or Array.');
}
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-private-theming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-styled-engine-sc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-styled-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://opencollective.com/mui-org"
},
"scripts": {
"build": "pnpm build:legacy && pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:legacy": "node ../../scripts/build.mjs legacy",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
Expand Down
12 changes: 1 addition & 11 deletions packages/mui-utils/src/getDisplayName/getDisplayName.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prefer-stateless-function */
import * as React from 'react';
import { expect } from 'chai';
import getDisplayName, { getFunctionName } from './getDisplayName';
import getDisplayName from './getDisplayName';

describe('utils/getDisplayName.js', () => {
describe('getDisplayName', () => {
Expand Down Expand Up @@ -75,14 +75,4 @@ describe('utils/getDisplayName.js', () => {
expect(getDisplayName(false)).to.equal(undefined);
});
});

describe('getFunctionName', () => {
it('gets the name of a function', () => {
function SomeFunction() {
return <div />;
}

expect(getFunctionName(SomeFunction)).to.equal('SomeFunction');
});
});
});
11 changes: 1 addition & 10 deletions packages/mui-utils/src/getDisplayName/getDisplayName.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import * as React from 'react';
import { ForwardRef, Memo } from 'react-is';

// Simplified polyfill for IE11 support
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
export function getFunctionName(fn: Function): string {
const match = `${fn}`.match(fnNameMatchRegex);
const name = match && match[1];
return name || '';
}

function getFunctionComponentName(
Component: React.FunctionComponent | React.ComponentClass,
fallback = '',
) {
return Component.displayName || Component.name || getFunctionName(Component) || fallback;
return Component.displayName || Component.name || fallback;
}

function getWrappedName(outerType: any, innerType: any, wrapperName: string) {
Expand Down
1 change: 0 additions & 1 deletion packages/mui-utils/src/getDisplayName/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default } from './getDisplayName';
export * from './getDisplayName';
Loading
Loading