Skip to content

Commit

Permalink
[core] Begin removing IE 11-related code (#41709)
Browse files Browse the repository at this point in the history
  • Loading branch information
iammminzzy committed Apr 16, 2024
1 parent 7cfc2bb commit bba4f7c
Show file tree
Hide file tree
Showing 42 changed files with 134 additions and 394 deletions.
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ module.exports = {
'react/state-in-constructor': 'off',
// stylistic opinion. For conditional assignment we want it outside, otherwise as static
'react/static-property-placement': 'off',
// noopener is enough, no IE 11 support
// noopener is enough
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md#rule-options
'react/jsx-no-target-blank': ['error', { allowReferrer: true }],

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
19 changes: 2 additions & 17 deletions docs/data/joy/components/table/TableSortAndSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,6 @@ function getComparator(order, orderBy) {
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort(array, comparator) {
const stabilizedThis = array.map((el, index) => [el, index]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

const headCells = [
{
id: 'name',
Expand Down Expand Up @@ -348,7 +332,8 @@ export default function TableSortAndSelection() {
rowCount={rows.length}
/>
<tbody>
{stableSort(rows, getComparator(order, orderBy))
{[...rows]
.sort(getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((row, index) => {
const isItemSelected = isSelected(row.name);
Expand Down
19 changes: 2 additions & 17 deletions docs/data/joy/components/table/TableSortAndSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,6 @@ function getComparator<Key extends keyof any>(
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort<T>(array: readonly T[], comparator: (a: T, b: T) => number) {
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

interface HeadCell {
disablePadding: boolean;
id: keyof Data;
Expand Down Expand Up @@ -390,7 +374,8 @@ export default function TableSortAndSelection() {
rowCount={rows.length}
/>
<tbody>
{stableSort(rows, getComparator(order, orderBy))
{[...rows]
.sort(getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((row, index) => {
const isItemSelected = isSelected(row.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,6 @@ function getComparator<Key extends keyof any>(
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort<T>(array: readonly T[], comparator: (a: T, b: T) => number) {
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

function RowMenu() {
return (
<Dropdown>
Expand Down Expand Up @@ -451,7 +435,7 @@ export default function OrderTable() {
</tr>
</thead>
<tbody>
{stableSort(rows, getComparator(order, 'id')).map((row) => (
{[...rows].sort(getComparator(order, 'id')).map((row) => (
<tr key={row.id}>
<td style={{ textAlign: 'center', width: 120 }}>
<Checkbox
Expand Down
23 changes: 3 additions & 20 deletions docs/data/material/components/table/EnhancedTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,6 @@ function getComparator(order, orderBy) {
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort(array, comparator) {
const stabilizedThis = array.map((el, index) => [el, index]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

const headCells = [
{
id: 'name',
Expand Down Expand Up @@ -288,10 +272,9 @@ export default function EnhancedTable() {

const visibleRows = React.useMemo(
() =>
stableSort(rows, getComparator(order, orderBy)).slice(
page * rowsPerPage,
page * rowsPerPage + rowsPerPage,
),
[...rows]
.sort(getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage),
[order, orderBy, page, rowsPerPage],
);

Expand Down
23 changes: 3 additions & 20 deletions docs/data/material/components/table/EnhancedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,6 @@ function getComparator<Key extends keyof any>(
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort<T>(array: readonly T[], comparator: (a: T, b: T) => number) {
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

interface HeadCell {
disablePadding: boolean;
id: keyof Data;
Expand Down Expand Up @@ -320,10 +304,9 @@ export default function EnhancedTable() {

const visibleRows = React.useMemo(
() =>
stableSort(rows, getComparator(order, orderBy)).slice(
page * rowsPerPage,
page * rowsPerPage + rowsPerPage,
),
[...rows]
.sort(getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage),
[order, orderBy, page, rowsPerPage],
);

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.4",
"@docsearch/react": "^3.6.0",
Expand Down
18 changes: 1 addition & 17 deletions docs/src/components/showcase/FolderTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ function getComparator<Key extends keyof any>(
: (a, b) => -descendingComparator(a, b, orderBy);
}

// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort<T>(array: readonly T[], comparator: (a: T, b: T) => number) {
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
stabilizedThis.sort((a, b) => {
const order = comparator(a[0], b[0]);
if (order !== 0) {
return order;
}
return a[1] - b[1];
});
return stabilizedThis.map((el) => el[0]);
}

function formatSize(size: number) {
const kb = size / 1000;
if (kb < 1000) {
Expand Down Expand Up @@ -138,7 +122,7 @@ export default function BasicTable() {
</TableRow>
</TableHead>
<TableBody>
{stableSort(data, getComparator(order, orderBy)).map((row) => (
{[...data].sort(getComparator(order, orderBy)).map((row) => (
<TableRow key={row.name} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
Expand Down
Loading

0 comments on commit bba4f7c

Please sign in to comment.