Change attribute serialization to explicit opt-in#988
Conversation
| encodeAttributes( attributes ) { | ||
| const { align } = attributes; | ||
| return { align }; | ||
| }, |
There was a problem hiding this comment.
don't you think the metadata( 'align' ) is better for consistency? It's just another way of parsing the attribute.
There was a problem hiding this comment.
don't you think the
metadata( 'align' )is better for consistency? It's just another way of parsing the attribute.
I suppose it depends where we take attributes initialization. I tried to communicate my current state of mind earlier at #391 (comment) . If matching included encoded attributes, I'd agree we wouldn't need this function at all. I might try to spend some time tomorrow exploring AST selectors like the ESLint ones I mentioned in that comment. If those work out, I don't think we'd really want to use them for comment sourcing.
|
Closing in favor of #1905 |
Related: #865, #391
This pull request seeks to change attribute serialization behavior, currently inferred as the difference between a block's actual attributes at time of serialization and the
attributesdefinition. With these changes, it will instead be required that a block explicitly control its comment encoding behavior by returning an object from anencodeAttributesfunction. This is implemented exactly as documented from theregisterBlockTypedocumentation.Testing instructions:
Ensure that tests pass:
Verify that block comment serialization continues to behave as expected for Button
align, Imagealign, and Quotestyleblocks, when changing these values and switching to Text mode.