mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 15:51:16 +08:00
Merge remote-tracking branch 'origin/main' into chore/sync-with-main-6
This commit is contained in:
@ -10,6 +10,7 @@ import {
|
||||
present,
|
||||
createDelegateController,
|
||||
createTriggerController,
|
||||
setOverlayId
|
||||
} from '@utils/overlays';
|
||||
import { sanitizeDOMString } from '@utils/sanitization';
|
||||
import { getClassMap } from '@utils/theme';
|
||||
@ -212,6 +213,7 @@ export class Loading implements ComponentInterface, OverlayInterface {
|
||||
const mode = getIonMode(this);
|
||||
this.spinner = config.get('loadingSpinner', config.get('spinner', mode === 'ios' ? 'lines' : 'crescent'));
|
||||
}
|
||||
setOverlayId(this.el);
|
||||
}
|
||||
|
||||
componentDidLoad() {
|
||||
|
||||
41
core/src/components/loading/test/loading-id.spec.ts
Normal file
41
core/src/components/loading/test/loading-id.spec.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { newSpecPage } from '@stencil/core/testing';
|
||||
|
||||
import { Loading } from '../loading';
|
||||
|
||||
it('loading should be assigned an incrementing id', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Loading],
|
||||
html: `<ion-loading is-open="true"></ion-loading>`,
|
||||
});
|
||||
let loading: HTMLIonLoadingElement;
|
||||
|
||||
loading = page.body.querySelector('ion-loading')!;
|
||||
|
||||
expect(loading).not.toBe(null);
|
||||
expect(loading.getAttribute('id')).toBe('ion-overlay-1');
|
||||
|
||||
// Remove the loading from the DOM
|
||||
loading.remove();
|
||||
await page.waitForChanges();
|
||||
|
||||
// Create a new loading to verify the id is incremented
|
||||
loading = document.createElement('ion-loading');
|
||||
loading.isOpen = true;
|
||||
page.body.appendChild(loading);
|
||||
await page.waitForChanges();
|
||||
|
||||
loading = page.body.querySelector('ion-loading')!;
|
||||
|
||||
expect(loading.getAttribute('id')).toBe('ion-overlay-2');
|
||||
|
||||
// Presenting the same loading again should reuse the existing id
|
||||
|
||||
loading.isOpen = false;
|
||||
await page.waitForChanges();
|
||||
loading.isOpen = true;
|
||||
await page.waitForChanges();
|
||||
|
||||
loading = page.body.querySelector('ion-loading')!;
|
||||
|
||||
expect(loading.getAttribute('id')).toBe('ion-overlay-2');
|
||||
});
|
||||
@ -1,15 +1,16 @@
|
||||
import { newSpecPage } from '@stencil/core/testing';
|
||||
import { Loading } from '../loading';
|
||||
import { config } from '../../../global/config';
|
||||
|
||||
describe('alert: custom html', () => {
|
||||
import { config } from '../../../global/config';
|
||||
import { Loading } from '../loading';
|
||||
|
||||
describe('loading: custom html', () => {
|
||||
it('should not allow for custom html by default', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Loading],
|
||||
html: `<ion-loading message="<button class='custom-html'>Custom Text</button>"></ion-loading>`,
|
||||
});
|
||||
|
||||
const content = page.body.querySelector('.loading-content');
|
||||
const content = page.body.querySelector('.loading-content')!;
|
||||
expect(content.textContent).toContain('Custom Text');
|
||||
expect(content.querySelector('button.custom-html')).toBe(null);
|
||||
});
|
||||
@ -21,7 +22,7 @@ describe('alert: custom html', () => {
|
||||
html: `<ion-loading message="<button class='custom-html'>Custom Text</button>"></ion-loading>`,
|
||||
});
|
||||
|
||||
const content = page.body.querySelector('.loading-content');
|
||||
const content = page.body.querySelector('.loading-content')!;
|
||||
expect(content.textContent).toContain('Custom Text');
|
||||
expect(content.querySelector('button.custom-html')).not.toBe(null);
|
||||
});
|
||||
@ -33,7 +34,7 @@ describe('alert: custom html', () => {
|
||||
html: `<ion-loading message="<button class='custom-html'>Custom Text</button>"></ion-loading>`,
|
||||
});
|
||||
|
||||
const content = page.body.querySelector('.loading-content');
|
||||
const content = page.body.querySelector('.loading-content')!;
|
||||
expect(content.textContent).toContain('Custom Text');
|
||||
expect(content.querySelector('button.custom-html')).toBe(null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user