From 49a5ca0abe9e6cabe5d8ac60d2795cb077ee4485 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 10 Apr 2024 14:07:43 +0200 Subject: [PATCH] make new controller when constructor args changes --- .../extension-with-api-slot.element.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/packages/core/components/extension-with-api-slot/extension-with-api-slot.element.ts b/src/packages/core/components/extension-with-api-slot/extension-with-api-slot.element.ts index 40f8e76d69..a9ea9b08dd 100644 --- a/src/packages/core/components/extension-with-api-slot/extension-with-api-slot.element.ts +++ b/src/packages/core/components/extension-with-api-slot/extension-with-api-slot.element.ts @@ -46,7 +46,7 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement { if (value === this.#type) return; this.#type = value; if (this.#attached) { - this._observeExtensions(); + this.#observeExtensions(); } } #type?: string | string[] | undefined; @@ -68,7 +68,7 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement { if (value === this.#filter) return; this.#filter = value; if (this.#attached) { - this._observeExtensions(); + this.#observeExtensions(); } } #filter: (manifest: any) => boolean = () => true; @@ -107,8 +107,9 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement { return this.#constructorArgs; } set apiArgs(newVal: Array | UmbApiConstructorArgumentsMethodType | undefined) { - // TODO, compare changes since last time. only reset the ones that changed. This might be better done by the controller is self: + if (newVal === this.#constructorArgs) return; this.#constructorArgs = newVal; + this.#observeExtensions(); } #constructorArgs?: Array | UmbApiConstructorArgumentsMethodType = []; @@ -146,11 +147,11 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement { connectedCallback(): void { super.connectedCallback(); - this._observeExtensions(); + this.#observeExtensions(); this.#attached = true; } - private _observeExtensions(): void { + #observeExtensions(): void { this.#extensionsController?.destroy(); if (this.#type) { this.#extensionsController = new UmbExtensionsElementAndApiInitializer(