From 488f5a101d8460b7a689c3f2526ae2cba7af8d6f Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 6 Nov 2018 11:39:49 +0800 Subject: [PATCH] Fix compatibility, #12970 --- components/icon/demo/old-icons.md | 1 + components/icon/index.tsx | 3 ++- components/icon/utils.ts | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/icon/demo/old-icons.md b/components/icon/demo/old-icons.md index 20315d2ee6..47ea3da245 100644 --- a/components/icon/demo/old-icons.md +++ b/components/icon/demo/old-icons.md @@ -93,6 +93,7 @@ const icons = [ 'exclamation-circle-o', 'exclamation-circle', 'close', + 'cross', 'close-circle', 'close-circle-o', 'close-square', diff --git a/components/icon/index.tsx b/components/icon/index.tsx index cb6b0e0abc..2da0b3fc7b 100755 --- a/components/icon/index.tsx +++ b/components/icon/index.tsx @@ -6,6 +6,7 @@ import createFromIconfontCN from './IconFont'; import { svgBaseProps, withThemeSuffix, removeTypeTheme, getThemeFromTypeName, + alias, } from './utils'; import warning from '../_util/warning'; import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor'; @@ -135,7 +136,7 @@ const Icon: IconComponent = (props) => { ` the 'theme' prop '${theme}' will be ignored.`); } computedType = withThemeSuffix( - removeTypeTheme(type), + removeTypeTheme(alias(type)), dangerousTheme || theme || defaultTheme, ); innerNode = ( diff --git a/components/icon/utils.ts b/components/icon/utils.ts index 9b3c42ea34..5e77a2f70c 100644 --- a/components/icon/utils.ts +++ b/components/icon/utils.ts @@ -47,3 +47,13 @@ export function withThemeSuffix(type: string, theme: ThemeType) { } return result; } + +// For alias or compatibility +export function alias(type: string) { + switch (type) { + case 'cross': + return 'close'; + default: + } + return type; +}