mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Use Object.assign directly and inject object-assign at compile
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"transform-es2015-block-scoping",
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es3-member-expression-literals",
|
||||
"transform-es3-property-literals"
|
||||
"transform-es3-property-literals",
|
||||
"./scripts/babel/transform-object-assign-require"
|
||||
]
|
||||
}
|
||||
|
||||
+9
-1
@@ -30,7 +30,15 @@ var paths = {
|
||||
|
||||
var babelOpts = {
|
||||
plugins: [
|
||||
[babelPluginModules, { map: require('fbjs/module-map') }],
|
||||
[babelPluginModules, {
|
||||
map: Object.assign(
|
||||
{},
|
||||
require('fbjs/module-map'),
|
||||
{
|
||||
'object-assign': 'object-assign',
|
||||
}
|
||||
),
|
||||
}],
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"gzip-js": "~0.3.2",
|
||||
"jest-cli": "^0.9.0",
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.0.1",
|
||||
"platform": "^1.1.0",
|
||||
"run-sequence": "^1.1.4",
|
||||
"through2": "^2.0.0",
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"fbjs": "^0.8.0-alpha.2",
|
||||
"loose-envify": "^1.1.0"
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.0.1"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function autoImporter(babel) {
|
||||
const t = babel.types;
|
||||
|
||||
return {
|
||||
pre: function() {
|
||||
// map from module to generated identifier
|
||||
this.id = null;
|
||||
},
|
||||
|
||||
visitor: {
|
||||
CallExpression: function(path, file) {
|
||||
if (path.get('callee').matchesPattern('Object.assign')) {
|
||||
// generate identifier and require if it hasn't been already
|
||||
if (!this.id) {
|
||||
this.id = path.scope.generateUidIdentifier('assign');
|
||||
path.scope.getProgramParent().push({
|
||||
id: this.id,
|
||||
init: t.callExpression(
|
||||
t.identifier('require'),
|
||||
[t.stringLiteral('object-assign')]
|
||||
),
|
||||
});
|
||||
}
|
||||
path.node.callee = this.id;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -27,7 +27,15 @@ var pathToBabelrc = path.join(__dirname, '..', '..', '.babelrc');
|
||||
// TODO: make sure this stays in sync with gulpfile
|
||||
var babelOptions = {
|
||||
plugins: [
|
||||
[babelPluginModules, { map: moduleMap }],
|
||||
[babelPluginModules, {
|
||||
map: Object.assign(
|
||||
{},
|
||||
moduleMap,
|
||||
{
|
||||
'object-assign': 'object-assign',
|
||||
}
|
||||
),
|
||||
}],
|
||||
],
|
||||
retainLines: true,
|
||||
};
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
var React = require('React');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
var ReactTransitionGroup = require('ReactTransitionGroup');
|
||||
var ReactCSSTransitionGroupChild = require('ReactCSSTransitionGroupChild');
|
||||
|
||||
@@ -87,7 +85,7 @@ var ReactCSSTransitionGroup = React.createClass({
|
||||
render: function() {
|
||||
return React.createElement(
|
||||
ReactTransitionGroup,
|
||||
assign({}, this.props, {childFactory: this._wrapChild})
|
||||
Object.assign({}, this.props, {childFactory: this._wrapChild})
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var React = require('React');
|
||||
var ReactTransitionChildMapping = require('ReactTransitionChildMapping');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyFunction = require('emptyFunction');
|
||||
|
||||
var ReactTransitionGroup = React.createClass({
|
||||
@@ -193,7 +192,7 @@ var ReactTransitionGroup = React.createClass({
|
||||
this.performEnter(key);
|
||||
} else {
|
||||
this.setState(function(state) {
|
||||
var newChildren = assign({}, state.children);
|
||||
var newChildren = Object.assign({}, state.children);
|
||||
delete newChildren[key];
|
||||
return {children: newChildren};
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var keyOf = require('keyOf');
|
||||
var invariant = require('invariant');
|
||||
var hasOwnProperty = {}.hasOwnProperty;
|
||||
@@ -22,7 +21,7 @@ function shallowCopy(x) {
|
||||
if (Array.isArray(x)) {
|
||||
return x.concat();
|
||||
} else if (x && typeof x === 'object') {
|
||||
return assign(new x.constructor(), x);
|
||||
return Object.assign(new x.constructor(), x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
@@ -102,7 +101,7 @@ function update(value, spec) {
|
||||
COMMAND_MERGE,
|
||||
nextValue
|
||||
);
|
||||
assign(nextValue, spec[COMMAND_MERGE]);
|
||||
Object.assign(nextValue, spec[COMMAND_MERGE]);
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
|
||||
|
||||
@@ -20,7 +20,6 @@ var ReactElementValidator = require('ReactElementValidator');
|
||||
var ReactPropTypes = require('ReactPropTypes');
|
||||
var ReactVersion = require('ReactVersion');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var onlyChild = require('onlyChild');
|
||||
|
||||
var createElement = ReactElement.createElement;
|
||||
@@ -68,7 +67,7 @@ var React = {
|
||||
version: ReactVersion,
|
||||
|
||||
// Hook for JSX spread, don't use this for anything else.
|
||||
__spread: assign,
|
||||
__spread: Object.assign,
|
||||
};
|
||||
|
||||
module.exports = React;
|
||||
|
||||
@@ -17,7 +17,6 @@ var ReactPropTypeLocations = require('ReactPropTypeLocations');
|
||||
var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
|
||||
var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyObject = require('emptyObject');
|
||||
var invariant = require('invariant');
|
||||
var keyMirror = require('keyMirror');
|
||||
@@ -331,7 +330,7 @@ var RESERVED_SPEC_KEYS = {
|
||||
ReactPropTypeLocations.childContext
|
||||
);
|
||||
}
|
||||
Constructor.childContextTypes = assign(
|
||||
Constructor.childContextTypes = Object.assign(
|
||||
{},
|
||||
Constructor.childContextTypes,
|
||||
childContextTypes
|
||||
@@ -345,7 +344,7 @@ var RESERVED_SPEC_KEYS = {
|
||||
ReactPropTypeLocations.context
|
||||
);
|
||||
}
|
||||
Constructor.contextTypes = assign(
|
||||
Constructor.contextTypes = Object.assign(
|
||||
{},
|
||||
Constructor.contextTypes,
|
||||
contextTypes
|
||||
@@ -373,7 +372,7 @@ var RESERVED_SPEC_KEYS = {
|
||||
ReactPropTypeLocations.prop
|
||||
);
|
||||
}
|
||||
Constructor.propTypes = assign(
|
||||
Constructor.propTypes = Object.assign(
|
||||
{},
|
||||
Constructor.propTypes,
|
||||
propTypes
|
||||
@@ -726,7 +725,7 @@ var ReactClassMixin = {
|
||||
};
|
||||
|
||||
var ReactClassComponent = function() {};
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactClassComponent.prototype,
|
||||
ReactComponent.prototype,
|
||||
ReactClassMixin
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var warning = require('warning');
|
||||
var canDefineProperty = require('canDefineProperty');
|
||||
|
||||
@@ -253,7 +252,7 @@ ReactElement.cloneElement = function(element, config, children) {
|
||||
var propName;
|
||||
|
||||
// Original props are copied
|
||||
var props = assign({}, element.props);
|
||||
var props = Object.assign({}, element.props);
|
||||
|
||||
// Reserved names are extracted
|
||||
var key = element.key;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
|
||||
var PREFIX = 'key:';
|
||||
@@ -475,7 +474,7 @@ var OrderedMapMethods = {
|
||||
},
|
||||
};
|
||||
|
||||
assign(OrderedMapImpl.prototype, OrderedMapMethods);
|
||||
Object.assign(OrderedMapImpl.prototype, OrderedMapMethods);
|
||||
|
||||
var OrderedMap = {
|
||||
from: function(orderedMap) {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyFunction = require('emptyFunction');
|
||||
var joinClasses = require('joinClasses');
|
||||
|
||||
@@ -36,7 +35,7 @@ var transferStrategyMerge = createTransferStrategy(function(a, b) {
|
||||
// `merge` overrides the first object's (`props[key]` above) keys using the
|
||||
// second object's (`value`) keys. An object's style's existing `propA` would
|
||||
// get overridden. Flip the order here.
|
||||
return assign({}, b, a);
|
||||
return Object.assign({}, b, a);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -100,7 +99,7 @@ var ReactPropTransferer = {
|
||||
* @return {object} a new object containing both sets of props merged.
|
||||
*/
|
||||
mergeProps: function(oldProps, newProps) {
|
||||
return transferInto(assign({}, oldProps), newProps);
|
||||
return transferInto(Object.assign({}, oldProps), newProps);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ var EventPluginRegistry = require('EventPluginRegistry');
|
||||
var ReactEventEmitterMixin = require('ReactEventEmitterMixin');
|
||||
var ViewportMetrics = require('ViewportMetrics');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var getVendorPrefixedEventName = require('getVendorPrefixedEventName');
|
||||
var isEventSupported = require('isEventSupported');
|
||||
|
||||
@@ -175,7 +174,7 @@ function getListeningForDocument(mountAt) {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
||||
var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
|
||||
|
||||
/**
|
||||
* Injectable event backend
|
||||
|
||||
@@ -17,7 +17,6 @@ var PooledClass = require('PooledClass');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var getEventTarget = require('getEventTarget');
|
||||
var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
|
||||
|
||||
@@ -44,7 +43,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
|
||||
this.nativeEvent = nativeEvent;
|
||||
this.ancestors = [];
|
||||
}
|
||||
assign(TopLevelCallbackBookKeeping.prototype, {
|
||||
Object.assign(TopLevelCallbackBookKeeping.prototype, {
|
||||
destructor: function() {
|
||||
this.topLevelType = null;
|
||||
this.nativeEvent = null;
|
||||
|
||||
@@ -17,7 +17,6 @@ var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
|
||||
var ReactInputSelection = require('ReactInputSelection');
|
||||
var Transaction = require('Transaction');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
/**
|
||||
* Ensures that, when possible, the selection range (currently selected text
|
||||
@@ -160,7 +159,7 @@ var Mixin = {
|
||||
};
|
||||
|
||||
|
||||
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
||||
Object.assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
||||
|
||||
PooledClass.addPoolingTo(ReactReconcileTransaction);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var getTextContentAccessor = require('getTextContentAccessor');
|
||||
|
||||
/**
|
||||
@@ -33,7 +32,7 @@ function FallbackCompositionState(root) {
|
||||
this._fallbackText = null;
|
||||
}
|
||||
|
||||
assign(FallbackCompositionState.prototype, {
|
||||
Object.assign(FallbackCompositionState.prototype, {
|
||||
destructor: function() {
|
||||
this._root = null;
|
||||
this._startText = null;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyFunction = require('emptyFunction');
|
||||
var warning = require('warning');
|
||||
|
||||
@@ -111,7 +110,7 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
|
||||
return this;
|
||||
}
|
||||
|
||||
assign(SyntheticEvent.prototype, {
|
||||
Object.assign(SyntheticEvent.prototype, {
|
||||
|
||||
preventDefault: function() {
|
||||
this.defaultPrevented = true;
|
||||
@@ -229,11 +228,11 @@ SyntheticEvent.augmentClass = function(Class, Interface) {
|
||||
E.prototype = Super.prototype;
|
||||
var prototype = new E();
|
||||
|
||||
assign(prototype, Class.prototype);
|
||||
Object.assign(prototype, Class.prototype);
|
||||
Class.prototype = prototype;
|
||||
Class.prototype.constructor = Class;
|
||||
|
||||
Class.Interface = assign({}, Super.Interface, Interface);
|
||||
Class.Interface = Object.assign({}, Super.Interface, Interface);
|
||||
Class.augmentClass = Super.augmentClass;
|
||||
|
||||
PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyFunction = require('emptyFunction');
|
||||
var warning = require('warning');
|
||||
|
||||
@@ -76,7 +75,7 @@ if (__DEV__) {
|
||||
};
|
||||
|
||||
var updatedAncestorInfo = function(oldInfo, tag, instance) {
|
||||
var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
|
||||
var ancestorInfo = Object.assign({}, oldInfo || emptyAncestorInfo);
|
||||
var info = {tag: tag, instance: instance};
|
||||
|
||||
if (inScopeTags.indexOf(tag) !== -1) {
|
||||
|
||||
@@ -16,7 +16,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
var warning = require('warning');
|
||||
|
||||
@@ -69,7 +68,7 @@ var ReactDOMInput = {
|
||||
var value = LinkedValueUtils.getValue(props);
|
||||
var checked = LinkedValueUtils.getChecked(props);
|
||||
|
||||
var nativeProps = assign({
|
||||
var nativeProps = Object.assign({
|
||||
// Make sure we set .type before any other properties (setting .value
|
||||
// before .type means .value is lost in IE11 and below)
|
||||
type: undefined,
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var ReactChildren = require('ReactChildren');
|
||||
var ReactDOMSelect = require('ReactDOMSelect');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var warning = require('warning');
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ var ReactDOMOption = {
|
||||
},
|
||||
|
||||
getNativeProps: function(inst, props) {
|
||||
var nativeProps = assign({selected: undefined, children: undefined}, props);
|
||||
var nativeProps = Object.assign({selected: undefined, children: undefined}, props);
|
||||
|
||||
// Read state only from initial mount because <select> updates value
|
||||
// manually; we need the initial state only for server rendering
|
||||
|
||||
@@ -15,7 +15,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var warning = require('warning');
|
||||
|
||||
var didWarnValueLink = false;
|
||||
@@ -159,7 +158,7 @@ function updateOptions(inst, multiple, propValue) {
|
||||
*/
|
||||
var ReactDOMSelect = {
|
||||
getNativeProps: function(inst, props) {
|
||||
return assign({}, props, {
|
||||
return Object.assign({}, props, {
|
||||
onChange: inst._wrapperState.onChange,
|
||||
value: undefined,
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@ var LinkedValueUtils = require('LinkedValueUtils');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
var warning = require('warning');
|
||||
|
||||
@@ -68,7 +67,7 @@ var ReactDOMTextarea = {
|
||||
|
||||
// Always set children to the same thing. In IE9, the selection range will
|
||||
// get reset if `textContent` is mutated.
|
||||
var nativeProps = assign({}, props, {
|
||||
var nativeProps = Object.assign({}, props, {
|
||||
defaultValue: undefined,
|
||||
value: undefined,
|
||||
children: inst._wrapperState.initialValue,
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var PooledClass = require('PooledClass');
|
||||
var Transaction = require('Transaction');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
/**
|
||||
* Executed within the scope of the `Transaction` instance. Consider these as
|
||||
@@ -64,7 +63,7 @@ var Mixin = {
|
||||
};
|
||||
|
||||
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactServerRenderingTransaction.prototype,
|
||||
Transaction.Mixin,
|
||||
Mixin
|
||||
|
||||
@@ -35,7 +35,6 @@ var ReactDOMTextarea = require('ReactDOMTextarea');
|
||||
var ReactMultiChild = require('ReactMultiChild');
|
||||
var ReactPerf = require('ReactPerf');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
|
||||
var invariant = require('invariant');
|
||||
var isEventSupported = require('isEventSupported');
|
||||
@@ -381,7 +380,7 @@ var newlineEatingTags = {
|
||||
// For HTML, certain tags cannot have children. This has the same purpose as
|
||||
// `omittedCloseTags` except that `menuitem` should still have its closing tag.
|
||||
|
||||
var voidElementTags = assign({
|
||||
var voidElementTags = Object.assign({
|
||||
'menuitem': true,
|
||||
}, omittedCloseTags);
|
||||
|
||||
@@ -641,7 +640,7 @@ ReactDOMComponent.Mixin = {
|
||||
// See `_updateDOMProperties`. style block
|
||||
this._previousStyle = propValue;
|
||||
}
|
||||
propValue = this._previousStyleCopy = assign({}, props.style);
|
||||
propValue = this._previousStyleCopy = Object.assign({}, props.style);
|
||||
}
|
||||
propValue = CSSPropertyOperations.createMarkupForStyles(propValue, this);
|
||||
}
|
||||
@@ -887,7 +886,7 @@ ReactDOMComponent.Mixin = {
|
||||
);
|
||||
this._previousStyle = nextProp;
|
||||
}
|
||||
nextProp = this._previousStyleCopy = assign({}, nextProp);
|
||||
nextProp = this._previousStyleCopy = Object.assign({}, nextProp);
|
||||
} else {
|
||||
this._previousStyleCopy = null;
|
||||
}
|
||||
@@ -1064,7 +1063,7 @@ ReactPerf.measureMethods(ReactDOMComponent.Mixin, 'ReactDOMComponent', {
|
||||
receiveComponent: 'receiveComponent',
|
||||
});
|
||||
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactDOMComponent.prototype,
|
||||
ReactDOMComponent.Mixin,
|
||||
ReactMultiChild.Mixin
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var DOMLazyTree = require('DOMLazyTree');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
var ReactDOMEmptyComponent = function(instantiate) {
|
||||
// ReactCompositeComponent uses this:
|
||||
@@ -25,7 +24,7 @@ var ReactDOMEmptyComponent = function(instantiate) {
|
||||
this._nativeContainerInfo = null;
|
||||
this._domID = null;
|
||||
};
|
||||
assign(ReactDOMEmptyComponent.prototype, {
|
||||
Object.assign(ReactDOMEmptyComponent.prototype, {
|
||||
mountComponent: function(
|
||||
transaction,
|
||||
nativeParent,
|
||||
|
||||
@@ -16,7 +16,6 @@ var DOMLazyTree = require('DOMLazyTree');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactPerf = require('ReactPerf');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
|
||||
var invariant = require('invariant');
|
||||
var validateDOMNesting = require('validateDOMNesting');
|
||||
@@ -51,7 +50,7 @@ var ReactDOMTextComponent = function(text) {
|
||||
this._commentNodes = null;
|
||||
};
|
||||
|
||||
assign(ReactDOMTextComponent.prototype, {
|
||||
Object.assign(ReactDOMTextComponent.prototype, {
|
||||
|
||||
/**
|
||||
* Creates the markup for this text node. This node is not intended to have
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
describe('ReactDOMComponent', function() {
|
||||
var React;
|
||||
@@ -623,7 +622,7 @@ describe('ReactDOMComponent', function() {
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
|
||||
genMarkup = function(props) {
|
||||
var transaction = new ReactReconcileTransaction();
|
||||
@@ -672,7 +671,7 @@ describe('ReactDOMComponent', function() {
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
|
||||
genMarkup = function(props) {
|
||||
var transaction = new ReactReconcileTransaction();
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
describe('EventPluginRegistry', function() {
|
||||
var EventPluginRegistry;
|
||||
@@ -22,7 +21,7 @@ describe('EventPluginRegistry', function() {
|
||||
EventPluginRegistry._resetEventPlugins();
|
||||
|
||||
createPlugin = function(properties) {
|
||||
return assign({extractEvents: function() {}}, properties);
|
||||
return Object.assign({extractEvents: function() {}}, properties);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
|
||||
var ReactReconciler = require('ReactReconciler');
|
||||
var ReactUpdateQueue = require('ReactUpdateQueue');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyObject = require('emptyObject');
|
||||
var invariant = require('invariant');
|
||||
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
|
||||
@@ -526,7 +525,7 @@ var ReactCompositeComponentMixin = {
|
||||
name
|
||||
);
|
||||
}
|
||||
return assign({}, currentContext, childContext);
|
||||
return Object.assign({}, currentContext, childContext);
|
||||
}
|
||||
return currentContext;
|
||||
},
|
||||
@@ -759,10 +758,10 @@ var ReactCompositeComponentMixin = {
|
||||
return queue[0];
|
||||
}
|
||||
|
||||
var nextState = assign({}, replace ? queue[0] : inst.state);
|
||||
var nextState = Object.assign({}, replace ? queue[0] : inst.state);
|
||||
for (var i = replace ? 1 : 0; i < queue.length; i++) {
|
||||
var partial = queue[i];
|
||||
assign(
|
||||
Object.assign(
|
||||
nextState,
|
||||
typeof partial === 'function' ?
|
||||
partial.call(inst, nextState, props, context) :
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
var Transaction = require('Transaction');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyFunction = require('emptyFunction');
|
||||
|
||||
var RESET_BATCHED_UPDATES = {
|
||||
@@ -35,7 +34,7 @@ function ReactDefaultBatchingStrategyTransaction() {
|
||||
this.reinitializeTransaction();
|
||||
}
|
||||
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactDefaultBatchingStrategyTransaction.prototype,
|
||||
Transaction.Mixin,
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
|
||||
var autoGenerateWrapperClass = null;
|
||||
@@ -34,7 +33,7 @@ var ReactNativeComponentInjection = {
|
||||
// This accepts a keyed object with classes as values. Each key represents a
|
||||
// tag. That particular tag will use this class instead of the generic one.
|
||||
injectComponentClasses: function(componentClasses) {
|
||||
assign(tagToComponentClass, componentClasses);
|
||||
Object.assign(tagToComponentClass, componentClasses);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -13,13 +13,12 @@
|
||||
|
||||
var ReactReconciler = require('ReactReconciler');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
var ReactSimpleEmptyComponent = function(placeholderElement, instantiate) {
|
||||
this._currentElement = null;
|
||||
this._renderedComponent = instantiate(placeholderElement);
|
||||
};
|
||||
assign(ReactSimpleEmptyComponent.prototype, {
|
||||
Object.assign(ReactSimpleEmptyComponent.prototype, {
|
||||
mountComponent: function(
|
||||
transaction,
|
||||
nativeParent,
|
||||
|
||||
@@ -18,7 +18,6 @@ var ReactPerf = require('ReactPerf');
|
||||
var ReactReconciler = require('ReactReconciler');
|
||||
var Transaction = require('Transaction');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
|
||||
var dirtyComponents = [];
|
||||
@@ -74,7 +73,7 @@ function ReactUpdatesFlushTransaction() {
|
||||
);
|
||||
}
|
||||
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactUpdatesFlushTransaction.prototype,
|
||||
Transaction.Mixin,
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ var ReactCompositeComponent = require('ReactCompositeComponent');
|
||||
var ReactEmptyComponent = require('ReactEmptyComponent');
|
||||
var ReactNativeComponent = require('ReactNativeComponent');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
var warning = require('warning');
|
||||
|
||||
@@ -23,7 +22,7 @@ var warning = require('warning');
|
||||
var ReactCompositeComponentWrapper = function(element) {
|
||||
this.construct(element);
|
||||
};
|
||||
assign(
|
||||
Object.assign(
|
||||
ReactCompositeComponentWrapper.prototype,
|
||||
ReactCompositeComponent.Mixin,
|
||||
{
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule Object.assign
|
||||
*/
|
||||
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
||||
|
||||
'use strict';
|
||||
|
||||
function assign(target, sources) {
|
||||
if (target == null) {
|
||||
throw new TypeError('Object.assign target cannot be null or undefined');
|
||||
}
|
||||
|
||||
var to = Object(target);
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
||||
var nextSource = arguments[nextIndex];
|
||||
if (nextSource == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var from = Object(nextSource);
|
||||
|
||||
// We don't currently support accessors nor proxies. Therefore this
|
||||
// copy cannot throw. If we ever supported this then we must handle
|
||||
// exceptions and side-effects. We don't support symbols so they won't
|
||||
// be transferred.
|
||||
|
||||
for (var key in from) {
|
||||
if (hasOwnProperty.call(from, key)) {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
module.exports = assign;
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
|
||||
/**
|
||||
@@ -32,7 +31,7 @@ function CallbackQueue() {
|
||||
this._contexts = null;
|
||||
}
|
||||
|
||||
assign(CallbackQueue.prototype, {
|
||||
Object.assign(CallbackQueue.prototype, {
|
||||
|
||||
/**
|
||||
* Enqueues a callback to be invoked when `notifyAll` is invoked.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
var Transaction;
|
||||
|
||||
@@ -46,7 +45,7 @@ describe('Transaction', function() {
|
||||
this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
this.lastCloseParam = INIT_ERRORED; // WON'T be set to something else
|
||||
};
|
||||
assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
TestTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
{
|
||||
@@ -97,7 +96,7 @@ describe('Transaction', function() {
|
||||
this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
this.lastCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
};
|
||||
assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
TestTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
{
|
||||
@@ -158,7 +157,7 @@ describe('Transaction', function() {
|
||||
this.secondCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
this.lastCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
};
|
||||
assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
// Now, none of the close/inits throw, but the operation we wrap will throw.
|
||||
TestTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
@@ -222,7 +221,7 @@ describe('Transaction', function() {
|
||||
var TestTransaction = function() {
|
||||
this.reinitializeTransaction();
|
||||
};
|
||||
assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
var exceptionMsg = 'This exception should throw.';
|
||||
TestTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
@@ -251,7 +250,7 @@ describe('Transaction', function() {
|
||||
this.reinitializeTransaction();
|
||||
this.firstCloseParam = INIT_ERRORED; // WILL be set to something else
|
||||
};
|
||||
assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(TestTransaction.prototype, Transaction.Mixin);
|
||||
TestTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
{
|
||||
@@ -279,7 +278,7 @@ describe('Transaction', function() {
|
||||
var NestedTransaction = function() {
|
||||
this.reinitializeTransaction();
|
||||
};
|
||||
assign(NestedTransaction.prototype, Transaction.Mixin);
|
||||
Object.assign(NestedTransaction.prototype, Transaction.Mixin);
|
||||
NestedTransaction.prototype.getTransactionWrappers = function() {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var warning = require('warning');
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
|
||||
};
|
||||
// We need to make sure all properties of the original fn are copied over.
|
||||
// In particular, this is needed to support PropTypes
|
||||
return assign(newFn, fn);
|
||||
return Object.assign(newFn, fn);
|
||||
}
|
||||
|
||||
return fn;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
// Don't try to save users less than 1.2ms (a number I made up)
|
||||
var DONT_CARE_THRESHOLD = 1.2;
|
||||
@@ -65,7 +64,7 @@ function getExclusiveSummary(measurements) {
|
||||
|
||||
for (var i = 0; i < measurements.length; i++) {
|
||||
var measurement = measurements[i];
|
||||
var allIDs = assign(
|
||||
var allIDs = Object.assign(
|
||||
{},
|
||||
measurement.exclusive,
|
||||
measurement.inclusive
|
||||
@@ -117,7 +116,7 @@ function getInclusiveSummary(measurements, onlyClean) {
|
||||
|
||||
for (var i = 0; i < measurements.length; i++) {
|
||||
var measurement = measurements[i];
|
||||
var allIDs = assign(
|
||||
var allIDs = Object.assign(
|
||||
{},
|
||||
measurement.exclusive,
|
||||
measurement.inclusive
|
||||
@@ -185,7 +184,7 @@ function getUnchangedComponents(measurement) {
|
||||
}
|
||||
});
|
||||
});
|
||||
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
|
||||
var allIDs = Object.assign({}, measurement.exclusive, measurement.inclusive);
|
||||
|
||||
for (var id in allIDs) {
|
||||
var isDirty = false;
|
||||
|
||||
@@ -25,7 +25,6 @@ var ReactInstanceMap = require('ReactInstanceMap');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
var SyntheticEvent = require('SyntheticEvent');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var emptyObject = require('emptyObject');
|
||||
var findDOMNode = require('findDOMNode');
|
||||
var invariant = require('invariant');
|
||||
@@ -396,7 +395,7 @@ NoopInternalComponent.prototype = {
|
||||
var ShallowComponentWrapper = function(element) {
|
||||
this.construct(element);
|
||||
};
|
||||
assign(
|
||||
Object.assign(
|
||||
ShallowComponentWrapper.prototype,
|
||||
ReactCompositeComponent.Mixin, {
|
||||
_instantiateReactComponent: function(element) {
|
||||
@@ -499,7 +498,7 @@ function makeSimulator(eventType) {
|
||||
fakeNativeEvent,
|
||||
node
|
||||
);
|
||||
assign(event, eventData);
|
||||
Object.assign(event, eventData);
|
||||
|
||||
if (dispatchConfig.phasedRegistrationNames) {
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
@@ -560,7 +559,7 @@ buildSimulators();
|
||||
function makeNativeSimulator(eventType) {
|
||||
return function(domComponentOrNode, nativeEventData) {
|
||||
var fakeNativeEvent = new Event(eventType);
|
||||
assign(fakeNativeEvent, nativeEventData);
|
||||
Object.assign(fakeNativeEvent, nativeEventData);
|
||||
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
||||
ReactTestUtils.simulateNativeEventOnDOMComponent(
|
||||
eventType,
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
var ReactInstanceMap = require('ReactInstanceMap');
|
||||
var ReactTestUtils = require('ReactTestUtils');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
var invariant = require('invariant');
|
||||
|
||||
function reactComponentExpect(instance) {
|
||||
@@ -47,7 +46,7 @@ function reactComponentExpectInternal(internalInstance) {
|
||||
this._instance = internalInstance;
|
||||
}
|
||||
|
||||
assign(reactComponentExpectInternal.prototype, {
|
||||
Object.assign(reactComponentExpectInternal.prototype, {
|
||||
// Getters -------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,10 +15,9 @@ var ReactDOM = require('ReactDOM');
|
||||
var ReactDOMServer = require('ReactDOMServer');
|
||||
var React = require('React');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
// `version` will be added here by ReactIsomorphic.
|
||||
var ReactUMDEntry = assign({
|
||||
var ReactUMDEntry = Object.assign({
|
||||
__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM,
|
||||
__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer,
|
||||
}, React);
|
||||
|
||||
@@ -15,10 +15,9 @@ var ReactDOM = require('ReactDOM');
|
||||
var ReactDOMServer = require('ReactDOMServer');
|
||||
var ReactWithAddons = require('ReactWithAddons');
|
||||
|
||||
var assign = require('Object.assign');
|
||||
|
||||
// `version` will be added here by ReactIsomorphic.
|
||||
var ReactWithAddonsUMDEntry = assign({
|
||||
var ReactWithAddonsUMDEntry = Object.assign({
|
||||
__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM,
|
||||
__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer,
|
||||
}, ReactWithAddons);
|
||||
|
||||
Reference in New Issue
Block a user