Skip to content

Commit 37ddc96

Browse files
committed
Merge branch 'feat-vue3' of https://github.com/vueComponent/ant-design-vue into feat-vue3
2 parents 6fa4f9c + 0e0ad46 commit 37ddc96

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

components/badge/Badge.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const BadgeProps = {
2121
scrollNumberPrefixCls: PropTypes.string,
2222
status: PropTypes.oneOf(['success', 'processing', 'default', 'error', 'warning']),
2323
color: PropTypes.string,
24-
text: PropTypes.string,
24+
text: PropTypes.any,
2525
offset: PropTypes.array,
2626
numberStyle: PropTypes.object.def(() => ({})),
2727
title: PropTypes.string,
@@ -110,7 +110,7 @@ export default {
110110
},
111111

112112
renderStatusText(prefixCls) {
113-
const { text } = this.$props;
113+
const text = getComponent(this, 'text');
114114
const hidden = this.isHidden();
115115
return hidden || !text ? null : <span class={`${prefixCls}-status-text`}>{text}</span>;
116116
},
@@ -173,10 +173,10 @@ export default {
173173
prefixCls: customizePrefixCls,
174174
scrollNumberPrefixCls: customizeScrollNumberPrefixCls,
175175
status,
176-
text,
177176
color,
178177
} = this;
179178

179+
const text = getComponent(this, 'text');
180180
const getPrefixCls = this.configProvider.getPrefixCls;
181181
const prefixCls = getPrefixCls('badge', customizePrefixCls);
182182
const scrollNumberPrefixCls = getPrefixCls('scroll-number', customizeScrollNumberPrefixCls);

components/badge/__tests__/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ exports[`Badge should support offset when count is a VueNode 1`] = `
4444
<span class="ant-badge"><a href="#" class="head-example">head</a><span class="ant-scroll-number-custom-component custom ant-badge-zoom-enter" style="color: rgb(245, 34, 45); right: -10px; margin-top: 20px;"></span>
4545
<!----></span>
4646
`;
47+
48+
exports[`Badge text works with vnode 1`] = `<span class="ant-badge ant-badge-status ant-badge-not-a-wrapper"><span class="ant-badge-status-dot ant-badge-status-success"></span><span class="ant-badge-status-text"><span>hello</span></span></span>`;

components/badge/__tests__/index.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,14 @@ describe('Badge', () => {
136136
});
137137
expect(wrapper.html()).toMatchSnapshot();
138138
});
139+
140+
it('text works with vnode', () => {
141+
const wrapper = mount({
142+
render() {
143+
return <Badge status="success" text={<span>hello</span>} />;
144+
},
145+
});
146+
147+
expect(wrapper.html()).toMatchSnapshot();
148+
});
139149
});

types/badge.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export declare class Badge extends AntdComponent {
5252
* If status is set, text sets the display text of the status dot
5353
* @type string
5454
*/
55-
text?: string;
55+
text?: VNodeChild | JSX.Element;
5656

5757
/**
5858
* sets the display style of the status dot

0 commit comments

Comments
 (0)