fix(overlay): error when removing empty string theme (#6306)

Something I ran into while doing #6305. If the previous overlay theme is a blank string, switching to another theme throws an error.
This commit is contained in:
Kristiyan Kostadinov
2017-08-07 23:23:47 +02:00
committed by mmalerba
parent 8b54715053
commit faa760104f
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -25,7 +25,9 @@ export class OverlayContainer {
get themeClass(): string { return this._themeClass; }
set themeClass(value: string) {
if (this._containerElement) {
this._containerElement.classList.remove(this._themeClass);
if (this._themeClass) {
this._containerElement.classList.remove(this._themeClass);
}
if (value) {
this._containerElement.classList.add(value);
+5
View File
@@ -476,6 +476,11 @@ describe('OverlayContainer theming', () => {
expect(overlayContainerElement.classList).not.toContain('initial-theme');
expect(overlayContainerElement.classList).toContain('new-theme');
});
it('should not throw when switching from a blank theme', () => {
overlayContainer.themeClass = '';
expect(() => overlayContainer.themeClass = 'new-theme').not.toThrow();
});
});
/** Simple component for testing ComponentPortal. */