Skip to content

Commit

Permalink
Lodash: Remove _.mapValues() from editor (#49654)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Apr 11, 2023
1 parent 9091d91 commit bae0d6b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/editor/src/hooks/custom-sources-backwards-compatibility.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { mapValues, isEmpty } from 'lodash';
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -57,9 +57,13 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
const mergedAttributes = useMemo(
() => ( {
...attributes,
...mapValues(
metaAttributes,
( metaKey ) => meta[ metaKey ]
...Object.fromEntries(
Object.entries( metaAttributes ).map(
( [ attributeKey, metaKey ] ) => [
attributeKey,
meta[ metaKey ],
]
)
),
} ),
[ attributes, meta ]
Expand Down Expand Up @@ -106,13 +110,10 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
*/
function shimAttributeSource( settings ) {
/** @type {WPMetaAttributeMapping} */
const metaAttributes = mapValues(
Object.fromEntries(
Object.entries( settings.attributes ?? {} ).filter(
( [ , { source } ] ) => source === 'meta'
)
),
'meta'
const metaAttributes = Object.fromEntries(
Object.entries( settings.attributes ?? {} )
.filter( ( [ , { source } ] ) => source === 'meta' )
.map( ( [ attributeKey, { meta } ] ) => [ attributeKey, meta ] )
);
if ( ! isEmpty( metaAttributes ) ) {
settings.edit = createWithMetaAttributeSource( metaAttributes )(
Expand Down

1 comment on commit bae0d6b

@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 bae0d6b.
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/4669660767
📝 Reported issues:

Please sign in to comment.