UNPKG

@bem-plus/class-generator

Version:

The `@bem-plus/class-generator` allows you to generate boilerplate JavaScript or TypeScript code from your Stylesheets.

27 lines (19 loc) 531 B
export class BemPlusModule<TRoot extends Element | HTMLElement = HTMLElement> { type rootClass index = 0 refresh = () => {} constructor(rootElement: TRoot, k?: number) { if (k) { this.index = k } this.type = this.constructor.name this.rootClass = rootElement.classList[0]?.split('__')[0] new MutationObserver(() => { this.refresh() }).observe(rootElement, { childList: true, subtree: true }) } }