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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Breadcrumb support data against #18941

Merged
merged 8 commits into from Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 7 additions & 1 deletion components/breadcrumb/Breadcrumb.tsx
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import * as PropTypes from 'prop-types';
import classNames from 'classnames';
import toArray from 'rc-util/lib/Children/toArray';
import omit from 'omit.js';
import BreadcrumbItem from './BreadcrumbItem';
import BreadcrumbSeparator from './BreadcrumbSeparator';
import Menu from '../menu';
Expand Down Expand Up @@ -144,6 +145,7 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
className,
routes,
children,
...restProps
} = this.props;
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
if (routes && routes.length > 0) {
Expand All @@ -169,7 +171,11 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
});
}
return (
<div className={classNames(className, prefixCls)} style={style}>
<div
className={classNames(className, prefixCls)}
style={style}
{...omit(restProps, ['itemRender', 'params'])}
sosohime marked this conversation as resolved.
Show resolved Hide resolved
>
{crumbs}
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions components/breadcrumb/__tests__/Breadcrumb.test.js
Expand Up @@ -102,4 +102,14 @@ describe('Breadcrumb', () => {
const wrapper = render(<Breadcrumb routes={routes} />);
expect(wrapper).toMatchSnapshot();
});

it('should support custom attribute', () => {
sosohime marked this conversation as resolved.
Show resolved Hide resolved
const wrapper = render(
<Breadcrumb data-custom="custom">
<Breadcrumb.Item>xxx</Breadcrumb.Item>
<Breadcrumb.Item>yyy</Breadcrumb.Item>
</Breadcrumb>,
);
expect(wrapper).toMatchSnapshot();
});
});
Expand Up @@ -157,3 +157,35 @@ exports[`Breadcrumb should render a menu 1`] = `
</span>
</div>
`;

exports[`Breadcrumb should support custom attribute 1`] = `
<div
class="ant-breadcrumb"
data-custom="custom"
>
<span>
<span
class="ant-breadcrumb-link"
>
xxx
</span>
<span
class="ant-breadcrumb-separator"
>
/
</span>
</span>
<span>
<span
class="ant-breadcrumb-link"
>
yyy
</span>
<span
class="ant-breadcrumb-separator"
>
/
</span>
</span>
</div>
`;
12 changes: 3 additions & 9 deletions components/menu/__tests__/index.test.js
Expand Up @@ -656,16 +656,10 @@ describe('Menu', () => {
collapsedWidth={0}
openKeys={['3']}
>
<Menu.Item key="1">
Option 1
</Menu.Item>
<Menu.Item key="2">
Option 2
</Menu.Item>
<Menu.Item key="1">Option 1</Menu.Item>
<Menu.Item key="2">Option 2</Menu.Item>
<Menu.SubMenu key="3" title="Option 3">
<Menu.Item key="4">
Option 4
</Menu.Item>
<Menu.Item key="4">Option 4</Menu.Item>
</Menu.SubMenu>
</Menu>,
);
Expand Down