Browse Source

fix icon miss viewBox (#14686)

pull/14708/head
zombieJ 6 years ago
committed by GitHub
parent
commit
0cb00e47b8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      components/icon/__tests__/__snapshots__/index.test.js.snap
  2. 9
      components/icon/__tests__/index.test.js
  3. 4
      components/icon/index.tsx

14
components/icon/__tests__/__snapshots__/index.test.js.snap

@ -333,6 +333,20 @@ exports[`Icon should support two-tone icon 1`] = `
</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`] = `
<div
class="icons-list"

9
components/icon/__tests__/index.test.js

@ -94,6 +94,15 @@ describe('Icon', () => {
}).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', () => {
let errorSpy;
beforeEach(() => {

4
components/icon/index.tsx

@ -121,6 +121,10 @@ const Icon: IconComponent<IconProps> = props => {
viewBox,
};
if (!viewBox) {
delete innerSvgProps.viewBox;
}
// component > children > type
if (Component) {
innerNode = <Component {...innerSvgProps}>{children}</Component>;

Loading…
Cancel
Save