-
Notifications
You must be signed in to change notification settings - Fork 319
Closed
Labels
Description
Initiative / goal
The @query decorator returns an element from the currently rendered element DOM; however, it is sometimes useful to query after the element has updated. This ensures the element update state is resolved before the query is performed. In addition, if the result of the query is itself a LitElement, it is often useful for it to be updated before the query is made.
Scope
Create an @asyncQuery decorator which creates a getter which returns a promise that resolves to the result of querying the passed selector after the element has updated.
For example, given a render method like:
@asyncQuery('#foo)
foo: HTMLDivElement;
render() {
return html`${this.special ?
html`<div id=foo>Special Foo</div>` :
html`<div id=foo>Foo</div>`
};
}
async toggleSpecialAndDoSomethingWithFoo() {
this.special = !this.special;
const text = (await this.foo).textContent;
}
Acceptance criteria and must have scope
Feature is implemented and tests pass.