query-async.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @license
  3. * Copyright 2017 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { ReactiveElement } from '../reactive-element.js';
  7. /**
  8. * A property decorator that converts a class property into a getter that
  9. * returns a promise that resolves to the result of a querySelector on the
  10. * element's renderRoot done after the element's `updateComplete` promise
  11. * resolves. When the queried property may change with element state, this
  12. * decorator can be used instead of requiring users to await the
  13. * `updateComplete` before accessing the property.
  14. *
  15. * @param selector A DOMString containing one or more selectors to match.
  16. *
  17. * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
  18. *
  19. * ```ts
  20. * class MyElement {
  21. * @queryAsync('#first')
  22. * first;
  23. *
  24. * render() {
  25. * return html`
  26. * <div id="first"></div>
  27. * <div id="second"></div>
  28. * `;
  29. * }
  30. * }
  31. *
  32. * // external usage
  33. * async doSomethingWithFirst() {
  34. * (await aMyElement.first).doSomething();
  35. * }
  36. * ```
  37. * @category Decorator
  38. */
  39. export declare function queryAsync(selector: string): (protoOrDescriptor: ReactiveElement | import("./base.js").ClassElement, name?: PropertyKey | undefined) => any;
  40. //# sourceMappingURL=query-async.d.ts.map