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

fix(snack-bar): not applying all panel classes in IE #8578

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [];
}
}