Fix <Icon type="cross" /> compatibility, #12970

This commit is contained in:
afc163 2018-11-06 11:39:49 +08:00
parent 4c5e3492ac
commit 488f5a101d
3 changed files with 13 additions and 1 deletions

View File

@ -93,6 +93,7 @@ const icons = [
'exclamation-circle-o', 'exclamation-circle-o',
'exclamation-circle', 'exclamation-circle',
'close', 'close',
'cross',
'close-circle', 'close-circle',
'close-circle-o', 'close-circle-o',
'close-square', 'close-square',

View File

@ -6,6 +6,7 @@ import createFromIconfontCN from './IconFont';
import { import {
svgBaseProps, withThemeSuffix, svgBaseProps, withThemeSuffix,
removeTypeTheme, getThemeFromTypeName, removeTypeTheme, getThemeFromTypeName,
alias,
} from './utils'; } from './utils';
import warning from '../_util/warning'; import warning from '../_util/warning';
import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor'; import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
@ -135,7 +136,7 @@ const Icon: IconComponent<IconProps> = (props) => {
` the 'theme' prop '${theme}' will be ignored.`); ` the 'theme' prop '${theme}' will be ignored.`);
} }
computedType = withThemeSuffix( computedType = withThemeSuffix(
removeTypeTheme(type), removeTypeTheme(alias(type)),
dangerousTheme || theme || defaultTheme, dangerousTheme || theme || defaultTheme,
); );
innerNode = ( innerNode = (

View File

@ -47,3 +47,13 @@ export function withThemeSuffix(type: string, theme: ThemeType) {
} }
return result; return result;
} }
// For alias or compatibility
export function alias(type: string) {
switch (type) {
case 'cross':
return 'close';
default:
}
return type;
}