Skip to content

Commit

Permalink
Change diff type for Themed mixin to auto
Browse files Browse the repository at this point in the history
  • Loading branch information
agubler committed Mar 18, 2020
1 parent 4d03fae commit 2ebe4db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/mixins/Themed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { inject } from './../decorators/inject';
import { WidgetBase } from './../WidgetBase';
import { handleDecorator } from './../decorators/handleDecorator';
import { diffProperty } from './../decorators/diffProperty';
import { shallow } from './../diff';

export { Theme, Classes, ClassNames } from './../interfaces';

Expand Down Expand Up @@ -144,9 +143,9 @@ export function ThemedMixin<E, T extends Constructor<WidgetBase<ThemedProperties
/**
* Function fired when `theme` or `extraClasses` are changed.
*/
@diffProperty('theme', shallow)
@diffProperty('extraClasses', shallow)
@diffProperty('classes', shallow)
@diffProperty('theme')
@diffProperty('extraClasses')
@diffProperty('classes')
protected onPropertiesChanged() {
this._recalculateClasses = true;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/core/unit/mixins/Themed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,25 @@ registerSuite('ThemedMixin', {
testWidget.__setProperties__({ foo: 'bar' });
renderResult = testWidget.__render__() as VNode;
assert.deepEqual(renderResult.properties.classes, 'theme1Class1');
},
'should not invalidate when previous and current theme is undefined'() {
let invalidateStub = stub();
class UndefinedTheme extends TestWidget {
invalidate() {
invalidateStub();
super.invalidate();
}
}

const testWidget = new UndefinedTheme();
assert.isTrue(invalidateStub.notCalled);
testWidget.registry.base = testRegistry;
testWidget.__setProperties__({ theme: undefined, classes: undefined, extraClasses: undefined });
testWidget.__render__() as VNode;
assert.isTrue(invalidateStub.notCalled);
testWidget.__setProperties__({ theme: undefined, classes: undefined, extraClasses: undefined });
testWidget.__render__() as VNode;
assert.isTrue(invalidateStub.notCalled);
}
},
integration: {
Expand Down

0 comments on commit 2ebe4db

Please sign in to comment.