Block Editor: Update callers to handle when getBlockType returns undefined #34891
+13
−8
Conversation
…fined This commit has partial changes. It is based on some manual testing.
gwwar
reviewed
Sep 16, 2021
Thanks for taking a look @amustaque97! I left a few notes since some of the usages have a few gotchas. Feel free to ask if anything I noted was unclear.
gwwar
reviewed
Sep 16, 2021
@@ -198,7 +198,7 @@ export function getSaveContent( blockTypeOrName, attributes, innerBlocks ) { | |||
*/ | |||
export function getCommentAttributes( blockType, attributes ) { | |||
return reduce( | |||
blockType.attributes, | |||
blockType?.attributes, |
To match the style of this package, if we're passing blockType as an argument from getBlockType( blockName )
, let's update that instead of adding sanitization in this function.
@gwwar can you explain this change? I'm not clear with your comment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit has partial changes related to #34462. It is based on some manual testing.
Description
In most cases we either need to check if blockType is truthy before using it, or use optional chaining if it makes sense. eg
const icon = blockType?.icon;
How has this been tested?
Testing Instruction can be found here #34346 (comment)
Screenshots
Types of changes
Fix
Checklist:
*.native.js
files for terms that need renaming or removal).cc @gwwar
The text was updated successfully, but these errors were encountered: