@samitouri / QOS-React / commits / 1573baaee8

Use Object.assign directly and inject object-assign at compile

Paul O’Shannessy committed Mar 29, 2016 at 15:02 UTC 1573baaee8ba1c9cd84145b01effcb5eb80503fb
45 files changed +123 -150
.babelrc
+2 -1
@@ -20,6 +20,7 @@
20 "transform-es2015-block-scoping",
21 "transform-es2015-modules-commonjs",
22 "transform-es3-member-expression-literals",
23 - "transform-es3-property-literals"
23 + "transform-es3-property-literals",
24 + "./scripts/babel/transform-object-assign-require"
25 ]
26 }
gulpfile.js
+9 -1
@@ -30,7 +30,15 @@ var paths = {
30
31 var babelOpts = {
32 plugins: [
33 - [babelPluginModules, { map: require('fbjs/module-map') }],
33 + [babelPluginModules, {
34 + map: Object.assign(
35 + {},
36 + require('fbjs/module-map'),
37 + {
38 + 'object-assign': 'object-assign',
39 + }
40 + ),
41 + }],
42 ],
43 };
44
package.json
+1
@@ -49,6 +49,7 @@
49 "gzip-js": "~0.3.2",
50 "jest-cli": "^0.9.0",
51 "loose-envify": "^1.1.0",
52 + "object-assign": "^4.0.1",
53 "platform": "^1.1.0",
54 "run-sequence": "^1.1.4",
55 "through2": "^2.0.0",
packages/react/package.json
+2 -1
@@ -24,7 +24,8 @@
24 },
25 "dependencies": {
26 "fbjs": "^0.8.0-alpha.2",
27 - "loose-envify": "^1.1.0"
27 + "loose-envify": "^1.1.0",
28 + "object-assign": "^4.0.1"
29 },
30 "browserify": {
31 "transform": [
scripts/babel/transform-object-assign-require.js new
+40
@@ -0,0 +1,40 @@
1 +/**
2 + * Copyright 2013-present, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + */
9 +
10 +'use strict';
11 +
12 +module.exports = function autoImporter(babel) {
13 + const t = babel.types;
14 +
15 + return {
16 + pre: function() {
17 + // map from module to generated identifier
18 + this.id = null;
19 + },
20 +
21 + visitor: {
22 + CallExpression: function(path, file) {
23 + if (path.get('callee').matchesPattern('Object.assign')) {
24 + // generate identifier and require if it hasn't been already
25 + if (!this.id) {
26 + this.id = path.scope.generateUidIdentifier('assign');
27 + path.scope.getProgramParent().push({
28 + id: this.id,
29 + init: t.callExpression(
30 + t.identifier('require'),
31 + [t.stringLiteral('object-assign')]
32 + ),
33 + });
34 + }
35 + path.node.callee = this.id;
36 + }
37 + },
38 + },
39 + };
40 +};
scripts/jest/preprocessor.js
+9 -1
@@ -27,7 +27,15 @@ var pathToBabelrc = path.join(__dirname, '..', '..', '.babelrc');
27 // TODO: make sure this stays in sync with gulpfile
28 var babelOptions = {
29 plugins: [
30 - [babelPluginModules, { map: moduleMap }],
30 + [babelPluginModules, {
31 + map: Object.assign(
32 + {},
33 + moduleMap,
34 + {
35 + 'object-assign': 'object-assign',
36 + }
37 + ),
38 + }],
39 ],
40 retainLines: true,
41 };
src/addons/transitions/ReactCSSTransitionGroup.js
+1 -3
@@ -13,8 +13,6 @@
13
14 var React = require('React');
15
16 -var assign = require('Object.assign');
17 -
16 var ReactTransitionGroup = require('ReactTransitionGroup');
17 var ReactCSSTransitionGroupChild = require('ReactCSSTransitionGroupChild');
18
@@ -87,7 +85,7 @@ var ReactCSSTransitionGroup = React.createClass({
85 render: function() {
86 return React.createElement(
87 ReactTransitionGroup,
90 - assign({}, this.props, {childFactory: this._wrapChild})
88 + Object.assign({}, this.props, {childFactory: this._wrapChild})
89 );
90 },
91 });
src/addons/transitions/ReactTransitionGroup.js
+1 -2
@@ -14,7 +14,6 @@
14 var React = require('React');
15 var ReactTransitionChildMapping = require('ReactTransitionChildMapping');
16
17 -var assign = require('Object.assign');
17 var emptyFunction = require('emptyFunction');
18
19 var ReactTransitionGroup = React.createClass({
@@ -193,7 +192,7 @@ var ReactTransitionGroup = React.createClass({
192 this.performEnter(key);
193 } else {
194 this.setState(function(state) {
196 - var newChildren = assign({}, state.children);
195 + var newChildren = Object.assign({}, state.children);
196 delete newChildren[key];
197 return {children: newChildren};
198 });
src/addons/update.js
+2 -3
@@ -13,7 +13,6 @@
13
14 'use strict';
15
16 -var assign = require('Object.assign');
16 var keyOf = require('keyOf');
17 var invariant = require('invariant');
18 var hasOwnProperty = {}.hasOwnProperty;
@@ -22,7 +21,7 @@ function shallowCopy(x) {
21 if (Array.isArray(x)) {
22 return x.concat();
23 } else if (x && typeof x === 'object') {
25 - return assign(new x.constructor(), x);
24 + return Object.assign(new x.constructor(), x);
25 } else {
26 return x;
27 }
@@ -102,7 +101,7 @@ function update(value, spec) {
101 COMMAND_MERGE,
102 nextValue
103 );
105 - assign(nextValue, spec[COMMAND_MERGE]);
104 + Object.assign(nextValue, spec[COMMAND_MERGE]);
105 }
106
107 if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
src/isomorphic/React.js
+1 -2
@@ -20,7 +20,6 @@ var ReactElementValidator = require('ReactElementValidator');
20 var ReactPropTypes = require('ReactPropTypes');
21 var ReactVersion = require('ReactVersion');
22
23 -var assign = require('Object.assign');
23 var onlyChild = require('onlyChild');
24
25 var createElement = ReactElement.createElement;
@@ -68,7 +67,7 @@ var React = {
67 version: ReactVersion,
68
69 // Hook for JSX spread, don't use this for anything else.
71 - __spread: assign,
70 + __spread: Object.assign,
71 };
72
73 module.exports = React;
src/isomorphic/classic/class/ReactClass.js
+4 -5
@@ -17,7 +17,6 @@ var ReactPropTypeLocations = require('ReactPropTypeLocations');
17 var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
18 var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
19
20 -var assign = require('Object.assign');
20 var emptyObject = require('emptyObject');
21 var invariant = require('invariant');
22 var keyMirror = require('keyMirror');
@@ -331,7 +330,7 @@ var RESERVED_SPEC_KEYS = {
330 ReactPropTypeLocations.childContext
331 );
332 }
334 - Constructor.childContextTypes = assign(
333 + Constructor.childContextTypes = Object.assign(
334 {},
335 Constructor.childContextTypes,
336 childContextTypes
@@ -345,7 +344,7 @@ var RESERVED_SPEC_KEYS = {
344 ReactPropTypeLocations.context
345 );
346 }
348 - Constructor.contextTypes = assign(
347 + Constructor.contextTypes = Object.assign(
348 {},
349 Constructor.contextTypes,
350 contextTypes
@@ -373,7 +372,7 @@ var RESERVED_SPEC_KEYS = {
372 ReactPropTypeLocations.prop
373 );
374 }
376 - Constructor.propTypes = assign(
375 + Constructor.propTypes = Object.assign(
376 {},
377 Constructor.propTypes,
378 propTypes
@@ -726,7 +725,7 @@ var ReactClassMixin = {
725 };
726
727 var ReactClassComponent = function() {};
729 -assign(
728 +Object.assign(
729 ReactClassComponent.prototype,
730 ReactComponent.prototype,
731 ReactClassMixin
src/isomorphic/classic/element/ReactElement.js
+1 -2
@@ -13,7 +13,6 @@
13
14 var ReactCurrentOwner = require('ReactCurrentOwner');
15
16 -var assign = require('Object.assign');
16 var warning = require('warning');
17 var canDefineProperty = require('canDefineProperty');
18
@@ -253,7 +252,7 @@ ReactElement.cloneElement = function(element, config, children) {
252 var propName;
253
254 // Original props are copied
256 - var props = assign({}, element.props);
255 + var props = Object.assign({}, element.props);
256
257 // Reserved names are extracted
258 var key = element.key;
src/isomorphic/deprecated/OrderedMap.js
+1 -2
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14 var invariant = require('invariant');
15
16 var PREFIX = 'key:';
@@ -475,7 +474,7 @@ var OrderedMapMethods = {
474 },
475 };
476
478 -assign(OrderedMapImpl.prototype, OrderedMapMethods);
477 +Object.assign(OrderedMapImpl.prototype, OrderedMapMethods);
478
479 var OrderedMap = {
480 from: function(orderedMap) {
src/isomorphic/deprecated/ReactPropTransferer.js
+2 -3
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14 var emptyFunction = require('emptyFunction');
15 var joinClasses = require('joinClasses');
16
@@ -36,7 +35,7 @@ var transferStrategyMerge = createTransferStrategy(function(a, b) {
35 // `merge` overrides the first object's (`props[key]` above) keys using the
36 // second object's (`value`) keys. An object's style's existing `propA` would
37 // get overridden. Flip the order here.
39 - return assign({}, b, a);
38 + return Object.assign({}, b, a);
39 });
40
41 /**
@@ -100,7 +99,7 @@ var ReactPropTransferer = {
99 * @return {object} a new object containing both sets of props merged.
100 */
101 mergeProps: function(oldProps, newProps) {
103 - return transferInto(assign({}, oldProps), newProps);
102 + return transferInto(Object.assign({}, oldProps), newProps);
103 },
104
105 };
src/renderers/dom/client/ReactBrowserEventEmitter.js
+1 -2
@@ -16,7 +16,6 @@ var EventPluginRegistry = require('EventPluginRegistry');
16 var ReactEventEmitterMixin = require('ReactEventEmitterMixin');
17 var ViewportMetrics = require('ViewportMetrics');
18
19 -var assign = require('Object.assign');
19 var getVendorPrefixedEventName = require('getVendorPrefixedEventName');
20 var isEventSupported = require('isEventSupported');
21
@@ -175,7 +174,7 @@ function getListeningForDocument(mountAt) {
174 *
175 * @internal
176 */
178 -var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
177 +var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
178
179 /**
180 * Injectable event backend
src/renderers/dom/client/ReactEventListener.js
+1 -2
@@ -17,7 +17,6 @@ var PooledClass = require('PooledClass');
17 var ReactDOMComponentTree = require('ReactDOMComponentTree');
18 var ReactUpdates = require('ReactUpdates');
19
20 -var assign = require('Object.assign');
20 var getEventTarget = require('getEventTarget');
21 var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
22
@@ -44,7 +43,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
43 this.nativeEvent = nativeEvent;
44 this.ancestors = [];
45 }
47 -assign(TopLevelCallbackBookKeeping.prototype, {
46 +Object.assign(TopLevelCallbackBookKeeping.prototype, {
47 destructor: function() {
48 this.topLevelType = null;
49 this.nativeEvent = null;
src/renderers/dom/client/ReactReconcileTransaction.js
+1 -2
@@ -17,7 +17,6 @@ var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
17 var ReactInputSelection = require('ReactInputSelection');
18 var Transaction = require('Transaction');
19
20 -var assign = require('Object.assign');
20
21 /**
22 * Ensures that, when possible, the selection range (currently selected text
@@ -160,7 +159,7 @@ var Mixin = {
159 };
160
161
163 -assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
162 +Object.assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
163
164 PooledClass.addPoolingTo(ReactReconcileTransaction);
165
src/renderers/dom/client/eventPlugins/FallbackCompositionState.js
+1 -2
@@ -13,7 +13,6 @@
13
14 var PooledClass = require('PooledClass');
15
16 -var assign = require('Object.assign');
16 var getTextContentAccessor = require('getTextContentAccessor');
17
18 /**
@@ -33,7 +32,7 @@ function FallbackCompositionState(root) {
32 this._fallbackText = null;
33 }
34
36 -assign(FallbackCompositionState.prototype, {
35 +Object.assign(FallbackCompositionState.prototype, {
36 destructor: function() {
37 this._root = null;
38 this._startText = null;
src/renderers/dom/client/syntheticEvents/SyntheticEvent.js
+3 -4
@@ -13,7 +13,6 @@
13
14 var PooledClass = require('PooledClass');
15
16 -var assign = require('Object.assign');
16 var emptyFunction = require('emptyFunction');
17 var warning = require('warning');
18
@@ -111,7 +110,7 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
110 return this;
111 }
112
114 -assign(SyntheticEvent.prototype, {
113 +Object.assign(SyntheticEvent.prototype, {
114
115 preventDefault: function() {
116 this.defaultPrevented = true;
@@ -229,11 +228,11 @@ SyntheticEvent.augmentClass = function(Class, Interface) {
228 E.prototype = Super.prototype;
229 var prototype = new E();
230
232 - assign(prototype, Class.prototype);
231 + Object.assign(prototype, Class.prototype);
232 Class.prototype = prototype;
233 Class.prototype.constructor = Class;
234
236 - Class.Interface = assign({}, Super.Interface, Interface);
235 + Class.Interface = Object.assign({}, Super.Interface, Interface);
236 Class.augmentClass = Super.augmentClass;
237
238 PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
src/renderers/dom/client/validateDOMNesting.js
+1 -2
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14 var emptyFunction = require('emptyFunction');
15 var warning = require('warning');
16
@@ -76,7 +75,7 @@ if (__DEV__) {
75 };
76
77 var updatedAncestorInfo = function(oldInfo, tag, instance) {
79 - var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
78 + var ancestorInfo = Object.assign({}, oldInfo || emptyAncestorInfo);
79 var info = {tag: tag, instance: instance};
80
81 if (inScopeTags.indexOf(tag) !== -1) {
src/renderers/dom/client/wrappers/ReactDOMInput.js
+1 -2
@@ -16,7 +16,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
16 var ReactDOMComponentTree = require('ReactDOMComponentTree');
17 var ReactUpdates = require('ReactUpdates');
18
19 -var assign = require('Object.assign');
19 var invariant = require('invariant');
20 var warning = require('warning');
21
@@ -69,7 +68,7 @@ var ReactDOMInput = {
68 var value = LinkedValueUtils.getValue(props);
69 var checked = LinkedValueUtils.getChecked(props);
70
72 - var nativeProps = assign({
71 + var nativeProps = Object.assign({
72 // Make sure we set .type before any other properties (setting .value
73 // before .type means .value is lost in IE11 and below)
74 type: undefined,
src/renderers/dom/client/wrappers/ReactDOMOption.js
+1 -2
@@ -14,7 +14,6 @@
14 var ReactChildren = require('ReactChildren');
15 var ReactDOMSelect = require('ReactDOMSelect');
16
17 -var assign = require('Object.assign');
17 var warning = require('warning');
18
19 /**
@@ -59,7 +58,7 @@ var ReactDOMOption = {
58 },
59
60 getNativeProps: function(inst, props) {
62 - var nativeProps = assign({selected: undefined, children: undefined}, props);
61 + var nativeProps = Object.assign({selected: undefined, children: undefined}, props);
62
63 // Read state only from initial mount because <select> updates value
64 // manually; we need the initial state only for server rendering
src/renderers/dom/client/wrappers/ReactDOMSelect.js
+1 -2
@@ -15,7 +15,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
15 var ReactDOMComponentTree = require('ReactDOMComponentTree');
16 var ReactUpdates = require('ReactUpdates');
17
18 -var assign = require('Object.assign');
18 var warning = require('warning');
19
20 var didWarnValueLink = false;
@@ -159,7 +158,7 @@ function updateOptions(inst, multiple, propValue) {
158 */
159 var ReactDOMSelect = {
160 getNativeProps: function(inst, props) {
162 - return assign({}, props, {
161 + return Object.assign({}, props, {
162 onChange: inst._wrapperState.onChange,
163 value: undefined,
164 });
src/renderers/dom/client/wrappers/ReactDOMTextarea.js
+1 -2
@@ -16,7 +16,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
16 var ReactDOMComponentTree = require('ReactDOMComponentTree');
17 var ReactUpdates = require('ReactUpdates');
18
19 -var assign = require('Object.assign');
19 var invariant = require('invariant');
20 var warning = require('warning');
21
@@ -68,7 +67,7 @@ var ReactDOMTextarea = {
67
68 // Always set children to the same thing. In IE9, the selection range will
69 // get reset if `textContent` is mutated.
71 - var nativeProps = assign({}, props, {
70 + var nativeProps = Object.assign({}, props, {
71 defaultValue: undefined,
72 value: undefined,
73 children: inst._wrapperState.initialValue,
src/renderers/dom/server/ReactServerRenderingTransaction.js
+1 -2
@@ -14,7 +14,6 @@
14 var PooledClass = require('PooledClass');
15 var Transaction = require('Transaction');
16
17 -var assign = require('Object.assign');
17
18 /**
19 * Executed within the scope of the `Transaction` instance. Consider these as
@@ -64,7 +63,7 @@ var Mixin = {
63 };
64
65
67 -assign(
66 +Object.assign(
67 ReactServerRenderingTransaction.prototype,
68 Transaction.Mixin,
69 Mixin
src/renderers/dom/shared/ReactDOMComponent.js
+4 -5
@@ -35,7 +35,6 @@ var ReactDOMTextarea = require('ReactDOMTextarea');
35 var ReactMultiChild = require('ReactMultiChild');
36 var ReactPerf = require('ReactPerf');
37
38 -var assign = require('Object.assign');
38 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
39 var invariant = require('invariant');
40 var isEventSupported = require('isEventSupported');
@@ -381,7 +380,7 @@ var newlineEatingTags = {
380 // For HTML, certain tags cannot have children. This has the same purpose as
381 // `omittedCloseTags` except that `menuitem` should still have its closing tag.
382
384 -var voidElementTags = assign({
383 +var voidElementTags = Object.assign({
384 'menuitem': true,
385 }, omittedCloseTags);
386
@@ -641,7 +640,7 @@ ReactDOMComponent.Mixin = {
640 // See `_updateDOMProperties`. style block
641 this._previousStyle = propValue;
642 }
644 - propValue = this._previousStyleCopy = assign({}, props.style);
643 + propValue = this._previousStyleCopy = Object.assign({}, props.style);
644 }
645 propValue = CSSPropertyOperations.createMarkupForStyles(propValue, this);
646 }
@@ -887,7 +886,7 @@ ReactDOMComponent.Mixin = {
886 );
887 this._previousStyle = nextProp;
888 }
890 - nextProp = this._previousStyleCopy = assign({}, nextProp);
889 + nextProp = this._previousStyleCopy = Object.assign({}, nextProp);
890 } else {
891 this._previousStyleCopy = null;
892 }
@@ -1064,7 +1063,7 @@ ReactPerf.measureMethods(ReactDOMComponent.Mixin, 'ReactDOMComponent', {
1063 receiveComponent: 'receiveComponent',
1064 });
1065
1067 -assign(
1066 +Object.assign(
1067 ReactDOMComponent.prototype,
1068 ReactDOMComponent.Mixin,
1069 ReactMultiChild.Mixin
src/renderers/dom/shared/ReactDOMEmptyComponent.js
+1 -2
@@ -14,7 +14,6 @@
14 var DOMLazyTree = require('DOMLazyTree');
15 var ReactDOMComponentTree = require('ReactDOMComponentTree');
16
17 -var assign = require('Object.assign');
17
18 var ReactDOMEmptyComponent = function(instantiate) {
19 // ReactCompositeComponent uses this:
@@ -25,7 +24,7 @@ var ReactDOMEmptyComponent = function(instantiate) {
24 this._nativeContainerInfo = null;
25 this._domID = null;
26 };
28 -assign(ReactDOMEmptyComponent.prototype, {
27 +Object.assign(ReactDOMEmptyComponent.prototype, {
28 mountComponent: function(
29 transaction,
30 nativeParent,
src/renderers/dom/shared/ReactDOMTextComponent.js
+1 -2
@@ -16,7 +16,6 @@ var DOMLazyTree = require('DOMLazyTree');
16 var ReactDOMComponentTree = require('ReactDOMComponentTree');
17 var ReactPerf = require('ReactPerf');
18
19 -var assign = require('Object.assign');
19 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
20 var invariant = require('invariant');
21 var validateDOMNesting = require('validateDOMNesting');
@@ -51,7 +50,7 @@ var ReactDOMTextComponent = function(text) {
50 this._commentNodes = null;
51 };
52
54 -assign(ReactDOMTextComponent.prototype, {
53 +Object.assign(ReactDOMTextComponent.prototype, {
54
55 /**
56 * Creates the markup for this text node. This node is not intended to have
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+2 -3
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14
15 describe('ReactDOMComponent', function() {
16 var React;
@@ -623,7 +622,7 @@ describe('ReactDOMComponent', function() {
622 this._currentElement = {props: initialProps};
623 this._rootNodeID = 'test';
624 };
626 - assign(NodeStub.prototype, ReactDOMComponent.Mixin);
625 + Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
626
627 genMarkup = function(props) {
628 var transaction = new ReactReconcileTransaction();
@@ -672,7 +671,7 @@ describe('ReactDOMComponent', function() {
671 this._currentElement = {props: initialProps};
672 this._rootNodeID = 'test';
673 };
675 - assign(NodeStub.prototype, ReactDOMComponent.Mixin);
674 + Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
675
676 genMarkup = function(props) {
677 var transaction = new ReactReconcileTransaction();
src/renderers/shared/event/__tests__/EventPluginRegistry-test.js
+1 -2
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14
15 describe('EventPluginRegistry', function() {
16 var EventPluginRegistry;
@@ -22,7 +21,7 @@ describe('EventPluginRegistry', function() {
21 EventPluginRegistry._resetEventPlugins();
22
23 createPlugin = function(properties) {
25 - return assign({extractEvents: function() {}}, properties);
24 + return Object.assign({extractEvents: function() {}}, properties);
25 };
26 });
27
src/renderers/shared/reconciler/ReactCompositeComponent.js
+3 -4
@@ -24,7 +24,6 @@ var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
24 var ReactReconciler = require('ReactReconciler');
25 var ReactUpdateQueue = require('ReactUpdateQueue');
26
27 -var assign = require('Object.assign');
27 var emptyObject = require('emptyObject');
28 var invariant = require('invariant');
29 var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
@@ -526,7 +525,7 @@ var ReactCompositeComponentMixin = {
525 name
526 );
527 }
529 - return assign({}, currentContext, childContext);
528 + return Object.assign({}, currentContext, childContext);
529 }
530 return currentContext;
531 },
@@ -759,10 +758,10 @@ var ReactCompositeComponentMixin = {
758 return queue[0];
759 }
760
762 - var nextState = assign({}, replace ? queue[0] : inst.state);
761 + var nextState = Object.assign({}, replace ? queue[0] : inst.state);
762 for (var i = replace ? 1 : 0; i < queue.length; i++) {
763 var partial = queue[i];
765 - assign(
764 + Object.assign(
765 nextState,
766 typeof partial === 'function' ?
767 partial.call(inst, nextState, props, context) :
src/renderers/shared/reconciler/ReactDefaultBatchingStrategy.js
+1 -2
@@ -14,7 +14,6 @@
14 var ReactUpdates = require('ReactUpdates');
15 var Transaction = require('Transaction');
16
17 -var assign = require('Object.assign');
17 var emptyFunction = require('emptyFunction');
18
19 var RESET_BATCHED_UPDATES = {
@@ -35,7 +34,7 @@ function ReactDefaultBatchingStrategyTransaction() {
34 this.reinitializeTransaction();
35 }
36
38 -assign(
37 +Object.assign(
38 ReactDefaultBatchingStrategyTransaction.prototype,
39 Transaction.Mixin,
40 {
src/renderers/shared/reconciler/ReactNativeComponent.js
+1 -2
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14 var invariant = require('invariant');
15
16 var autoGenerateWrapperClass = null;
@@ -34,7 +33,7 @@ var ReactNativeComponentInjection = {
33 // This accepts a keyed object with classes as values. Each key represents a
34 // tag. That particular tag will use this class instead of the generic one.
35 injectComponentClasses: function(componentClasses) {
37 - assign(tagToComponentClass, componentClasses);
36 + Object.assign(tagToComponentClass, componentClasses);
37 },
38 };
39
src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js
+1 -2
@@ -13,13 +13,12 @@
13
14 var ReactReconciler = require('ReactReconciler');
15
16 -var assign = require('Object.assign');
16
17 var ReactSimpleEmptyComponent = function(placeholderElement, instantiate) {
18 this._currentElement = null;
19 this._renderedComponent = instantiate(placeholderElement);
20 };
22 -assign(ReactSimpleEmptyComponent.prototype, {
21 +Object.assign(ReactSimpleEmptyComponent.prototype, {
22 mountComponent: function(
23 transaction,
24 nativeParent,
src/renderers/shared/reconciler/ReactUpdates.js
+1 -2
@@ -18,7 +18,6 @@ var ReactPerf = require('ReactPerf');
18 var ReactReconciler = require('ReactReconciler');
19 var Transaction = require('Transaction');
20
21 -var assign = require('Object.assign');
21 var invariant = require('invariant');
22
23 var dirtyComponents = [];
@@ -74,7 +73,7 @@ function ReactUpdatesFlushTransaction() {
73 );
74 }
75
77 -assign(
76 +Object.assign(
77 ReactUpdatesFlushTransaction.prototype,
78 Transaction.Mixin,
79 {
src/renderers/shared/reconciler/instantiateReactComponent.js
+1 -2
@@ -15,7 +15,6 @@ var ReactCompositeComponent = require('ReactCompositeComponent');
15 var ReactEmptyComponent = require('ReactEmptyComponent');
16 var ReactNativeComponent = require('ReactNativeComponent');
17
18 -var assign = require('Object.assign');
18 var invariant = require('invariant');
19 var warning = require('warning');
20
@@ -23,7 +22,7 @@ var warning = require('warning');
22 var ReactCompositeComponentWrapper = function(element) {
23 this.construct(element);
24 };
26 -assign(
25 +Object.assign(
26 ReactCompositeComponentWrapper.prototype,
27 ReactCompositeComponent.Mixin,
28 {
src/shared/stubs/Object.assign.js deleted
-47
@@ -1,47 +0,0 @@
1 -/**
2 - * Copyright 2014-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule Object.assign
10 - */
11 -
12 -// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
13 -
14 -'use strict';
15 -
16 -function assign(target, sources) {
17 - if (target == null) {
18 - throw new TypeError('Object.assign target cannot be null or undefined');
19 - }
20 -
21 - var to = Object(target);
22 - var hasOwnProperty = Object.prototype.hasOwnProperty;
23 -
24 - for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
25 - var nextSource = arguments[nextIndex];
26 - if (nextSource == null) {
27 - continue;
28 - }
29 -
30 - var from = Object(nextSource);
31 -
32 - // We don't currently support accessors nor proxies. Therefore this
33 - // copy cannot throw. If we ever supported this then we must handle
34 - // exceptions and side-effects. We don't support symbols so they won't
35 - // be transferred.
36 -
37 - for (var key in from) {
38 - if (hasOwnProperty.call(from, key)) {
39 - to[key] = from[key];
40 - }
41 - }
42 - }
43 -
44 - return to;
45 -}
46 -
47 -module.exports = assign;
src/shared/utils/CallbackQueue.js
+1 -2
@@ -13,7 +13,6 @@
13
14 var PooledClass = require('PooledClass');
15
16 -var assign = require('Object.assign');
16 var invariant = require('invariant');
17
18 /**
@@ -32,7 +31,7 @@ function CallbackQueue() {
31 this._contexts = null;
32 }
33
35 -assign(CallbackQueue.prototype, {
34 +Object.assign(CallbackQueue.prototype, {
35
36 /**
37 * Enqueues a callback to be invoked when `notifyAll` is invoked.
src/shared/utils/__tests__/Transaction-test.js
+6 -7
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14
15 var Transaction;
16
@@ -46,7 +45,7 @@ describe('Transaction', function() {
45 this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
46 this.lastCloseParam = INIT_ERRORED; // WON'T be set to something else
47 };
49 - assign(TestTransaction.prototype, Transaction.Mixin);
48 + Object.assign(TestTransaction.prototype, Transaction.Mixin);
49 TestTransaction.prototype.getTransactionWrappers = function() {
50 return [
51 {
@@ -97,7 +96,7 @@ describe('Transaction', function() {
96 this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
97 this.lastCloseParam = INIT_ERRORED; // WILL be set to something else
98 };
100 - assign(TestTransaction.prototype, Transaction.Mixin);
99 + Object.assign(TestTransaction.prototype, Transaction.Mixin);
100 TestTransaction.prototype.getTransactionWrappers = function() {
101 return [
102 {
@@ -158,7 +157,7 @@ describe('Transaction', function() {
157 this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
158 this.lastCloseParam = INIT_ERRORED; // WILL be set to something else
159 };
161 - assign(TestTransaction.prototype, Transaction.Mixin);
160 + Object.assign(TestTransaction.prototype, Transaction.Mixin);
161 // Now, none of the close/inits throw, but the operation we wrap will throw.
162 TestTransaction.prototype.getTransactionWrappers = function() {
163 return [
@@ -222,7 +221,7 @@ describe('Transaction', function() {
221 var TestTransaction = function() {
222 this.reinitializeTransaction();
223 };
225 - assign(TestTransaction.prototype, Transaction.Mixin);
224 + Object.assign(TestTransaction.prototype, Transaction.Mixin);
225 var exceptionMsg = 'This exception should throw.';
226 TestTransaction.prototype.getTransactionWrappers = function() {
227 return [
@@ -251,7 +250,7 @@ describe('Transaction', function() {
250 this.reinitializeTransaction();
251 this.firstCloseParam = INIT_ERRORED; // WILL be set to something else
252 };
254 - assign(TestTransaction.prototype, Transaction.Mixin);
253 + Object.assign(TestTransaction.prototype, Transaction.Mixin);
254 TestTransaction.prototype.getTransactionWrappers = function() {
255 return [
256 {
@@ -279,7 +278,7 @@ describe('Transaction', function() {
278 var NestedTransaction = function() {
279 this.reinitializeTransaction();
280 };
282 - assign(NestedTransaction.prototype, Transaction.Mixin);
281 + Object.assign(NestedTransaction.prototype, Transaction.Mixin);
282 NestedTransaction.prototype.getTransactionWrappers = function() {
283 return [
284 {
src/shared/utils/deprecated.js
+1 -2
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14 var warning = require('warning');
15
16 /**
@@ -48,7 +47,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
47 };
48 // We need to make sure all properties of the original fn are copied over.
49 // In particular, this is needed to support PropTypes
51 - return assign(newFn, fn);
50 + return Object.assign(newFn, fn);
51 }
52
53 return fn;
src/test/ReactDefaultPerfAnalysis.js
+3 -4
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var assign = require('Object.assign');
14
15 // Don't try to save users less than 1.2ms (a number I made up)
16 var DONT_CARE_THRESHOLD = 1.2;
@@ -65,7 +64,7 @@ function getExclusiveSummary(measurements) {
64
65 for (var i = 0; i < measurements.length; i++) {
66 var measurement = measurements[i];
68 - var allIDs = assign(
67 + var allIDs = Object.assign(
68 {},
69 measurement.exclusive,
70 measurement.inclusive
@@ -117,7 +116,7 @@ function getInclusiveSummary(measurements, onlyClean) {
116
117 for (var i = 0; i < measurements.length; i++) {
118 var measurement = measurements[i];
120 - var allIDs = assign(
119 + var allIDs = Object.assign(
120 {},
121 measurement.exclusive,
122 measurement.inclusive
@@ -185,7 +184,7 @@ function getUnchangedComponents(measurement) {
184 }
185 });
186 });
188 - var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
187 + var allIDs = Object.assign({}, measurement.exclusive, measurement.inclusive);
188
189 for (var id in allIDs) {
190 var isDirty = false;
src/test/ReactTestUtils.js
+3 -4
@@ -25,7 +25,6 @@ var ReactInstanceMap = require('ReactInstanceMap');
25 var ReactUpdates = require('ReactUpdates');
26 var SyntheticEvent = require('SyntheticEvent');
27
28 -var assign = require('Object.assign');
28 var emptyObject = require('emptyObject');
29 var findDOMNode = require('findDOMNode');
30 var invariant = require('invariant');
@@ -396,7 +395,7 @@ NoopInternalComponent.prototype = {
395 var ShallowComponentWrapper = function(element) {
396 this.construct(element);
397 };
399 -assign(
398 +Object.assign(
399 ShallowComponentWrapper.prototype,
400 ReactCompositeComponent.Mixin, {
401 _instantiateReactComponent: function(element) {
@@ -499,7 +498,7 @@ function makeSimulator(eventType) {
498 fakeNativeEvent,
499 node
500 );
502 - assign(event, eventData);
501 + Object.assign(event, eventData);
502
503 if (dispatchConfig.phasedRegistrationNames) {
504 EventPropagators.accumulateTwoPhaseDispatches(event);
@@ -560,7 +559,7 @@ buildSimulators();
559 function makeNativeSimulator(eventType) {
560 return function(domComponentOrNode, nativeEventData) {
561 var fakeNativeEvent = new Event(eventType);
563 - assign(fakeNativeEvent, nativeEventData);
562 + Object.assign(fakeNativeEvent, nativeEventData);
563 if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
564 ReactTestUtils.simulateNativeEventOnDOMComponent(
565 eventType,
src/test/reactComponentExpect.js
+1 -2
@@ -15,7 +15,6 @@
15 var ReactInstanceMap = require('ReactInstanceMap');
16 var ReactTestUtils = require('ReactTestUtils');
17
18 -var assign = require('Object.assign');
18 var invariant = require('invariant');
19
20 function reactComponentExpect(instance) {
@@ -47,7 +46,7 @@ function reactComponentExpectInternal(internalInstance) {
46 this._instance = internalInstance;
47 }
48
50 -assign(reactComponentExpectInternal.prototype, {
49 +Object.assign(reactComponentExpectInternal.prototype, {
50 // Getters -------------------------------------------------------------------
51
52 /**
src/umd/ReactUMDEntry.js
+1 -2
@@ -15,10 +15,9 @@ var ReactDOM = require('ReactDOM');
15 var ReactDOMServer = require('ReactDOMServer');
16 var React = require('React');
17
18 -var assign = require('Object.assign');
18
19 // `version` will be added here by ReactIsomorphic.
21 -var ReactUMDEntry = assign({
20 +var ReactUMDEntry = Object.assign({
21 __SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM,
22 __SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer,
23 }, React);
src/umd/ReactWithAddonsUMDEntry.js
+1 -2
@@ -15,10 +15,9 @@ var ReactDOM = require('ReactDOM');
15 var ReactDOMServer = require('ReactDOMServer');
16 var ReactWithAddons = require('ReactWithAddons');
17
18 -var assign = require('Object.assign');
18
19 // `version` will be added here by ReactIsomorphic.
21 -var ReactWithAddonsUMDEntry = assign({
20 +var ReactWithAddonsUMDEntry = Object.assign({
21 __SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM,
22 __SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer,
23 }, ReactWithAddons);