diff --git a/src/WidgetBase.ts b/src/WidgetBase.ts index 47785611..19057eb4 100644 --- a/src/WidgetBase.ts +++ b/src/WidgetBase.ts @@ -421,7 +421,7 @@ export class WidgetBase
extends E
specificDecoratorList.push(...value);
}
else {
- const decorators = this._decoratorCache.get(decoratorKey) || [];
+ const decorators = this.getDecorator(decoratorKey);
this._decoratorCache.set(decoratorKey, [ ...decorators, ...value ]);
}
}
diff --git a/tests/unit/WidgetBase.ts b/tests/unit/WidgetBase.ts
index e6e3bc95..7211e629 100644
--- a/tests/unit/WidgetBase.ts
+++ b/tests/unit/WidgetBase.ts
@@ -1379,5 +1379,24 @@ registerSuite({
assert.equal(testWidget.getAfterRenders().length, 1);
assert.equal(testWidget2.getAfterRenders().length, 2);
+ },
+ 'decorator cache is populated when addDecorator is called after instantiation'() {
+ class TestWidget extends WidgetBase