From 79e25a342dde37ed264a1fcf3d40eef523383170 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 9 Aug 2016 16:23:12 -0400 Subject: [PATCH] feat(toast): add ability to pass multiple classes to cssClass references #7618 --- src/components/toast/test/basic/index.ts | 3 ++- src/components/toast/toast-component.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/toast/test/basic/index.ts b/src/components/toast/test/basic/index.ts index 2ab4b78da35..f43774e3fa1 100644 --- a/src/components/toast/test/basic/index.ts +++ b/src/components/toast/test/basic/index.ts @@ -47,7 +47,8 @@ class E2EPage { showLongToast() { const toast = this.toastCtrl.create({ message: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea voluptatibus quibusdam eum nihil optio, ullam accusamus magni, nobis suscipit reprehenderit, sequi quam amet impedit. Accusamus dolorem voluptates laborum dolor obcaecati.', - duration: 5000 + duration: 5000, + cssClass: 'custom-class my-toast' }); toast.onDidDismiss(this.dismissHandler); diff --git a/src/components/toast/toast-component.ts b/src/components/toast/toast-component.ts index 150a4babad5..43111ed6660 100644 --- a/src/components/toast/toast-component.ts +++ b/src/components/toast/toast-component.ts @@ -35,7 +35,15 @@ import { ViewController } from '../nav/view-controller'; }, }) export class ToastCmp implements AfterViewInit { - private d: any; + private d: { + message?: string; + cssClass?: string; + duration?: number; + showCloseButton?: boolean; + closeButtonText?: string; + dismissOnPageChange?: boolean; + position?: string; + }; private descId: string; private dismissTimeout: number = undefined; private enabled: boolean; @@ -53,7 +61,10 @@ export class ToastCmp implements AfterViewInit { this.d = params.data; if (this.d.cssClass) { - renderer.setElementClass(_elementRef.nativeElement, this.d.cssClass, true); + this.d.cssClass.split(' ').forEach(cssClass => { + // Make sure the class isn't whitespace, otherwise it throws exceptions + if (cssClass.trim() !== '') renderer.setElementClass(_elementRef.nativeElement, cssClass, true); + }); } this.id = (++toastIds);