From 0cb00e47b8468b75bffd000e7860a3b36b85d823 Mon Sep 17 00:00:00 2001 From: zombieJ Date: Fri, 1 Feb 2019 23:04:41 +0800 Subject: [PATCH] fix icon miss viewBox (#14686) --- .../__tests__/__snapshots__/index.test.js.snap | 14 ++++++++++++++ components/icon/__tests__/index.test.js | 9 +++++++++ components/icon/index.tsx | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/components/icon/__tests__/__snapshots__/index.test.js.snap b/components/icon/__tests__/__snapshots__/index.test.js.snap index 3f374700bd..325441a7cd 100644 --- a/components/icon/__tests__/__snapshots__/index.test.js.snap +++ b/components/icon/__tests__/__snapshots__/index.test.js.snap @@ -333,6 +333,20 @@ exports[`Icon should support two-tone icon 1`] = ` `; +exports[`Icon support render svg as component 1`] = ` + + + +`; + exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
{ }).not.toThrow(); }); + it('support render svg as component', () => { + const renderSvg = () => ( + + ); + const SvgIcon = props => ; + + expect(mount().render()).toMatchSnapshot(); + }); + describe('warning on conflicting theme', () => { let errorSpy; beforeEach(() => { diff --git a/components/icon/index.tsx b/components/icon/index.tsx index 59567a2808..caa214d6e4 100755 --- a/components/icon/index.tsx +++ b/components/icon/index.tsx @@ -121,6 +121,10 @@ const Icon: IconComponent = props => { viewBox, }; + if (!viewBox) { + delete innerSvgProps.viewBox; + } + // component > children > type if (Component) { innerNode = {children};