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

pull/3052/head
John60676 2020-10-24 23:33:24 +08:00 committed by GitHub
parent 4a3e310db7
commit 6c521620b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -94,7 +94,9 @@ export default {
<div class={`${contentPrefixCls}-body`}>
{iconNode}
{props.title === undefined ? null : (
<span class={`${contentPrefixCls}-title`}>{props.title}</span>
<span class={`${contentPrefixCls}-title`}>
{typeof props.title === 'function' ? props.title(h) : props.title}
</span>
)}
<div class={`${contentPrefixCls}-content`}>
{typeof props.content === 'function' ? props.content(h) : props.content}

View File

@ -88,7 +88,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
expect($$('.ant-btn')[1].disabled).toBe(true);
});
fit('trigger onCancel once when click on cancel button', async () => {
it('trigger onCancel once when click on cancel button', async () => {
const arr = ['info', 'success', 'warning', 'error'];
for (let type of arr) {
Modal[type]({
@ -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>');
});
});