diff --git a/src/WidgetBase.ts b/src/WidgetBase.ts index 418fc822..6e8663ac 100644 --- a/src/WidgetBase.ts +++ b/src/WidgetBase.ts @@ -15,7 +15,6 @@ import { DiffPropertyFunction, DiffPropertyReaction, DNode, - RegistryLabel, Render, VirtualDomNode, WidgetMetaBase, @@ -156,7 +155,7 @@ export class WidgetBase

extends E /** * cached chldren map for instance management */ - private _cachedChildrenMap: Map | WidgetBaseConstructor, WidgetCacheWrapper[]>; + private _cachedChildrenMap: Map | WidgetBaseConstructor, WidgetCacheWrapper[]>; /** * map of specific property diff functions diff --git a/src/interfaces.d.ts b/src/interfaces.d.ts index 466c33b7..3a7d5b1a 100644 --- a/src/interfaces.d.ts +++ b/src/interfaces.d.ts @@ -230,7 +230,7 @@ export interface WidgetProperties { * The key for a widget. Used to differentiate uniquely identify child widgets for * rendering and instance management */ - key?: string; + key?: string | number; /** * Optional registry @@ -238,6 +238,18 @@ export interface WidgetProperties { registry?: any; } +/** + * Widget properties that require a key + */ +export interface KeyedWidgetProperties extends WidgetProperties { + + /** + * The key for a widget. Used to differentiate uniquely identify child widgets for + * rendering and instance management + */ + key: string | number; +} + /** * */ @@ -407,7 +419,7 @@ export interface WidgetBaseInterface< * Meta Base type */ export interface WidgetMetaBase extends Destroyable { - has(key: string): boolean; + has(key: string | number): boolean; } /** @@ -418,8 +430,8 @@ export interface WidgetMetaConstructor { } export interface NodeHandlerInterface extends Evented { - get(key: string): HTMLElement | undefined; - has(key: string): boolean; + get(key: string | number): HTMLElement | undefined; + has(key: string | number): boolean; add(element: HTMLElement, properties: VNodeProperties): void; addRoot(element: HTMLElement, properties: VNodeProperties): void; addProjector(element: HTMLElement, properties: VNodeProperties): void; diff --git a/src/meta/Base.ts b/src/meta/Base.ts index 1b2fb98f..bda317b9 100644 --- a/src/meta/Base.ts +++ b/src/meta/Base.ts @@ -6,7 +6,7 @@ export class Base extends Destroyable implements WidgetMetaBase { private _invalidate: () => void; protected nodeHandler: NodeHandlerInterface; - private _requestedNodeKeys = new Set(); + private _requestedNodeKeys = new Set(); constructor(properties: WidgetMetaProperties) { super(); @@ -15,15 +15,15 @@ export class Base extends Destroyable implements WidgetMetaBase { this.nodeHandler = properties.nodeHandler; } - public has(key: string): boolean { + public has(key: string | number): boolean { return this.nodeHandler.has(key); } - protected getNode(key: string): HTMLElement | undefined { + protected getNode(key: string | number): HTMLElement | undefined { const node = this.nodeHandler.get(key); if (!node && !this._requestedNodeKeys.has(key)) { - const handle = this.nodeHandler.on(key, () => { + const handle = this.nodeHandler.on(`${key}`, () => { handle.destroy(); this._requestedNodeKeys.delete(key); this.invalidate();