Skip to content

Commit

Permalink
Lodash: Remove _.mapValues() from editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Apr 7, 2023
1 parent 32f217b commit 536c48f
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

0 comments on commit 536c48f

Please sign in to comment.