Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Return new object instead of mutating passed settings
  • Loading branch information
aaronrobertshaw committed Apr 12, 2021
commit 82b7ab116452adeccd154fa510041e6683629c82
19 changes: 12 additions & 7 deletions packages/block-editor/src/hooks/border-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,25 @@ export function useIsBorderColorDisabled( { name: blockName } = {} ) {
* @return {Object} Updated block settings.
*/
function addAttributes( settings ) {
if ( ! hasBlockSupport( settings, BORDER_COLOR_SUPPORT_KEY ) ) {
if ( ! hasBorderColorSupport( settings ) ) {
return settings;
}

// Allow blocks to specify default value if needed.
if ( ! settings.attributes.borderColor ) {
Object.assign( settings.attributes, {
if ( settings.attributes.borderColor ) {
return settings;
}

// Add new borderColor attribute to block settings.
return {
...settings,
attributes: {
...settings.attributes,
borderColor: {
type: 'string',
},
} );
}

return settings;
},
};
}

/**
Expand Down