Skip to content
13 changes: 13 additions & 0 deletions packages/blocks/src/store/process-block-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ export const processBlockType =
),
};

// Temporary fix to allow block authors time to fix blocks that register attributes as null or undefined.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be temporary. Folks might encounter this in the future, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it not being temporary if others agree. I'd defer to folks with more expertise in block registration first.

if (
! blockType.attributes ||
typeof blockType.attributes !== 'object'
) {
warning(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also include a test for this?

'The block "' +
name +
'" must not register attributes as null or undefined. Use an empty object (`attributes: {}`) or exclude the attributes key. In the next Gutenberg release, passing null or undefined for attributes will cause the block editor to crash.'
);
blockType.attributes = {};
}

const settings = applyFilters(
'blocks.registerBlockType',
blockType,
Expand Down
Loading