-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces a new `HTMLElementHydrationParamsMap` which maps tag names to class properties which be set as part of hydration. Intended usage looks like so: ```typescript class MyElement extends HTMLElement { declare tagName: 'MY-ELEMENT'; // Necessary. public foo!: string; public bar!: number; public baz!: boolean; // ... } declare global { interface HTMLElementTagNameMap { 'my-element': MyElement; } // Defines which properties are required and which are optional. interface HTMLElementHydrationParamsMap { 'my-element': Properties<MyElement, { required: 'foo', optional: 'bar' | 'baz', }>; } } ``` Then, when hydrating this element with `hydrate` or `Dehydrated.prototype.hydrate`, the params object *must* contain `foo` and *may* contain `bar` and `baz`. ```typescript host.query('my-element').hydrate(MyElement, { foo: 'test', bar: 1234, baz: true, }); ``` Custom elements which do not define their parameters in `HTMLElementHydrationParamsMap` or which do not narrow the `tagName` property have all their properties considered optional.
- Loading branch information
Showing
4 changed files
with
320 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.