diff --git a/README.md b/README.md index 28b8c44..bd1d837 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ The following options can be React elements: - footer - closeButtonHtml - iconHtml + - loaderHtml ## Installation diff --git a/src/mounts.js b/src/mounts.js index cc68b8e..d0fec5f 100644 --- a/src/mounts.js +++ b/src/mounts.js @@ -31,4 +31,8 @@ export const mounts = [ key: 'iconHtml', getter: swal => swal.getIcon().querySelector('.swal2-icon-content'), }, + { + key: 'loaderHtml', + getter: swal => swal.getLoader(), + }, ] diff --git a/src/sweetalert2-react-content.d.ts b/src/sweetalert2-react-content.d.ts index 4ea9d49..ac3a6f0 100644 --- a/src/sweetalert2-react-content.d.ts +++ b/src/sweetalert2-react-content.d.ts @@ -45,6 +45,7 @@ interface ReactOptions { footer?: ReactElementOr<'footer'>; closeButtonHtml?: ReactElementOr<'closeButtonHtml'>; iconHtml?: ReactElementOr<'iconHtml'>; + loaderHtml?: ReactElementOr<'loaderHtml'>; } // Overwrite will take the properties of U and add to it the properties of T that are not in U. diff --git a/test/integration.test.js b/test/integration.test.js index fb9ac86..16f1a13 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -42,6 +42,7 @@ describe('integration', () => { title: title, html: html, iconHtml: @, + loaderHtml: %, confirmButtonText: confirmButtonText, denyButtonText: denyButtonText, cancelButtonText: cancelButtonText, @@ -58,6 +59,7 @@ describe('integration', () => { expect(MySwal.getIcon().innerHTML).toEqual('
@
') expect(MySwal.getFooter().innerHTML).toEqual('footer') expect(MySwal.getCloseButton().innerHTML).toEqual('closeButtonHtml') + expect(MySwal.getLoader().innerHTML).toEqual('%') } }) it('can mix React and non-React params', async () => { diff --git a/test/test-build.html b/test/test-build.html index 3636314..72e47ff 100644 --- a/test/test-build.html +++ b/test/test-build.html @@ -15,6 +15,7 @@ await MySwal.fire({ icon: 'success', iconHtml: React.createElement('b', {key: 'iconHtml'}, ['P']), + loaderHtml: React.createElement('b', {key: 'iconHtml'}, ['@']), title: React.createElement('i', {key: 'title'}, ['Hello World']), didOpen: (popup) => { console.log('didOpen', popup)