diff --git a/components/_util/getTransitionProps.js b/components/_util/getTransitionProps.js index 7cd553023..6481bf4d1 100644 --- a/components/_util/getTransitionProps.js +++ b/components/_util/getTransitionProps.js @@ -4,10 +4,10 @@ const getTransitionProps = (transitionName, opt = {}) => { appear: true, css: false, onEnter: (el, done) => { - animate(el, `${transitionName}-enter`, done); + transitionName ? animate(el, `${transitionName}-enter`, done) : done(); }, onLeave: (el, done) => { - animate(el, `${transitionName}-leave`, done); + transitionName ? animate(el, `${transitionName}-leave`, done) : done(); }, ...opt, }; diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index f1652aa4f..69a01f7d8 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -26,6 +26,7 @@ const ScrollNumberProps = { component: PropTypes.string, title: PropTypes.oneOfType([PropTypes.number, PropTypes.string, null]), displayComponent: PropTypes.any, + onAnimated: PropTypes.func, }; export default { @@ -65,7 +66,7 @@ export default { animateStarted: false, sCount: count, }, - this.onAnimated, + this.handleAnimated, ); }); } @@ -102,7 +103,7 @@ export default { } return num; }, - onAnimated() { + handleAnimated() { this.$emit('animated'); }, @@ -165,11 +166,20 @@ export default { const { class: className, style = {} } = this.$attrs; if (displayComponent) { return cloneElement(displayComponent, { - class: `${prefixCls}-custom-component`, + class: classNames( + `${prefixCls}-custom-component`, + displayComponent.props && displayComponent.props.class, + ), }); } // fix https://fb.me/react-unknown-prop - const restProps = omit(this.$props, ['count', 'component', 'prefixCls', 'displayComponent']); + const restProps = omit({ ...this.$props, ...this.$attrs }, [ + 'count', + 'onAnimated', + 'component', + 'prefixCls', + 'displayComponent', + ]); const tempStyle = { ...style }; const newProps = { ...restProps, diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index f2a04eda5..2939e5279 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -2,20 +2,45 @@ exports[`Badge badge should support float number 1`] = `"3.5"`; -exports[`Badge badge should support float number 2`] = `3.5`; +exports[`Badge badge should support float number 2`] = `3.5`; -exports[`Badge render correct with negative number 1`] = `
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
-0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ -0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should be compatible with borderColor style 1`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should render when count is changed 1`] = `0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should render when count is changed 1`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should render when count is changed 2`] = `0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should render when count is changed 2`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should render when count is changed 3`] = `0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should render when count is changed 3`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should render when count is changed 4`] = `0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should render when count is changed 4`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should render when count is changed 5`] = `0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
`; +exports[`Badge should render when count is changed 5`] = ` +0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
+ +`; -exports[`Badge should support offset when count is a VueNode 1`] = `head`; +exports[`Badge should support offset when count is a VueNode 1`] = ` +head + +`;