test: update button snap
parent
7eeee692e7
commit
16e6118deb
|
@ -2,7 +2,7 @@
|
|||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 1`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!---->0</button>
|
||||
<!----><span>0</span></button>
|
||||
`;
|
||||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 2`] = `
|
||||
|
@ -12,7 +12,6 @@ exports[`Button fixbug renders {0} , 0 and {false} 2`] = `
|
|||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 3`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!---->
|
||||
<!----></button>
|
||||
`;
|
||||
|
||||
|
@ -23,7 +22,7 @@ exports[`Button renders Chinese characters correctly 1`] = `
|
|||
|
||||
exports[`Button renders Chinese characters correctly 2`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><span class="anticon anticon-search" role="img" aria-label="search"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span>按钮</button>
|
||||
<!----><span class="anticon anticon-search" role="img" aria-label="search"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>
|
||||
`;
|
||||
|
||||
exports[`Button renders Chinese characters correctly 3`] = `
|
||||
|
|
|
@ -2,7 +2,7 @@ import { inject, Text } from 'vue';
|
|||
import Wave from '../_util/wave';
|
||||
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
|
||||
import buttonTypes from './buttonTypes';
|
||||
import { filterEmpty, getSlot } from '../_util/props-util';
|
||||
import { getSlot, getComponent } from '../_util/props-util';
|
||||
import { ConfigConsumerProps } from '../config-provider';
|
||||
// eslint-disable-next-line no-console
|
||||
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
|
||||
|
@ -20,6 +20,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
this.children = [];
|
||||
this.iconCom = undefined;
|
||||
return {
|
||||
sizeMap: {
|
||||
large: 'lg',
|
||||
|
@ -133,14 +134,14 @@ export default {
|
|||
return child;
|
||||
},
|
||||
isNeedInserted() {
|
||||
const { icon, type } = this;
|
||||
return this.children.length === 1 && !icon && type !== 'link';
|
||||
const { iconCom, type } = this;
|
||||
return this.children.length === 1 && !iconCom && type !== 'link';
|
||||
},
|
||||
},
|
||||
render() {
|
||||
this.icon = getSlot(this, 'icon');
|
||||
const { type, htmlType, icon, disabled, handleClick, sLoading, $attrs } = this;
|
||||
const children = filterEmpty(getSlot(this));
|
||||
this.iconCom = getComponent(this, 'icon');
|
||||
const { type, htmlType, iconCom, disabled, handleClick, sLoading, $attrs } = this;
|
||||
const children = getSlot(this);
|
||||
this.children = children;
|
||||
const classes = this.getClasses();
|
||||
|
||||
|
@ -150,7 +151,7 @@ export default {
|
|||
class: classes,
|
||||
onClick: handleClick,
|
||||
};
|
||||
const iconNode = sLoading ? <LoadingOutlined /> : icon;
|
||||
const iconNode = sLoading ? <LoadingOutlined /> : iconCom;
|
||||
|
||||
const autoInsertSpace = this.configProvider.autoInsertSpaceInButton !== false;
|
||||
const kids = children.map(child =>
|
||||
|
|
|
@ -10,4 +10,5 @@ export default () => ({
|
|||
disabled: PropTypes.bool,
|
||||
ghost: PropTypes.bool,
|
||||
block: PropTypes.bool,
|
||||
icon: PropTypes.any,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue