Skip to content
Closed
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
11 changes: 9 additions & 2 deletions packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { store as blocksStore } from '@wordpress/blocks';
import { store as blocksStore, getBlockType } from '@wordpress/blocks';
import { createHigherOrderComponent } from '@wordpress/compose';
import { useRegistry, useSelect } from '@wordpress/data';
import { useCallback, useMemo, useContext } from '@wordpress/element';
Expand Down Expand Up @@ -93,7 +93,14 @@ export function canBindAttribute( blockName, attributeName ) {
}

export function getBindableAttributes( blockName ) {
return BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
const blockType = getBlockType( blockName );
const allowedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ] || [];
// Still comparing with the allowed blocks constant until we can automate the bindings server process.
return Object.keys( blockType.attributes ).filter(
( key ) =>
blockType.attributes[ key ].role === 'content' &&
allowedAttributes.includes( key )
);
}

export const withBlockBindingSupport = createHigherOrderComponent(
Expand Down