Skip to content

Commit

Permalink
Fix missing source property
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed May 31, 2024
1 parent c6b1c4f commit e5b834f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const DEFAULT_ATTRIBUTE = '__default';
* Returns the bindings with the `__default` binding for pattern overrides
* replaced with the full-set of supported attributes. e.g.:
*
* bindings passed in: `{ bindings: { __default: 'core/pattern-overrides' } }`
* bindings returned: `{ bindings: { content: 'core/pattern-overrides' } }`
* bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`
* bindings returned: `{ content: { source: 'core/pattern-overrides' } }`
*
* @param {string} blockName The block name (e.g. 'core/paragraph').
* @param {Object} bindings A block's bindings from the metadata attribute.
Expand All @@ -45,14 +45,16 @@ const DEFAULT_ATTRIBUTE = '__default';
*/
function replacePatternOverrideDefaultBindings( blockName, bindings ) {
// The `__default` binding currently only works for pattern overrides.
if ( bindings?.[ DEFAULT_ATTRIBUTE ] === 'core/pattern-overrides' ) {
if (
bindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'
) {
const supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
const bindingsWithDefaults = {};
for ( const attributeName of supportedAttributes ) {
// If the block has mixed binding sources, retain any non pattern override bindings.
const bindingSourceName = bindings[ attributeName ]
? bindings[ attributeName ]
: 'core/pattern-overrides';
: { source: 'core/pattern-overrides' };
bindingsWithDefaults[ attributeName ] = bindingSourceName;
}

Expand Down

0 comments on commit e5b834f

Please sign in to comment.