Browse Source

Merge pull request #2297 from ddcat1115/fix-2258-spin

fix #2258 for `Spin` `Badge`
pull/2313/head
ddcat1115 9 years ago
committed by GitHub
parent
commit
54d02d32c9
  1. 13
      components/badge/ScrollNumber.jsx
  2. 5
      components/badge/index.jsx
  3. 10
      components/spin/index.jsx

13
components/badge/ScrollNumber.jsx

@ -1,6 +1,7 @@
import React, { createElement } from 'react';
import { findDOMNode } from 'react-dom';
import isCssAnimationSupported from '../_util/isCssAnimationSupported';
import omit from 'object.omit';
function getNumberArray(num) {
return num ?
@ -122,12 +123,18 @@ export default class ScrollNumber extends React.Component {
}
render() {
const { component, prefixCls, className, ...otherProps } = this.props;
// fix https://fb.me/react-unknown-prop
const restProps = omit(otherProps, [
'count',
'onAnimated',
]);
const props = {
...this.props,
className: `${this.props.prefixCls} ${this.props.className}`,
...restProps,
className: `${prefixCls} ${className}`,
};
return createElement(
this.props.component,
component,
props,
this.renderNumberElement()
);

5
components/badge/index.jsx

@ -21,8 +21,7 @@ export default class Badge extends React.Component {
}
render() {
let { count, prefixCls, overflowCount, className, style, children } = this.props;
const dot = this.props.dot;
let { count, prefixCls, overflowCount, className, style, children, dot, ...restProps } = this.props;
count = count > overflowCount ? `${overflowCount}+` : count;
@ -41,7 +40,7 @@ export default class Badge extends React.Component {
});
return (
<span className={badgeCls} title={count} {...this.props} style={null}>
<span className={badgeCls} title={count} {...restProps} style={null}>
{children}
<Animate component=""
showProp="data-show"

10
components/spin/index.jsx

@ -3,6 +3,7 @@ import { findDOMNode } from 'react-dom';
import classNames from 'classnames';
import isCssAnimationSupported from '../_util/isCssAnimationSupported';
import warning from 'warning';
import omit from 'object.omit';
export default class Spin extends React.Component {
static defaultProps = {
@ -75,8 +76,13 @@ export default class Spin extends React.Component {
[className]: !!className,
});
// fix https://fb.me/react-unknown-prop
const divProps = omit(restProps, [
'spinning',
]);
const spinElement = (
<div {...restProps} className={spinClassName}>
<div {...divProps} className={spinClassName}>
<span className={`${prefixCls}-dot`} />
<div className={`${prefixCls}-text`}>{tip || '加载中...'}</div>
</div>
@ -84,7 +90,7 @@ export default class Spin extends React.Component {
if (this.isNestedPattern()) {
return (
<div {...restProps} className={spinning ? (`${prefixCls}-nested-loading`) : ''}>
<div {...divProps} className={spinning ? (`${prefixCls}-nested-loading`) : ''}>
{spinElement}
<div className={`${prefixCls}-container`}>
{this.props.children}

Loading…
Cancel
Save