Skip to content

Commit

Permalink
Block Supports: Allow skipping serialization of border (#30035)
Browse files Browse the repository at this point in the history
By setting `"__experimentalSkipSerialization": true` in the `__experimentalBorder` object in a block's `block.json`.
  • Loading branch information
ockham authored Mar 23, 2021
1 parent 7295579 commit da9b4ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/block-supports/border.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ function gutenberg_register_border_support( $block_type ) {
* @return array Border CSS classes and inline styles.
*/
function gutenberg_apply_border_support( $block_type, $block_attributes ) {
$border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );

if (
is_array( $border_support ) &&
array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
$border_support['__experimentalSkipSerialization']
) {
return array();
}

// Arrays used to ease addition of further border related features in future.
$styles = array();

Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export function addSaveProps( props, blockType, attributes ) {

const { style } = attributes;
const filteredStyle = omitKeysNotToSerialize( style, {
border: getBlockSupport( blockType, BORDER_SUPPORT_KEY ),
[ COLOR_SUPPORT_KEY ]: getBlockSupport( blockType, COLOR_SUPPORT_KEY ),
} );
props.style = {
Expand Down

0 comments on commit da9b4ae

Please sign in to comment.