mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
fix: should support number 0 (#38006)
* fix: should support number `0` * fix: should support number `0` * test: add snap * test: add snap * test: add snap * test: add snap
This commit is contained in:
parent
02b1176c43
commit
19eabb0819
@ -83,7 +83,7 @@ const Breadcrumb: BreadcrumbInterface = ({
|
||||
}) => {
|
||||
const { getPrefixCls, direction } = React.useContext(ConfigContext);
|
||||
|
||||
let crumbs;
|
||||
let crumbs: React.ReactNode;
|
||||
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
|
||||
if (routes && routes.length > 0) {
|
||||
// generated by route
|
||||
|
@ -43,7 +43,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({
|
||||
return breadcrumbItem;
|
||||
};
|
||||
|
||||
let link;
|
||||
let link: React.ReactNode;
|
||||
if ('href' in restProps) {
|
||||
link = (
|
||||
<a className={`${prefixCls}-link`} {...restProps}>
|
||||
@ -60,7 +60,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({
|
||||
|
||||
// wrap to dropDown
|
||||
link = renderBreadcrumbNode(link);
|
||||
if (children) {
|
||||
if (children !== undefined && children !== null) {
|
||||
return (
|
||||
<li>
|
||||
{link}
|
||||
|
@ -157,4 +157,15 @@ describe('Breadcrumb', () => {
|
||||
);
|
||||
expect(asFragment().firstChild).toMatchSnapshot();
|
||||
});
|
||||
it('should support string `0` and number `0`', () => {
|
||||
const { container } = render(
|
||||
<Breadcrumb>
|
||||
<Breadcrumb.Item>{0}</Breadcrumb.Item>
|
||||
<Breadcrumb.Item>0</Breadcrumb.Item>
|
||||
</Breadcrumb>,
|
||||
);
|
||||
expect(container.querySelectorAll('.ant-breadcrumb-link')[0].textContent).toBe('0');
|
||||
expect(container.querySelectorAll('.ant-breadcrumb-link')[1].textContent).toBe('0');
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -323,3 +323,36 @@ exports[`Breadcrumb should support custom attribute 1`] = `
|
||||
</ol>
|
||||
</nav>
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb should support string \`0\` and number \`0\` 1`] = `
|
||||
<nav
|
||||
class="ant-breadcrumb"
|
||||
>
|
||||
<ol>
|
||||
<li>
|
||||
<span
|
||||
class="ant-breadcrumb-link"
|
||||
>
|
||||
0
|
||||
</span>
|
||||
<span
|
||||
class="ant-breadcrumb-separator"
|
||||
>
|
||||
/
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span
|
||||
class="ant-breadcrumb-link"
|
||||
>
|
||||
0
|
||||
</span>
|
||||
<span
|
||||
class="ant-breadcrumb-separator"
|
||||
>
|
||||
/
|
||||
</span>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
`;
|
||||
|
Loading…
Reference in New Issue
Block a user