Skip to content

Commit

Permalink
Properly clean up nested objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Apr 6, 2023
1 parent 3ff2c69 commit ec78782
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/block-library/src/utils/clean-empty-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const cleanEmptyObject = ( object ) => {
return object;
}
const cleanedNestedObjects = Object.fromEntries(
Object.entries( object ).filter( ( [ , value ] ) =>
Boolean( cleanEmptyObject( value ) )
)
Object.entries( object )
.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
.filter( ( [ , value ] ) => Boolean( value ) )
);
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
};
Expand Down

0 comments on commit ec78782

Please sign in to comment.