fix(modal): title props support render function (#3031)

This commit is contained in:
John60676 2020-10-24 23:01:20 +08:00 committed by GitHub
parent 157d0e72e9
commit 9ac18c5e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -82,7 +82,9 @@ const ConfirmDialog = (_, { attrs }) => {
<div class={`${contentPrefixCls}-body`}>
{typeof icon === 'function' ? icon() : icon}
{attrs.title === undefined ? null : (
<span class={`${contentPrefixCls}-title`}>{attrs.title}</span>
<span class={`${contentPrefixCls}-title`}>
{typeof attrs.title === 'function' ? attrs.title() : attrs.title}
</span>
)}
<div class={`${contentPrefixCls}-content`}>
{typeof attrs.content === 'function' ? attrs.content() : attrs.content}

View File

@ -102,4 +102,12 @@ describe('Modal.confirm triggers callbacks correctly', () => {
expect($$(`.ant-modal-confirm-${type}`)).toHaveLength(0);
}
});
it('should render title', async () => {
open({
title: h => <span>title</span>,
});
await sleep();
expect($$('.ant-modal-confirm-title')[0].innerHTML).toBe('<span>title</span>');
});
});