Skip to content

Commit

Permalink
style: simplify destroyAll api due to private usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Jul 11, 2024
1 parent d360da0 commit 7877ead
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/modules/esl-mixin-element/ui/esl-mixin-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,11 @@ export class ESLMixinRegistry {
delete store[mixin];
}

/**
* Destroys all mixins on the element
* @param el - host element to destroy all mixins
* @param deep - if true, will destroy all mixins on the subtree
*/
private static destroyAll(el: HTMLElement, deep = true): void {
/** Destroys all mixins on the element and its subtree */
private static destroyAll(el: HTMLElement): void {
const store = (el as any)[STORE] as Record<string, ESLMixinElement> | undefined;
store && Object.keys(store).forEach((name) => ESLMixinRegistry.destroy(el, name));
if (!deep || !el.children || !el.children.length) return;
if (!el.children || !el.children.length) return;
Array.prototype.forEach.call(el.children, (child: Element) => ESLMixinRegistry.destroyAll(child as HTMLElement));
}
}

0 comments on commit 7877ead

Please sign in to comment.