Skip to content

Commit

Permalink
Lodash: Remove _.isEmpty() from cleanEmptyObject util
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed May 25, 2023
1 parent 34c5d3c commit f9a9e6b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/block-editor/src/hooks/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { isEmpty, get } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -30,12 +30,13 @@ export const cleanEmptyObject = ( object ) => {
) {
return object;
}
const cleanedNestedObjects = Object.fromEntries(
Object.entries( object )
.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
.filter( ( [ , value ] ) => value !== undefined )
);
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;

const cleanedNestedObjects = Object.entries( object )
.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
.filter( ( [ , value ] ) => value !== undefined );
return ! cleanedNestedObjects.length
? undefined
: Object.fromEntries( cleanedNestedObjects );
};

export function transformStyles(
Expand Down

0 comments on commit f9a9e6b

Please sign in to comment.