fix: use Object.prototype.toString to check object (#20546)

close #20528
This commit is contained in:
DiamondYuan 2019-12-30 22:14:17 +08:00 committed by 偏右
parent 8ea9356399
commit 4297f33e85
2 changed files with 8 additions and 1 deletions

View File

@ -189,4 +189,8 @@ describe('message', () => {
jest.advanceTimersByTime(1500);
expect(document.querySelectorAll('.ant-message-notice').length).toBe(0);
});
it('should not throw error when pass null', () => {
message.error(null);
});
});

View File

@ -114,7 +114,10 @@ type JointContent = ConfigContent | ArgsProps;
export type ConfigOnClose = () => void;
function isArgsProps(content: JointContent): content is ArgsProps {
return typeof content === 'object' && !!(content as ArgsProps).content;
return (
Object.prototype.toString.call(content) === '[object Object]' &&
!!(content as ArgsProps).content
);
}
export interface ConfigOptions {