Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): @Prop / @State now work with runtime decorators #6084

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

johnjenkins
Copy link
Contributor

@johnjenkins johnjenkins commented Dec 20, 2024

What is the current behavior?

Following on from #6076 I delved into runtime decorators in combination with Stencil decorated members and found them to be quite limited.

One of the most useful things of property decorators is their ability to augment a class' prototype.

For example, If you want validation on an incoming value - e.g. an incoming number should be clamped between a floor and ceiling - you could use a decorator to add get() / set() accessors, checking and amending the incoming value.

Unfortunately, for @State and @Prop members, Stencil set's up it's own get() and set() and overrides any set on the prototype via decorators.

This gets in the way of expected / native behaviour.

GitHub Issue Number: N/A

What is the new behavior?

runtime/proxy-component.ts (client) & hydrated/proxy-host-element.ts (server) has been refactored.

  1. Merges the previously separate setter / getter handlers into a unified handler
  2. preserves and applies any already in-place accessors

Runtime decorators can now be used in combination with prop / state values / accessors.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • Spec tests
  • Components tests
  • End-to-End tests

Other information

@johnjenkins johnjenkins marked this pull request as ready for review January 11, 2025 01:07
@johnjenkins johnjenkins requested a review from a team as a code owner January 11, 2025 01:07
@johnjenkins johnjenkins changed the title refactor: proxy component feat(runtime): @Prop / @State now work with runtime decorators Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant