@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
52 lines (51 loc) • 2.46 kB
TypeScript
import type { ESLMixinElement, ESLMixinElementConstructable } from './esl-mixin-element';
/** Registry to store and initialize {@link ESLMixinElement} instances */
export declare class ESLMixinRegistry {
/** Map that stores available mixins under their identifier (attribute) */
protected store: Map<string, ESLMixinElementConstructable>;
/** MutationObserver instance to track DOM changes and init mixins on-fly */
protected mutation$$: MutationObserver;
constructor();
/** Array of registered mixin tags */
get observedAttributes(): string[];
/** Registers mixin definition using {@link ESLMixinElement} constructor */
register(mixin: ESLMixinElementConstructable): void;
/** Resubscribes DOM observer */
resubscribe(root?: Element): void;
/**
* Invalidates all mixins on the element and subtree
* @param root - root HTMLElement to start traversing
* @param name - optional filter for mixin name
*/
invalidateRecursive(root?: HTMLElement, name?: string): void;
/**
* Invalidates all mixins on the element
* @param el - host element to invalidate mixins
*/
invalidateAll(el: HTMLElement): void;
/**
* Invalidates passed mixin name on the element
* @param el - host element to invalidate mixin
* @param name - mixin name to invalidate
* @param oldValue - optional previous value of mixins attribute
*/
invalidate(el: HTMLElement, name: string, oldValue?: string | null): void;
/** Handles DOM {@link MutationRecord} list */
protected _onMutation(mutations: MutationRecord[]): void;
/** Returns mixin instance by element */
static get<T extends ESLMixinElementConstructable>(this: T, $el: HTMLElement): InstanceType<T> | null;
/** Returns mixin instance by element and mixin name */
static get($el: HTMLElement, name: string): ESLMixinElement | null;
/** @returns all mixins initialized on passed host element */
static getAll(el: HTMLElement): ESLMixinElement[];
/** @returns if the passed mixin exists on the element */
static has(el: HTMLElement, mixin: string): boolean;
/** Sets mixin instance to the element store */
private static set;
/** Inits mixin instance on the element */
private static init;
/** Destroys passed mixin on the element */
private static destroy;
/** Destroys all mixins on the element and its subtree */
private static destroyAll;
}