mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(snack-bar): not applying all panel classes in IE (#8578)
Fixes a regression that was causing the snack bar only to apply the first class that was specified via `panelClass`.
This commit is contained in:
committed by
tinayuangao
parent
741378a3f2
commit
a6d08472c9
@@ -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') {
|
||||
@@ -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 [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user