From bae0d6bfedcbf15fe874dcc5a962d4cd8d64fc71 Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:11:14 +0300 Subject: [PATCH] Lodash: Remove _.mapValues() from editor (#49654) --- .../custom-sources-backwards-compatibility.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/editor/src/hooks/custom-sources-backwards-compatibility.js b/packages/editor/src/hooks/custom-sources-backwards-compatibility.js index bf73a3ade7935..b0b1bf96e9d29 100644 --- a/packages/editor/src/hooks/custom-sources-backwards-compatibility.js +++ b/packages/editor/src/hooks/custom-sources-backwards-compatibility.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { mapValues, isEmpty } from 'lodash'; +import { isEmpty } from 'lodash'; /** * WordPress dependencies @@ -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 ] @@ -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 )(