@alwatr/synapse
Version:
Connect your TypeScript classes to the DOM, declaratively.
38 lines • 1.52 kB
TypeScript
import type { DirectiveBase } from './directiveClass.js';
/**
* A property decorator that queries the directive's element for a selector.
* The query is performed once and the result is cached.
*
* @param selector The CSS selector to query for.
* @param cache Whether to cache the result on first access. Defaults is true.
* @param root Optional root element to perform the query on. Defaults to the directive's element.
*
* @example
* ```ts
* @directive('[my-directive]')
* class MyDirective extends DirectiveBase {
* @query('.my-element')
* protected myElement: HTMLDivElement | null;
* }
* ```
*/
export declare function query(selector: string, cache?: boolean, root?: ParentNode): (target: DirectiveBase, propertyKey: string) => void;
/**
* A property decorator that queries the directive's element for all selectors.
* The queries are performed once and the result is cached.
*
* @param selector The CSS selector to query for.
* @param cache Whether to cache the result on first access. Defaults is true.
* @param root Optional root element to perform the query on. Defaults to the directive's element.
*
* @example
* ```ts
* @directive('[my-directive]')
* class MyDirective extends DirectiveBase {
* @queryAll('.my-elements')
* protected myElements: NodeListOf<HTMLDivElement>;
* }
* ```
*/
export declare function queryAll(selector: string, cache?: boolean, root?: ParentNode): (target: DirectiveBase, propertyKey: string) => void;
//# sourceMappingURL=queryDecorator.d.ts.map