Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/message/__tests__/index.test.js
Expand Up @@ -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);
});
});
5 changes: 4 additions & 1 deletion components/message/index.tsx
Expand Up @@ -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 {
Expand Down