Skip to content

Commit 7a5e8e3

Browse files
committed
remove lodash dependency
1 parent c464408 commit 7a5e8e3

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

src/blocks/shared-block/edit.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -26,6 +21,7 @@ import './editor.scss';
2621

2722
export default function Edit( { attributes, setAttributes } ) {
2823
const { blockId, blockTitle, display } = attributes;
24+
const hasBlockId = ( blockId && blockId.length ) > 0 ? true : false;
2925

3026
const [ isEditing, setIsEditing ] = useState( false );
3127

@@ -98,9 +94,9 @@ export default function Edit( { attributes, setAttributes } ) {
9894
</ButtonGroup>
9995
</PanelBody>
10096
</InspectorControls>
101-
{ isEmpty( blockId ) || isEditing ? (
97+
{ ! hasBlockId || isEditing ? (
10298
<div className={ 'shared-block-selector-wrapper' }>
103-
{ false === isEmpty( blockId ) && (
99+
{ ! hasBlockId && (
104100
<div
105101
className={
106102
'shared-block-selector-wrapper__cancel'

src/hooks/registerSharedBlockAttributes.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { assign, isEmpty } from 'lodash';
5-
61
/**
72
* Internal dependencies
83
*/
@@ -21,13 +16,20 @@ import { blockSupportSharing, getBlockSharingAttributes } from './helper';
2116
const registerSharedBlockAttributes = ( settings, name ) => {
2217
const sharedBlockAttributes = getBlockSharingAttributes();
2318

24-
if ( ! blockSupportSharing( name ) || isEmpty( sharedBlockAttributes ) ) {
19+
if (
20+
! blockSupportSharing( name ) ||
21+
Object.keys( sharedBlockAttributes ).length === 0
22+
) {
2523
return settings;
2624
}
2725

28-
return assign( {}, settings, {
29-
attributes: assign( {}, settings.attributes, sharedBlockAttributes ),
30-
} );
26+
return {
27+
...settings,
28+
attributes: {
29+
...settings.attributes,
30+
...sharedBlockAttributes,
31+
},
32+
};
3133
};
3234

3335
export default registerSharedBlockAttributes;

src/hooks/sharedBlockIdControls.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -27,6 +22,8 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
2722
const { name, attributes, setAttributes } = props;
2823
const { sharedBlockId, sharedBlockIsShared, sharedBlockShareTitle } =
2924
attributes;
25+
const hasShareTitle =
26+
sharedBlockShareTitle && sharedBlockShareTitle > 0 ? true : false;
3027

3128
const getEmptySharedBlockTitle = () => {
3229
return sprintf(
@@ -45,7 +42,7 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
4542
};
4643

4744
const getTitleCharCount = ( title ) => {
48-
if ( isEmpty( title ) ) {
45+
if ( ! hasShareTitle ) {
4946
return '0';
5047
}
5148

@@ -105,7 +102,7 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
105102
'multisite-shared-blocks'
106103
) }
107104
/>
108-
{ isEmpty( sharedBlockShareTitle ) && (
105+
{ ! hasShareTitle && (
109106
<p>
110107
<small>
111108
{ createInterpolateElement(

0 commit comments

Comments
 (0)