Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Move filter for registering block types before validation happens #5076

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Feb 15, 2018

Description

When reviewing #4777 I noticed that registerSidebar function reuses some logic from registerBlockType. I also discovered that for both functions it is possible to use a filter which changes to the settings object after validation happened. See https://github.com/WordPress/gutenberg/pull/4777/files#r166887072. What it means in practice is that even if originally passed settings are valid, everyone can update them with corrupted data and it won't stop registration with the proper warning. This PR fixes it for registerBlockType method.

I also added small refactoring which uses jest-console package to validate console.error calls.

How Has This Been Tested?

I added a new unit test to ensure that it works as expected.

Types of changes

Bug fix (non-breaking change which fixes an issue).

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@gziolo gziolo added [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience labels Feb 15, 2018
@gziolo gziolo self-assigned this Feb 15, 2018
Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

Useful change, LGTM!

@gziolo gziolo merged commit 2fe1df8 into master Feb 19, 2018
@gziolo gziolo deleted the update/block-register-filters branch February 19, 2018 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants