import { Directive } from '@alwatr/directive'; import { type BindingValue } from './main.js'; /** * A declarative DOM directive that binds DOM element attributes to view model properties. * * Syntax: `bind_attrib="attributeName=[!]namespace.propertyName; anotherAttribute=[!]namespace.anotherProperty"` * * Supports binding multiple attributes on the same element separated by semicolons (`;`). * * Behavior: * - `boolean` value: Toggles the presence of the attribute (idiomatic for boolean attributes like `disabled`, `hidden`, `readonly`, `checked`). * - `null` / `undefined` value: Removes the attribute from the element. * - Negation (`!`): Prefixing the property with `!` (e.g., `!namespace.prop`) will negate the value (coerced as boolean). * - Any other type: Coerced via `String(value)` and set as the attribute's value. * * Includes a redundant write guard (via `lastValues_`) that skips calls to the DOM if the property value hasn't changed. * Supports deferred viewport initialization if the `lazy_bind` attribute is present on the element. * * @example * ```html * * * * *
Player is paused
* * * * * * * ``` */ export declare class BindAttribDirective extends Directive { /** * Attribute flag used to defer binding initialization until the element enters the viewport. * If `lazy_bind` attribute exists, this is non-null. */ protected accessor lazyBinding_: null | string; /** * Initializes the directive. * Checks if lazy binding is enabled via `lazy_bind`. * If yes, delegates the initialization to `lazyInit_`; otherwise, initializes immediately. */ protected init_(): void; /** * Cache of the last applied values to guard against redundant DOM modifications. */ protected lastValues_: Record; /** * Main binding initialization logic. Parses each attribute-binding pair, * retrieves the corresponding ViewModel signals, subscribes to updates, * and applies the initial attribute state. */ protected bindingInit_(): void; /** * Applies the bound value to a specific DOM attribute on the element. * * @param attributeName The name of the target attribute (e.g., `'src'`, `'disabled'`). * @param value The value to apply. */ protected applyAttribute_(attributeName: string, value: BindingValue): void; } /** * Helper to register `BindAttribDirective` lazily under the `bind_attrib` attribute. */ export declare const registerBindAttribDirective: import("@alwatr/directive").RegisterDirectiveFunction; //# sourceMappingURL=directive_bind_attrib.d.ts.map