From a74854fb4ecb54d75fe6b34e72aab1e8dc58e46d Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Mon, 23 Dec 2024 06:00:43 +0200 Subject: [PATCH] cleanup and refactor --- packages/core/src/common/index.ts | 1 - .../src/dom_components/model/Component.ts | 35 ++++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/core/src/common/index.ts b/packages/core/src/common/index.ts index 34292a4e9..90d9ac5d9 100644 --- a/packages/core/src/common/index.ts +++ b/packages/core/src/common/index.ts @@ -9,7 +9,6 @@ export const collectionEvents = 'add remove reset change'; export type Debounced = Function & { cancel(): void }; export type SetOptions = Backbone.ModelSetOptions & { - unset?: boolean; avoidStore?: boolean; avoidTransformers?: boolean; partial?: boolean; diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 8225988f3..907723f6a 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -337,33 +337,34 @@ export default class Component extends StyleableModel { } } - set(attributeName: A, value?: ComponentProperties[A], options?: ComponentSetOptions): this; - set(attributeName: Partial, options?: ComponentSetOptions): this; set( - attributeName: Partial | A, - value?: SetOptions | ComponentProperties[A], + keyOrAttributes: A | Partial, + valueOrOptions?: ComponentProperties[A] | SetOptions, options?: ComponentSetOptions, ): this; + set( - attributeName: Partial | A, - value?: SetOptions | ComponentProperties[A], + keyOrAttributes: A | Partial, + valueOrOptions?: ComponentProperties[A] | SetOptions, options: ComponentSetOptions = { skipWatcherUpdates: false }, ): this { - const props = - typeof attributeName === 'object' - ? attributeName - : typeof attributeName === 'string' - ? { [attributeName as string]: value } + const attributes = + typeof keyOrAttributes === 'object' + ? keyOrAttributes + : typeof keyOrAttributes === 'string' + ? { [keyOrAttributes as string]: valueOrOptions } : {}; - const areStaticAttributes = DynamicValueWatcher.areStaticValues(props); - const evaluatedProps = areStaticAttributes - ? props - : ComponentDynamicValueListener.evaluateComponentDef(props, this.em); + + const areStaticAttributes = DynamicValueWatcher.areStaticValues(attributes); + const evaluatedAttributes = areStaticAttributes + ? attributes + : ComponentDynamicValueListener.evaluateComponentDef(attributes, this.em); + if (!options.skipWatcherUpdates) { - this.componentDVListener?.watchProps(props); + this.componentDVListener?.watchProps(attributes); } - return super.set(evaluatedProps, options); + return super.set(evaluatedAttributes, options); } __postAdd(opts: { recursive?: boolean } = {}) {