feat: prop get set new#6050
Merged
christian-bromann merged 11 commits intostenciljs:mainfrom Nov 26, 2024
Merged
Conversation
12 tasks
Member
|
@johnjenkins great work 👏 do you think this feature needs to amendments to the Stencil docs? |
Contributor
Author
christian-bromann
approved these changes
Nov 26, 2024
Member
christian-bromann
left a comment
There was a problem hiding this comment.
LGTM 👍 great work 👏
|
@johnjenkins you legend! 🎉 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allowing the
@Propdecorator to use get / set provides many quality of life improvements for developers and can improve the api of their components (see linked issues for many valid, uncontested use cases).Validation & Guards. Transforming data. Read-only properties. All things that may be achievable at the moment but can be extremely cumbersome to implement.
What is the current behavior?
@Prop()decorated attributes cannot be used withget()orset()GitHub Issue Number: Fixes #1359
What is the new behavior?
Documentation
@Propdecorator attributes: attribute and reflect work as expected.Prop setters work as expected in relation to
@Watchdecorated methods (the Watch method will only be called after the setter has actually changed the property value).get()only properties will be marked as@readonlyin the JSDoc comment.Known limitations
When using the
dist/ 'lazy' bundle, If an initial value is set (via an attribute for example) in-order to 'go through' the class'set()method, Stencil can only do so after lazily fetching / loading the class component. This means one initial render / tick before being able to set the incoming, initial value.This limitation does not exist on the
dist-custom-elements/ non-lazy bundlestenciljs/site#1496
Does this introduce a breaking change?
Testing
Other information