Provide context when blocks.registerBlockType is applied to deprecations
#36628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
blocks.registerBlockTypefilter is applied both to the block's full settings as well as to the settings for its deprecations. If care is not taken, a change intended for the current block's settings can be applied to one of its deprecations unintentionally, with the potential to break the deprecation. This can be avoided by testing the block's settings before applying changes via the filter, but the block's settings may not always be changed in a way that can easily be discerned. To assist with determining the context in which the filter is applied, the deprecation's settings are passed as a third argument, andnullis passed when the filter is applied to the block's complete settings.How has this been tested?
Added a filter that expects three arguments, confirmed that received arguments were as expected.
Screenshots
Types of changes
blocks.registerBlockTypethat isnullwhen filtering the full settings, and contains a deprecation's settings when applied to one of the block's deprecations.Checklist:
*.native.jsfiles for terms that need renaming or removal).