Skip to content

Commit

Permalink
Avoid processing bindings recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 23, 2024
1 parent dbb82c2 commit ed11e1a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export function isBlockValid( state, clientId ) {
return !! block && block.isValid;
}

/**
* Variable to avoid processing bindings recursively.
*
* @type {boolean}
*/
let isProcessingBindings;

/**
* Returns a block's attributes given its client ID, or null if no block exists with
* the client ID.
Expand All @@ -135,9 +142,10 @@ export const getBlockAttributes = createRegistrySelector(

// Change attribute values if bindings are present.
const bindings = blockAttributes?.metadata?.bindings;
if ( ! bindings ) {
if ( ! bindings || isProcessingBindings ) {
return blockAttributes;
}
isProcessingBindings = true;

const sources = unlock(
select( blocksStore )
Expand Down Expand Up @@ -182,6 +190,7 @@ export const getBlockAttributes = createRegistrySelector(
}
}

isProcessingBindings = false;
return blockAttributes;
}
);
Expand Down

0 comments on commit ed11e1a

Please sign in to comment.