Skip to content

Commit

Permalink
Lodash: Remove _.pickBy() from block editor and deprecate (#46999)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jan 10, 2023
1 parent 94e06b2 commit 92a40bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const restrictedImports = [
'partial',
'partialRight',
'pick',
'pickBy',
'random',
'reduce',
'reject',
Expand Down
66 changes: 33 additions & 33 deletions packages/block-editor/src/components/font-sizes/with-font-sizes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { pickBy } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -160,35 +155,40 @@ export default ( ...fontSizeNames ) => {
}

const newState = Object.entries(
pickBy(
fontSizeAttributeNames,
didAttributesChange
fontSizeAttributeNames
)
.filter( ( [ key, value ] ) =>
didAttributesChange( value, key )
)
).reduce(
(
newStateAccumulator,
[
fontSizeAttributeName,
customFontSizeAttributeName,
]
) => {
const fontSizeAttributeValue =
attributes[ fontSizeAttributeName ];
const fontSizeObject = getFontSize(
fontSizes,
fontSizeAttributeValue,
attributes[ customFontSizeAttributeName ]
);
newStateAccumulator[ fontSizeAttributeName ] = {
...fontSizeObject,
class: getFontSizeClass(
fontSizeAttributeValue
),
};
return newStateAccumulator;
},
{}
);
.reduce(
(
newStateAccumulator,
[
fontSizeAttributeName,
customFontSizeAttributeName,
]
) => {
const fontSizeAttributeValue =
attributes[ fontSizeAttributeName ];
const fontSizeObject = getFontSize(
fontSizes,
fontSizeAttributeValue,
attributes[
customFontSizeAttributeName
]
);
newStateAccumulator[
fontSizeAttributeName
] = {
...fontSizeObject,
class: getFontSizeClass(
fontSizeAttributeValue
),
};
return newStateAccumulator;
},
{}
);

return {
...previousState,
Expand Down

1 comment on commit 92a40bd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 92a40bd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3882325138
📝 Reported issues:

Please sign in to comment.