diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index d218a0432e..d3a2fd1f06 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -1,5 +1,4 @@ import React, { createElement } from 'react'; -import assign from 'object-assign'; import { isCssAnimationSupported } from 'css-animation'; function getNumberArray(num) { @@ -94,9 +93,10 @@ export default class ScrollNumber extends React.Component { } render() { - const props = assign({}, this.props, { + const props = { + ...this.props, className: `${this.props.prefixCls} ${this.props.className}` - }); + }; const isBrowser = (typeof document !== 'undefined' && typeof window !== 'undefined'); if (isBrowser && isCssAnimationSupported) { return createElement( diff --git a/components/carousel/index.jsx b/components/carousel/index.jsx index a27072fc96..c914142178 100644 --- a/components/carousel/index.jsx +++ b/components/carousel/index.jsx @@ -15,11 +15,10 @@ if (typeof window !== 'undefined') { import SlickCarousel from 'react-slick'; import React from 'react'; -import assign from 'object-assign'; export default class Carousel extends React.Component { render() { - let props = assign({}, this.props); + let props = { ...this.props }; if (props.effect === 'fade') { props.fade = true; diff --git a/components/date-picker/PickerMixin.jsx b/components/date-picker/PickerMixin.jsx index f936dabe69..5746016c75 100644 --- a/components/date-picker/PickerMixin.jsx +++ b/components/date-picker/PickerMixin.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import objectAssign from 'object-assign'; import defaultLocale from './locale/zh_CN'; import DateTimeFormat from 'gregorian-calendar-format'; import GregorianCalendar from 'gregorian-calendar'; @@ -15,8 +14,8 @@ export default { locale = this.context.antLocale.DatePicker; } // 统一合并为完整的 Locale - const result = objectAssign({}, locale, this.props.locale); - result.lang = objectAssign({}, locale.lang, this.props.locale.lang); + const result = { ...locale, ...this.props.locale }; + result.lang = { ...locale.lang, ...this.props.locale.lang }; return result; }, diff --git a/components/date-picker/locale/en_US.js b/components/date-picker/locale/en_US.js index aff512e58b..0cc48401b5 100644 --- a/components/date-picker/locale/en_US.js +++ b/components/date-picker/locale/en_US.js @@ -1,13 +1,13 @@ -import objectAssign from 'object-assign'; import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US'; import CalendarLocale from 'rc-calendar/lib/locale/en_US'; // 统一合并为完整的 Locale -let locale = objectAssign({}, GregorianCalendarLocale); -locale.lang = objectAssign({ +let locale = { ...GregorianCalendarLocale }; +locale.lang = { placeholder: 'Select date', timePlaceholder: 'Select time', -}, CalendarLocale); + ...CalendarLocale, +}; // All settings at: // https://github.com/ant-design/ant-design/issues/424 diff --git a/components/date-picker/locale/zh_CN.js b/components/date-picker/locale/zh_CN.js index b6a9177c70..b9d4f003c6 100644 --- a/components/date-picker/locale/zh_CN.js +++ b/components/date-picker/locale/zh_CN.js @@ -1,13 +1,13 @@ -import objectAssign from 'object-assign'; import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/zh_CN'; import CalendarLocale from 'rc-calendar/lib/locale/zh_CN'; // 统一合并为完整的 Locale -let locale = objectAssign({}, GregorianCalendarLocale); -locale.lang = objectAssign({ +let locale = { ...GregorianCalendarLocale }; +locale.lang = { placeholder: '请选择日期', timePlaceholder: '请选择时间', -}, CalendarLocale); + ...CalendarLocale, +}; // should add whitespace between char in Button locale.lang.ok = '确 定'; diff --git a/components/input/index.jsx b/components/input/index.jsx index 8dd00ba541..9fe44b2100 100644 --- a/components/input/index.jsx +++ b/components/input/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import assign from 'object-assign'; import classNames from 'classnames'; function ieGT9() { @@ -67,7 +66,7 @@ class Input extends React.Component { } renderInput() { - const props = assign({}, this.props); + const props = { ...this.props }; const prefixCls = props.prefixCls; if (!props.type) { return props.children; diff --git a/components/modal/confirm.jsx b/components/modal/confirm.jsx index 10a1c2f0c4..a95c81ffa6 100644 --- a/components/modal/confirm.jsx +++ b/components/modal/confirm.jsx @@ -3,7 +3,6 @@ import ReactDOM from 'react-dom'; import Dialog from './Modal'; import Icon from '../icon'; import Button from '../button'; -import objectAssign from 'object-assign'; const defaultLocale = { okText: '确定', @@ -15,14 +14,14 @@ let runtimeLocale = { ...defaultLocale }; export function changeConfirmLocale(newLocale) { if (newLocale) { - objectAssign(runtimeLocale, newLocale); + runtimeLocale = { ...runtimeLocale, ...newLocale }; } else { runtimeLocale = { ...defaultLocale }; } } export default function confirm(config) { - const props = objectAssign({}, config); + const props = { ...config }; let div = document.createElement('div'); document.body.appendChild(div); diff --git a/components/modal/index.jsx b/components/modal/index.jsx index ebfabe515f..b8e7548290 100644 --- a/components/modal/index.jsx +++ b/components/modal/index.jsx @@ -1,35 +1,38 @@ import Modal from './Modal'; import confirm from './confirm'; -import objectAssign from 'object-assign'; Modal.info = function (props) { - const config = objectAssign({}, props, { + const config = { + ...props, iconClassName: 'info-circle', okCancel: false, - }); + }; return confirm(config); }; Modal.success = function (props) { - const config = objectAssign({}, props, { + const config = { + ...props, iconClassName: 'check-circle', okCancel: false, - }); + }; return confirm(config); }; Modal.error = function (props) { - const config = objectAssign({}, props, { + const config = { + ...props, iconClassName: 'exclamation-circle', okCancel: false, - }); + }; return confirm(config); }; Modal.confirm = function (props) { - const config = objectAssign({}, props, { + const config = { + ...props, okCancel: true, - }); + }; return confirm(config); }; diff --git a/components/notification/index.jsx b/components/notification/index.jsx index 546af285bc..70699eb0e3 100644 --- a/components/notification/index.jsx +++ b/components/notification/index.jsx @@ -1,6 +1,5 @@ import React from 'react'; import Notification from 'rc-notification'; -import assign from 'object-assign'; import Icon from '../icon'; let defaultTop = 24; @@ -124,9 +123,10 @@ const api = { ['success', 'info', 'warn', 'error'].forEach((type) => { api[type] = (args) => { - let newArgs = assign({}, args, { + let newArgs = { + ...args, icon: type - }); + }; return api.open(newArgs); }; }); diff --git a/components/progress/index.jsx b/components/progress/index.jsx index ba5245e450..56ec39a298 100644 --- a/components/progress/index.jsx +++ b/components/progress/index.jsx @@ -1,6 +1,5 @@ import { Circle as Progresscircle } from 'rc-progress'; import React from 'react'; -import assign from 'object-assign'; import warning from 'warning'; import Icon from '../icon'; @@ -35,7 +34,7 @@ let Line = React.createClass({ }; }, render() { - let props = assign({}, this.props); + let props = { ...this.props }; if (parseInt(props.percent, 10) === 100) { props.status = 'success'; @@ -119,7 +118,7 @@ let Circle = React.createClass({ }; }, render() { - let props = assign({}, this.props); + let props = { ...this.props }; if (parseInt(props.percent, 10) === 100) { props.status = 'success'; diff --git a/components/table/index.jsx b/components/table/index.jsx index acf6645175..a7ea84d80c 100644 --- a/components/table/index.jsx +++ b/components/table/index.jsx @@ -5,7 +5,6 @@ import Radio from '../radio'; import FilterDropdown from './filterDropdown'; import Pagination from '../pagination'; import Icon from '../icon'; -import objectAssign from 'object-assign'; import Spin from '../spin'; import classNames from 'classnames'; import { flatArray } from './util'; @@ -39,10 +38,11 @@ let Table = React.createClass({ sorter: null, radioIndex: null, pagination: this.hasPagination() ? - objectAssign({ - size: this.props.size, - }, defaultPagination, this.props.pagination) : - {}, + { + size: this.props.size, + ...defaultPagination, + ...this.props.pagination, + } : {}, }; }, @@ -93,13 +93,13 @@ let Table = React.createClass({ if (this.context.antLocale && this.context.antLocale.Table) { locale = this.context.antLocale.Table; } - return objectAssign({}, defaultLocale, locale, this.props.locale); + return { ...defaultLocale, ...locale, ...this.props.locale }; }, componentWillReceiveProps(nextProps) { if (('pagination' in nextProps) && nextProps.pagination !== false) { this.setState({ - pagination: objectAssign({}, defaultPagination, this.state.pagination, nextProps.pagination) + pagination: { ...defaultPagination, ...this.state.pagination, ...nextProps.pagination }, }); } // dataSource 的变化会清空选中项 @@ -171,9 +171,10 @@ let Table = React.createClass({ }, handleFilter(column, nextFilters) { - const filters = objectAssign({}, this.state.filters, { + const filters = { + ...this.state.filters, [this.getColumnKey(column)]: nextFilters - }); + }; // Remove filters not in current columns const currentColumnKeys = this.props.columns.map(c => this.getColumnKey(c)); Object.keys(filters).forEach((columnKey) => { @@ -276,7 +277,7 @@ let Table = React.createClass({ }, handlePageChange(current) { - let pagination = objectAssign({}, this.state.pagination); + let pagination = { ...this.state.pagination }; if (current) { pagination.current = current; } else { @@ -416,7 +417,7 @@ let Table = React.createClass({ renderColumnsDropdown(columns) { const locale = this.getLocale(); return columns.map((originColumn, i) => { - let column = objectAssign({}, originColumn); + let column = { ...originColumn }; let key = this.getColumnKey(column, i); let filterDropdown; let sortButton; @@ -587,7 +588,7 @@ let Table = React.createClass({ columns = this.renderColumnsDropdown(columns); columns = columns.map((column, i) => { - const newColumn = objectAssign({}, column); + const newColumn = { ...column }; newColumn.key = newColumn.key || newColumn.dataIndex || i; return newColumn; }); diff --git a/components/time-picker/index.jsx b/components/time-picker/index.jsx index c101430b57..8695b5e89a 100644 --- a/components/time-picker/index.jsx +++ b/components/time-picker/index.jsx @@ -1,7 +1,6 @@ import React from 'react'; import DateTimeFormat from 'gregorian-calendar-format'; import RcTimePicker from 'rc-time-picker/lib/TimePicker'; -import objectAssign from 'object-assign'; import defaultLocale from './locale/zh_CN'; import classNames from 'classnames'; import GregorianCalendar from 'gregorian-calendar'; @@ -77,12 +76,12 @@ const TimePicker = React.createClass({ locale = this.context.antLocale.TimePicker; } // 统一合并为完整的 Locale - return objectAssign({}, locale, this.props.locale); + return { ...locale, ...this.props.locale }; }, render() { const locale = this.getLocale(); - const props = objectAssign({}, this.props); + const props = { ...this.props }; props.placeholder = ('placeholder' in this.props) ? props.placeholder : locale.placeholder; if (props.defaultValue) { diff --git a/components/upload/index.jsx b/components/upload/index.jsx index 91ab98b322..350fba5323 100644 --- a/components/upload/index.jsx +++ b/components/upload/index.jsx @@ -1,6 +1,5 @@ import React from 'react'; import RcUpload from 'rc-upload'; -import assign from 'object-assign'; import UploadList from './uploadList'; import getFileItem from './getFileItem'; import classNames from 'classnames'; @@ -218,13 +217,14 @@ const Upload = React.createClass({ render() { let type = this.props.type || 'select'; - let props = assign({}, this.props, { + let props = { + ...this.props, onStart: this.onStart, onError: this.onError, onProgress: this.onProgress, onSuccess: this.onSuccess, beforeUpload: this.beforeUpload, - }); + }; let uploadList; if (this.props.showUploadList) { uploadList = ( diff --git a/package.json b/package.json index fcc083f72d..0c45be6b0f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "css-animation": "~1.1.0", "gregorian-calendar": "~4.1.0", "gregorian-calendar-format": "~4.1.0", - "object-assign": "~4.0.1", "rc-animate": "~2.0.2", "rc-calendar": "~5.4.0", "rc-cascader": "~0.9.0", @@ -115,6 +114,7 @@ "mark-twain": "^0.2.0-beta.4", "mkdirp": "~0.5.1", "nico-jsx": "~0.9.0", + "object-assign": "~4.0.1", "postcss-loader": "^0.8.0", "pre-commit": "1.x", "querystring": "^0.2.0",