feat: make field initView
and initModel
more accessible
#7345
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.
The basics
npm run format
andnpm run lint
The details
Resolves
Fixes inconsistency in our API. The
init
method on a field is@sealed
and@internal
. The documentation says to overrideinitView
andinitModel
instead. However, those methods were also marked@internal
meaning they couldn't actually be overridden.Proposed Changes
initView
protected because it's only used inside subclasses of fieldsinitModel
public because it's also used from within block serialization codeinitModel
in block serialization code because the old style of for loop was causing the field to be typed asany
which breaks reference searching. Now, "find all references" will actually find them all.imageElement
andimageHeight
protected infield_image
. Having the image element be@internal
makes the image field almost impossible to subclass. If you want to use dynamic image fields that can change images, you have to subclass the image field.Behavior Before Change
Behavior After Change
Reason for Changes
Test Coverage
All tests pass and manually tested serialization in playground.
Documentation
These methods will be included in the next documentation update through api-documenter
Additional Information