Skip to content

Commit

Permalink
fix(overlay): error when removing empty string theme (#6306)
Browse files Browse the repository at this point in the history
Something I ran into while doing #6305. If the previous overlay theme is a blank string, switching to another theme throws an error.
  • Loading branch information
crisbeto authored and mmalerba committed Aug 7, 2017
1 parent 8b54715 commit faa7601
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/core/overlay/overlay-container.ts
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/lib/core/overlay/overlay.spec.ts
Expand Up @@ -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. */
Expand Down

0 comments on commit faa7601

Please sign in to comment.