-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): watch native HTML attributes (#4760)
* wip(working-state) * isolate use cases * only execute after initial value is set * remove unused params * observed attributes includes members and native attributes * revert some logic for "member" watchers * get lazy builds working * use instance when binding callback * add test * remove `watchable` from state and prop transformers * jsdoc for new method
- Loading branch information
1 parent
1065463
commit fc86c23
Showing
13 changed files
with
150 additions
and
58 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Component, Element, h, State, Watch } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'watch-native-attributes', | ||
}) | ||
export class WatchNativeAttributes { | ||
@Element() el!: HTMLElement; | ||
|
||
@State() callbackTriggered = false; | ||
|
||
@Watch('aria-label') | ||
onAriaLabelChange() { | ||
this.callbackTriggered = true; | ||
} | ||
|
||
render() { | ||
return [ | ||
<p>Label: {this.el.getAttribute('aria-label')}</p>, | ||
<p>Callback triggered: {`${this.callbackTriggered}`}</p>, | ||
]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!doctype html> | ||
<meta charset="utf8" /> | ||
<script src="./build/testapp.esm.js" type="module"></script> | ||
<script src="./build/testapp.js" nomodule></script> | ||
|
||
<watch-native-attributes aria-label="myStartingLabel"></watch-native-attributes> |
Oops, something went wrong.