Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Supports: Allow skipping serialization of border #30035

Merged
merged 4 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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