From b7e46038e0eee611bb9f5d83772804e83b19a63d Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 27 Mar 2023 12:07:00 -0400 Subject: [PATCH] fix(many): innerHTML is disabled by default (#27029) BREAKING CHANGE: The `innerHTMLTemplatesEnabled` Ionic Config now defaults to `false`. Developers can set this option to `true` if they would like to continue to use custom HTML features in `ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, and `ion-toast`. --- BREAKING.md | 5 +++++ core/src/components/alert/test/alert.spec.ts | 4 ++-- core/src/components/alert/test/basic/index.html | 6 ++++++ .../test/infinite-scroll-content.spec.ts | 4 ++-- core/src/components/loading/test/basic/index.html | 6 ++++++ core/src/components/loading/test/loading.spec.ts | 4 ++-- .../refresher-content/test/refresher-content.spec.ts | 6 +++--- core/src/components/toast/test/basic/index.html | 6 ++++++ core/src/components/toast/test/toast.spec.ts | 4 ++-- core/src/utils/config.ts | 2 +- 10 files changed, 35 insertions(+), 12 deletions(-) diff --git a/BREAKING.md b/BREAKING.md index 9726b59b11..01b7efca6a 100644 --- a/BREAKING.md +++ b/BREAKING.md @@ -35,6 +35,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver - [Textarea](#version-7x-textarea) - [Toggle](#version-7x-toggle) - [Virtual Scroll](#version-7x-virtual-scroll) +- [Config](#version-7x-config) - [Types](#version-7x-types) - [Overlay Attribute Interfaces](#version-7x-overlay-attribute-interfaces) - [JavaScript Frameworks](#version-7x-javascript-frameworks) @@ -297,6 +298,10 @@ Developers using the component will need to migrate to a virtual scroll solution Any references to the virtual scroll types from `@ionic/core` have been removed. Please remove or replace these types: `Cell`, `VirtualNode`, `CellType`, `NodeChange`, `HeaderFn`, `ItemHeightFn`, `FooterHeightFn`, `ItemRenderFn` and `DomRenderFn`. +

Config

+ +- `innerHTMLTemplatesEnabled` defaults to `false`. Developers who wish to use the `innerHTML` functionality inside of `ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, and `ion-toast` must set this config to `true` and properly sanitize their content. +

Types

Overlay Attribute Interfaces

diff --git a/core/src/components/alert/test/alert.spec.ts b/core/src/components/alert/test/alert.spec.ts index af4e6543f1..e5b2960849 100644 --- a/core/src/components/alert/test/alert.spec.ts +++ b/core/src/components/alert/test/alert.spec.ts @@ -3,7 +3,7 @@ import { Alert } from '../alert'; import { config } from '../../../global/config'; describe('alert: custom html', () => { - it('should allow for custom html by default', async () => { + it('should not allow for custom html by default', async () => { const page = await newSpecPage({ components: [Alert], html: ``, @@ -11,7 +11,7 @@ describe('alert: custom html', () => { const content = page.body.querySelector('.alert-message'); expect(content.textContent).toContain('Custom Text'); - expect(content.querySelector('button.custom-html')).not.toBe(null); + expect(content.querySelector('button.custom-html')).toBe(null); }); it('should allow for custom html', async () => { diff --git a/core/src/components/alert/test/basic/index.html b/core/src/components/alert/test/basic/index.html index 7ae66082d9..429223fa36 100644 --- a/core/src/components/alert/test/basic/index.html +++ b/core/src/components/alert/test/basic/index.html @@ -58,6 +58,12 @@