mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
fix icon miss viewBox (#14686)
This commit is contained in:
parent
6668c12c46
commit
0cb00e47b8
@ -333,6 +333,20 @@ exports[`Icon should support two-tone icon 1`] = `
|
|||||||
</i>
|
</i>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Icon support render svg as component 1`] = `
|
||||||
|
<i
|
||||||
|
aria-label="icon: undefined"
|
||||||
|
class="anticon"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
fill="currentColor"
|
||||||
|
height="1em"
|
||||||
|
viewBox="0 0 1024 1024"
|
||||||
|
width="1em"
|
||||||
|
/>
|
||||||
|
</i>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
|
exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
|
||||||
<div
|
<div
|
||||||
class="icons-list"
|
class="icons-list"
|
||||||
|
@ -94,6 +94,15 @@ describe('Icon', () => {
|
|||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('support render svg as component', () => {
|
||||||
|
const renderSvg = () => (
|
||||||
|
<svg viewBox="0 0 1024 1024" width="1em" height="1em" fill="currentColor" />
|
||||||
|
);
|
||||||
|
const SvgIcon = props => <Icon component={renderSvg} {...props} />;
|
||||||
|
|
||||||
|
expect(mount(<SvgIcon />).render()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
describe('warning on conflicting theme', () => {
|
describe('warning on conflicting theme', () => {
|
||||||
let errorSpy;
|
let errorSpy;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -121,6 +121,10 @@ const Icon: IconComponent<IconProps> = props => {
|
|||||||
viewBox,
|
viewBox,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!viewBox) {
|
||||||
|
delete innerSvgProps.viewBox;
|
||||||
|
}
|
||||||
|
|
||||||
// component > children > type
|
// component > children > type
|
||||||
if (Component) {
|
if (Component) {
|
||||||
innerNode = <Component {...innerSvgProps}>{children}</Component>;
|
innerNode = <Component {...innerSvgProps}>{children}</Component>;
|
||||||
|
Loading…
Reference in New Issue
Block a user