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

fix: extraCommonProps not work properly #19572

Merged
merged 2 commits into from Nov 5, 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
2 changes: 1 addition & 1 deletion components/icon/IconFont.tsx
Expand Up @@ -44,7 +44,7 @@ export default function create(options: CustomIconOptions = {}): React.SFC<IconP
content = children;
}
return (
<Icon {...restProps} {...extraCommonProps}>
<Icon {...extraCommonProps} {...restProps}>
{content}
</Icon>
);
Expand Down
61 changes: 58 additions & 3 deletions components/icon/__tests__/__snapshots__/index.test.js.snap
Expand Up @@ -370,12 +370,67 @@ exports[`Icon support render svg as component 1`] = `
</i>
`;

exports[`Icon.createFromIconfontCN() extraCommonProps should works fine and can be overwritten 1`] = `
<div
class="icons-list"
>
<i
class="anticon bcd"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-tuichu"
/>
</svg>
</i>
<i
class="anticon abc"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-facebook"
/>
</svg>
</i>
<i
class="anticon efg"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-twitter"
/>
</svg>
</i>
</div>
`;

exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
<div
class="icons-list"
>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand All @@ -391,7 +446,7 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand All @@ -407,7 +462,7 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand Down
14 changes: 14 additions & 0 deletions components/icon/__tests__/index.test.js
Expand Up @@ -180,6 +180,9 @@ describe('Icon', () => {
describe('Icon.createFromIconfontCN()', () => {
const IconFont = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js',
extraCommonProps: {
className: 'abc',
},
});

it('should support iconfont.cn', () => {
Expand All @@ -192,6 +195,17 @@ describe('Icon.createFromIconfontCN()', () => {
);
expect(wrapper).toMatchSnapshot();
});

it('extraCommonProps should works fine and can be overwritten', () => {
const wrapper = render(
<div className="icons-list">
<IconFont type="icon-tuichu" className="bcd" />
<IconFont type="icon-facebook" />
<IconFont type="icon-twitter" className="efg" />
</div>,
);
expect(wrapper).toMatchSnapshot();
});
});

describe('utils', () => {
Expand Down