Skip to content
Permalink
Browse files

feat(toast): allow html content (#18423)

  • Loading branch information...
liamdebeasi committed May 30, 2019
1 parent 17ad73a commit c8104a29ecfd5685fb2e7738b85e654377ffb323
@@ -46,6 +46,10 @@ test('toast: start end position', async () => {
await testToast(DIRECTORY, '#toast-start-and-end');
});

test('toast: html', async () => {
await testToast(DIRECTORY, '#toast-html');
});

/**
* RTL Tests
*/
@@ -93,3 +97,7 @@ test('toast:rtl: basic, custom class', async () => {
test('toast:rtl: start end position', async () => {
await testToast(DIRECTORY, '#toast-start-and-end', true);
});

test('toast:rtl: html', async () => {
await testToast(DIRECTORY, '#toast-html', true);
});
@@ -71,6 +71,10 @@
<ion-button expand="block" id="toast-start-and-end" onclick="presentToastWithOptions({message: 'click to close', showCloseButton: true, cssClass: 'toast-start-and-end'})">
Show Toast with start-end position
</ion-button>

<ion-button expand="block" id="toast-html" onclick="presentToastWithOptions({message: '<ion-button>Button in a Toast!</ion-button>', showCloseButton: true})">
Show HTML Toast
</ion-button>

<ion-toast-controller></ion-toast-controller>

@@ -2,6 +2,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Pr

import { Animation, AnimationBuilder, Color, Config, CssClassMap, Mode, OverlayEventDetail, OverlayInterface, ToastButton } from '../../interface';
import { dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
import { sanitizeDOMString } from '../../utils/sanitization';
import { createColorClasses, getClassMap } from '../../utils/theme';

import { iosEnterAnimation } from './animations/ios.enter';
@@ -290,7 +291,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
<div class="toast-header">{this.header}</div>
}
{this.message !== undefined &&
<div class="toast-message">{this.message}</div>
<div class="toast-message" innerHTML={sanitizeDOMString(this.message)}></div>
}
</div>

0 comments on commit c8104a2

Please sign in to comment.
You can’t perform that action at this time.