From 706321be7b993e8223f141e7b9573d11d745af4f Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Thu, 17 Jun 2021 15:17:23 +1000 Subject: [PATCH] Filter empty longhand CSS styles from inline style generation --- packages/block-editor/src/hooks/style.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/hooks/style.js b/packages/block-editor/src/hooks/style.js index b02c662de0df3b..4c207f3dab8ea3 100644 --- a/packages/block-editor/src/hooks/style.js +++ b/packages/block-editor/src/hooks/style.js @@ -83,10 +83,12 @@ export function getInlineStyles( styles = {} ) { if ( !! subPaths && ! isString( styleValue ) ) { Object.entries( subPaths ).forEach( ( entry ) => { - const [ name, suffix ] = entry; - output[ name ] = compileStyleValue( - get( styleValue, [ suffix ] ) - ); + const [ name, subPath ] = entry; + const value = get( styleValue, [ subPath ] ); + + if ( value ) { + output[ name ] = compileStyleValue( value ); + } } ); } else { output[ propKey ] = compileStyleValue( get( styles, path ) );