From ce803308505987b62c5afd58c947f1671b8bd48b Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Fri, 19 Jul 2024 12:26:57 +0200 Subject: [PATCH] Use `blockBindingsBySource` name --- .../src/hooks/use-bindings-attributes.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/block-editor/src/hooks/use-bindings-attributes.js b/packages/block-editor/src/hooks/use-bindings-attributes.js index 0c978d436e8d64..410ad93bd971a7 100644 --- a/packages/block-editor/src/hooks/use-bindings-attributes.js +++ b/packages/block-editor/src/hooks/use-bindings-attributes.js @@ -121,7 +121,7 @@ export const withBlockBindingSupport = createHigherOrderComponent( const attributes = {}; - const bindingsBySource = new Map(); + const blockBindingsBySource = new Map(); for ( const [ attributeName, binding ] of Object.entries( blockBindings @@ -135,16 +135,16 @@ export const withBlockBindingSupport = createHigherOrderComponent( continue; } - bindingsBySource.set( source, { - ...bindingsBySource.get( source ), + blockBindingsBySource.set( source, { + ...blockBindingsBySource.get( source ), [ attributeName ]: { args: sourceArgs, }, } ); } - if ( bindingsBySource.size ) { - for ( const [ source, bindings ] of bindingsBySource ) { + if ( blockBindingsBySource.size ) { + for ( const [ source, bindings ] of blockBindingsBySource ) { // Get values in batch if the source supports it. const values = source.getValues( { registry, @@ -190,7 +190,7 @@ export const withBlockBindingSupport = createHigherOrderComponent( } const keptAttributes = { ...nextAttributes }; - const bindingsBySource = new Map(); + const blockBindingsBySource = new Map(); // Loop only over the updated attributes to avoid modifying the bound ones that haven't changed. for ( const [ attributeName, newValue ] of Object.entries( @@ -208,8 +208,8 @@ export const withBlockBindingSupport = createHigherOrderComponent( if ( ! source?.setValues ) { continue; } - bindingsBySource.set( source, { - ...bindingsBySource.get( source ), + blockBindingsBySource.set( source, { + ...blockBindingsBySource.get( source ), [ attributeName ]: { args: binding.args, newValue, @@ -218,8 +218,11 @@ export const withBlockBindingSupport = createHigherOrderComponent( delete keptAttributes[ attributeName ]; } - if ( bindingsBySource.size ) { - for ( const [ source, bindings ] of bindingsBySource ) { + if ( blockBindingsBySource.size ) { + for ( const [ + source, + bindings, + ] of blockBindingsBySource ) { source.setValues( { registry, context,