Skip to content

Commit

Permalink
Lodash: Remove completely from @wordpress/interface package (#42157)
Browse files Browse the repository at this point in the history
* Lodash: Remove completely from interface package

* Move comments up

* Improve non-array or empty array handling

Co-authored-by: Pascal Birchler <[email protected]>

Co-authored-by: Pascal Birchler <[email protected]>
  • Loading branch information
tyxla and swissspidy authored Jul 5, 2022
1 parent b33b256 commit 78d3661
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 31 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"@wordpress/plugins": "file:../plugins",
"@wordpress/preferences": "file:../preferences",
"@wordpress/viewport": "file:../viewport",
"classnames": "^2.3.1",
"lodash": "^4.17.21"
"classnames": "^2.3.1"
},
"peerDependencies": {
"react": "^17.0.0",
Expand Down
7 changes: 1 addition & 6 deletions packages/interface/src/components/action-item/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -25,7 +20,7 @@ function ActionItemSlot( {
fillProps={ fillProps }
>
{ ( fills ) => {
if ( isEmpty( Children.toArray( fills ) ) ) {
if ( ! Children.toArray( fills ).length ) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { omit } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -15,17 +10,14 @@ import { MenuItem } from '@wordpress/components';
import ComplementaryAreaToggle from '../complementary-area-toggle';
import ActionItem from '../action-item';

const PluginsMenuItem = ( props ) => (
const PluginsMenuItem = ( {
// Menu item is marked with unstable prop for backward compatibility.
// They are removed so they don't leak to DOM elements.
// @see https://github.com/WordPress/gutenberg/issues/14457
<MenuItem
{ ...omit( props, [
'__unstableExplicitMenuItem',
'__unstableTarget',
] ) }
/>
);
__unstableExplicitMenuItem,
__unstableTarget,
...restProps
} ) => <MenuItem { ...restProps } />;

export default function ComplementaryAreaMoreMenuItem( {
scope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { omit } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -21,6 +16,7 @@ function ComplementaryAreaToggle( {
identifier,
icon,
selectedIcon,
name,
...props
} ) {
const ComponentToUse = as;
Expand All @@ -42,7 +38,7 @@ function ComplementaryAreaToggle( {
enableComplementaryArea( scope, identifier );
}
} }
{ ...omit( props, [ 'name' ] ) }
{ ...props }
/>
);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/interface/src/components/pinned-items/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';
import classnames from 'classnames';

/**
Expand All @@ -17,7 +16,7 @@ function PinnedItemsSlot( { scope, className, ...props } ) {
return (
<Slot name={ `PinnedItems/${ scope }` } { ...props }>
{ ( fills ) =>
! isEmpty( fills ) && (
fills?.length > 0 && (
<div
className={ classnames(
className,
Expand Down

0 comments on commit 78d3661

Please sign in to comment.