Skip to content

createBlock fires error if name doesn't match a registered block type. #24286

@ryanwelcher

Description

@ryanwelcher

Describe the bug
When calling createBlock() with a block name that is not registered, a console error is fired due to blockType being undefined when accessing the .attributes property here

To reproduce
Steps to reproduce the behavior:

  1. Create a new Post or Page
  2. In the console panel call wp.blocks.createBlock('not/registered)
  3. See error in console.

Expected behavior
I would expect this function to fail with a console warning of Block type {name} is not registered.

Screenshots
create-block-error

Editor version (please complete the following information):

  • WordPress version: 5.4.2
  • No plugin installed.

Desktop (please complete the following information):

  • OS: Mac OS 10.15.6
  • Browser Chrome
  • Version 84.0.4147.105

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions