Skip to content

Commit

Permalink
fix(snack-bar): not applying all panel classes in IE (#8578)
Browse files Browse the repository at this point in the history
Fixes a regression that was causing the snack bar only to apply the first class that was specified via `panelClass`.
  • Loading branch information
crisbeto authored and tinayuangao committed Nov 28, 2017
1 parent 741378a commit a6d0847
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/lib/snack-bar/snack-bar-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
const element: HTMLElement = this._elementRef.nativeElement;

if (this.snackBarConfig.panelClass || this.snackBarConfig.extraClasses) {
element.classList.add(...this._getCssClasses(this.snackBarConfig.panelClass),
...this._getCssClasses(this.snackBarConfig.extraClasses));
this._setCssClasses(this.snackBarConfig.panelClass);
this._setCssClasses(this.snackBarConfig.extraClasses);
}

if (this.snackBarConfig.horizontalPosition === 'center') {
Expand Down Expand Up @@ -176,15 +176,19 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
});
}

/** Convert the class list to a array of classes it can apply to the dom */
private _getCssClasses(classList: undefined | string | string[]) {
if (classList) {
if (Array.isArray(classList)) {
return classList;
} else {
return [classList];
}
/** Applies the user-specified list of CSS classes to the element. */
private _setCssClasses(classList: undefined|string|string[]) {
if (!classList) {
return;
}

const element = this._elementRef.nativeElement;

if (Array.isArray(classList)) {
// Note that we can't use a spread here, because IE doesn't support multiple arguments.
classList.forEach(cssClass => element.classList.add(cssClass));
} else {
element.classList.add(classList);
}
return [];
}
}

0 comments on commit a6d0847

Please sign in to comment.