Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change diff type for Themed Mixin to auto #685

Merged
merged 1 commit into from Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/core/mixins/Themed.ts
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
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