diff --git a/packages/block-library/src/image/deprecated.js b/packages/block-library/src/image/deprecated.js index 9f5aaee4f7d21a..9b7a41cab188de 100644 --- a/packages/block-library/src/image/deprecated.js +++ b/packages/block-library/src/image/deprecated.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { isEmpty } from 'lodash'; /** * WordPress dependencies @@ -122,7 +121,7 @@ const deprecated = [ title, } = attributes; - const newRel = isEmpty( rel ) ? undefined : rel; + const newRel = ! rel ? undefined : rel; const classes = classnames( { [ `align${ align }` ]: align, @@ -202,7 +201,7 @@ const deprecated = [ title, } = attributes; - const newRel = isEmpty( rel ) ? undefined : rel; + const newRel = ! rel ? undefined : rel; const classes = classnames( { [ `align${ align }` ]: align, diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 19e8196dfc7a51..c4d8de316ea997 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { isEmpty } from 'lodash'; /** * WordPress dependencies @@ -320,7 +319,9 @@ export function ImageEdit( { 'is-resized': !! width || !! height, [ `size-${ sizeSlug }` ]: sizeSlug, 'has-custom-border': - !! borderProps.className || ! isEmpty( borderProps.style ), + !! borderProps.className || + ( borderProps.style && + Object.keys( borderProps.style ).length > 0 ), } ); const blockProps = useBlockProps( { diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index c513ede8b9fe29..abc65f7022acd3 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - /** * WordPress dependencies */ @@ -480,7 +475,8 @@ export default function Image( { const borderProps = useBorderProps( attributes ); const isRounded = attributes.className?.includes( 'is-style-rounded' ); const hasCustomBorder = - !! borderProps.className || ! isEmpty( borderProps.style ); + !! borderProps.className || + ( borderProps.style && Object.keys( borderProps.style ).length > 0 ); let img = ( // Disable reason: Image itself is not meant to be interactive, but diff --git a/packages/block-library/src/image/save.js b/packages/block-library/src/image/save.js index 872ea980d8cf84..d0fd5ef3d6f98b 100644 --- a/packages/block-library/src/image/save.js +++ b/packages/block-library/src/image/save.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { isEmpty } from 'lodash'; /** * WordPress dependencies @@ -31,7 +30,7 @@ export default function save( { attributes } ) { title, } = attributes; - const newRel = isEmpty( rel ) ? undefined : rel; + const newRel = ! rel ? undefined : rel; const borderProps = getBorderClassesAndStyles( attributes ); const classes = classnames( { @@ -39,7 +38,9 @@ export default function save( { attributes } ) { [ `size-${ sizeSlug }` ]: sizeSlug, 'is-resized': width || height, 'has-custom-border': - !! borderProps.className || ! isEmpty( borderProps.style ), + !! borderProps.className || + ( borderProps.style && + Object.keys( borderProps.style ).length > 0 ), } ); const imageClasses = classnames( borderProps.className, { diff --git a/packages/block-library/src/image/utils.js b/packages/block-library/src/image/utils.js index 71e44517517f36..839628fa978b00 100644 --- a/packages/block-library/src/image/utils.js +++ b/packages/block-library/src/image/utils.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - /** * Internal dependencies */ @@ -11,21 +6,19 @@ import { NEW_TAB_REL } from './constants'; export function removeNewTabRel( currentRel ) { let newRel = currentRel; - if ( currentRel !== undefined && ! isEmpty( newRel ) ) { - if ( ! isEmpty( newRel ) ) { - NEW_TAB_REL.forEach( ( relVal ) => { - const regExp = new RegExp( '\\b' + relVal + '\\b', 'gi' ); - newRel = newRel.replace( regExp, '' ); - } ); + if ( currentRel !== undefined && newRel ) { + NEW_TAB_REL.forEach( ( relVal ) => { + const regExp = new RegExp( '\\b' + relVal + '\\b', 'gi' ); + newRel = newRel.replace( regExp, '' ); + } ); - // Only trim if NEW_TAB_REL values was replaced. - if ( newRel !== currentRel ) { - newRel = newRel.trim(); - } + // Only trim if NEW_TAB_REL values was replaced. + if ( newRel !== currentRel ) { + newRel = newRel.trim(); + } - if ( isEmpty( newRel ) ) { - newRel = undefined; - } + if ( ! newRel ) { + newRel = undefined; } }