@@ -2,17 +2,12 @@ import PropTypes from '../_util/vue-types';
2
2
import ScrollNumber from './ScrollNumber' ;
3
3
import { PresetColorTypes } from '../_util/colors' ;
4
4
import classNames from 'classnames' ;
5
- import {
6
- initDefaultProps ,
7
- filterEmpty ,
8
- getComponentFromProp ,
9
- getListeners ,
10
- } from '../_util/props-util' ;
5
+ import { initDefaultProps , getComponent , getSlot } from '../_util/props-util' ;
11
6
import { cloneElement } from '../_util/vnode' ;
12
7
import getTransitionProps from '../_util/getTransitionProps' ;
13
8
import isNumeric from '../_util/isNumeric' ;
14
9
import { ConfigConsumerProps } from '../config-provider' ;
15
- import { inject } from 'vue' ;
10
+ import { inject , Transition } from 'vue' ;
16
11
17
12
const BadgeProps = {
18
13
/** Number to show in badge */
@@ -82,8 +77,7 @@ export default {
82
77
}
83
78
: { ...numberStyle } ;
84
79
} ,
85
- getBadgeClassName ( prefixCls ) {
86
- const children = filterEmpty ( this . $slots . default && this . $slots . default ( ) ) ;
80
+ getBadgeClassName ( prefixCls , children ) {
87
81
const hasStatus = this . hasStatus ( ) ;
88
82
return classNames ( prefixCls , {
89
83
[ `${ prefixCls } -status` ] : hasStatus ,
@@ -127,9 +121,13 @@ export default {
127
121
if ( ! customNode || typeof customNode !== 'object' ) {
128
122
return undefined ;
129
123
}
130
- return cloneElement ( customNode , {
131
- style : this . getStyleWithOffset ( ) ,
132
- } ) ;
124
+ return cloneElement (
125
+ customNode ,
126
+ {
127
+ style : this . getStyleWithOffset ( ) ,
128
+ } ,
129
+ false ,
130
+ ) ;
133
131
} ,
134
132
135
133
renderBadgeNumber ( prefixCls , scrollNumberPrefixCls ) {
@@ -158,8 +156,8 @@ export default {
158
156
< ScrollNumber
159
157
prefixCls = { scrollNumberPrefixCls }
160
158
data-show = { ! hidden }
161
- v-show = { ! hidden }
162
- className = { scrollNumberCls }
159
+ vShow = { ! hidden }
160
+ class = { scrollNumberCls }
163
161
count = { displayCount }
164
162
displayComponent = { this . renderDispayComponent ( ) }
165
163
title = { this . getScrollNumberTitle ( ) }
@@ -177,15 +175,14 @@ export default {
177
175
status,
178
176
text,
179
177
color,
180
- $slots,
181
178
} = this ;
182
179
183
180
const getPrefixCls = this . configProvider . getPrefixCls ;
184
181
const prefixCls = getPrefixCls ( 'badge' , customizePrefixCls ) ;
185
182
const scrollNumberPrefixCls = getPrefixCls ( 'scroll-number' , customizeScrollNumberPrefixCls ) ;
186
183
187
- const children = filterEmpty ( $slots . default && $slots . default ( ) ) ;
188
- let count = getComponentFromProp ( this , 'count' ) ;
184
+ const children = getSlot ( this ) ;
185
+ let count = getComponent ( this , 'count' ) ;
189
186
if ( Array . isArray ( count ) ) {
190
187
count = count [ 0 ] ;
191
188
}
@@ -206,11 +203,7 @@ export default {
206
203
const styleWithOffset = this . getStyleWithOffset ( ) ;
207
204
const statusTextColor = styleWithOffset && styleWithOffset . color ;
208
205
return (
209
- < span
210
- { ...{ on : getListeners ( this ) } }
211
- class = { this . getBadgeClassName ( prefixCls ) }
212
- style = { styleWithOffset }
213
- >
206
+ < span class = { this . getBadgeClassName ( prefixCls , children ) } style = { styleWithOffset } >
214
207
< span class = { statusCls } style = { statusStyle } />
215
208
< span style = { { color : statusTextColor } } class = { `${ prefixCls } -status-text` } >
216
209
{ text }
@@ -222,9 +215,9 @@ export default {
222
215
const transitionProps = getTransitionProps ( children . length ? `${ prefixCls } -zoom` : '' ) ;
223
216
224
217
return (
225
- < span { ... { on : getListeners ( this ) } } class = { this . getBadgeClassName ( prefixCls ) } >
218
+ < span class = { this . getBadgeClassName ( prefixCls , children ) } >
226
219
{ children }
227
- < transition { ...transitionProps } > { scrollNumber } </ transition >
220
+ < Transition { ...transitionProps } > { scrollNumber } </ Transition >
228
221
{ statusText }
229
222
</ span >
230
223
) ;
0 commit comments