mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
feat(toast): allow html content (#18423)
This commit is contained in:
@ -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);
|
||||
});
|
||||
|
||||
@ -72,6 +72,10 @@
|
||||
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>
|
||||
|
||||
<ion-grid>
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user