mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 23:58:13 +08:00
chore(): sync with main
This commit is contained in:
@ -4,6 +4,7 @@ import { Watch, Component, Element, Event, h, Host, Method, Prop } from '@stenci
|
||||
import { config } from '../../global/config';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import type { AnimationBuilder, Color, CssClassMap, OverlayInterface, FrameworkDelegate } from '../../interface';
|
||||
import { ENABLE_HTML_CONTENT_DEFAULT } from '../../utils/config';
|
||||
import { printIonWarning } from '../../utils/logging';
|
||||
import {
|
||||
createDelegateController,
|
||||
@ -49,6 +50,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
private readonly delegateController = createDelegateController(this);
|
||||
private readonly triggerController = createTriggerController();
|
||||
private currentTransition?: Promise<any>;
|
||||
private customHTMLEnabled = config.get('innerHTMLTemplatesEnabled', ENABLE_HTML_CONTENT_DEFAULT);
|
||||
private durationTimeout?: ReturnType<typeof setTimeout>;
|
||||
|
||||
presented = false;
|
||||
@ -111,6 +113,10 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
|
||||
/**
|
||||
* Message to be shown in the toast.
|
||||
* This property accepts custom HTML as a string.
|
||||
* Developers who only want to pass plain text
|
||||
* can disable the custom HTML functionality
|
||||
* by setting `innerHTMLTemplatesEnabled: false` in the Ionic config.
|
||||
*/
|
||||
@Prop() message?: string | IonicSafeString;
|
||||
|
||||
@ -401,6 +407,19 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
);
|
||||
}
|
||||
|
||||
private renderToastMessage() {
|
||||
const { customHTMLEnabled, message } = this;
|
||||
if (customHTMLEnabled) {
|
||||
return <div class="toast-message" part="message" innerHTML={sanitizeDOMString(message)}></div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="toast-message" part="message">
|
||||
{message}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { layout, el } = this;
|
||||
const allButtons = this.getButtons();
|
||||
@ -457,9 +476,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
{this.header}
|
||||
</div>
|
||||
)}
|
||||
{this.message !== undefined && (
|
||||
<div class="toast-message" part="message" innerHTML={sanitizeDOMString(this.message)}></div>
|
||||
)}
|
||||
{this.message !== undefined && this.renderToastMessage()}
|
||||
</div>
|
||||
|
||||
{this.renderButtons(endButtons, 'end')}
|
||||
|
||||
Reference in New Issue
Block a user