react 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/JSXTransformer.js +13448 -0
- package/dist/react-with-addons.js +20235 -0
- package/dist/react-with-addons.min.js +22 -0
- package/dist/react.js +18443 -0
- package/dist/react.min.js +21 -0
- package/lib/AutoFocusMixin.js +3 -1
- package/lib/BeforeInputEventPlugin.js +222 -0
- package/lib/CSSPropertyOperations.js +3 -3
- package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
- package/lib/ChangeEventPlugin.js +1 -1
- package/lib/CompositionEventPlugin.js +5 -1
- package/lib/DOMChildrenOperations.js +33 -20
- package/lib/DOMProperty.js +51 -21
- package/lib/DOMPropertyOperations.js +28 -16
- package/lib/DefaultEventPluginOrder.js +1 -0
- package/lib/EventConstants.js +1 -0
- package/lib/EventListener.js +5 -2
- package/lib/EventPluginHub.js +2 -5
- package/lib/EventPluginRegistry.js +6 -4
- package/lib/EventPluginUtils.js +11 -1
- package/lib/ExecutionEnvironment.js +8 -2
- package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +41 -58
- package/lib/LinkedValueUtils.js +26 -28
- package/lib/LocalEventTrapMixin.js +52 -0
- package/lib/React.js +39 -3
- package/lib/ReactBrowserComponentMixin.js +46 -0
- package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
- package/lib/ReactCSSTransitionGroup.js +12 -10
- package/lib/ReactCSSTransitionGroupChild.js +2 -5
- package/lib/ReactChildren.js +31 -10
- package/lib/ReactComponent.js +119 -223
- package/lib/ReactComponentBrowserEnvironment.js +3 -36
- package/lib/ReactComponentWithPureRenderMixin.js +54 -0
- package/lib/ReactCompositeComponent.js +249 -287
- package/lib/ReactDOM.js +25 -23
- package/lib/ReactDOMButton.js +2 -1
- package/lib/ReactDOMComponent.js +42 -23
- package/lib/ReactDOMForm.js +7 -12
- package/lib/ReactDOMIDOperations.js +2 -31
- package/lib/ReactDOMImg.js +7 -13
- package/lib/ReactDOMInput.js +2 -1
- package/lib/ReactDOMOption.js +11 -7
- package/lib/ReactDOMSelect.js +18 -16
- package/lib/ReactDOMSelection.js +35 -10
- package/lib/ReactDOMTextarea.js +9 -7
- package/lib/ReactDefaultBatchingStrategy.js +3 -3
- package/lib/ReactDefaultInjection.js +27 -14
- package/lib/ReactDefaultPerf.js +28 -11
- package/lib/ReactDefaultPerfAnalysis.js +4 -0
- package/lib/ReactDescriptor.js +251 -0
- package/lib/ReactDescriptorValidator.js +283 -0
- package/lib/ReactEmptyComponent.js +78 -0
- package/lib/ReactEventEmitterMixin.js +1 -3
- package/lib/ReactEventListener.js +189 -0
- package/lib/ReactInjection.js +8 -2
- package/lib/ReactInputSelection.js +2 -1
- package/lib/ReactLink.js +24 -0
- package/lib/ReactMount.js +61 -21
- package/lib/ReactMultiChild.js +18 -13
- package/lib/ReactOwner.js +6 -1
- package/lib/ReactPropTransferer.js +44 -29
- package/lib/ReactPropTypes.js +226 -242
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +21 -20
- package/lib/ReactServerRendering.js +41 -11
- package/lib/ReactServerRenderingTransaction.js +115 -0
- package/lib/ReactTestUtils.js +39 -21
- package/lib/ReactTextComponent.js +21 -13
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +19 -0
- package/lib/ReactTransitionGroup.js +9 -6
- package/lib/ReactUpdates.js +139 -22
- package/lib/ReactWithAddons.js +8 -3
- package/lib/SVGDOMPropertyConfig.js +97 -0
- package/lib/SimpleEventPlugin.js +7 -1
- package/lib/SyntheticInputEvent.js +52 -0
- package/lib/SyntheticKeyboardEvent.js +33 -4
- package/lib/SyntheticMouseEvent.js +3 -0
- package/lib/SyntheticTouchEvent.js +4 -1
- package/lib/SyntheticUIEvent.js +24 -2
- package/lib/Transaction.js +0 -32
- package/lib/cloneWithProps.js +10 -8
- package/lib/createFullPageComponent.js +1 -1
- package/lib/dangerousStyleValue.js +11 -5
- package/lib/{ReactComponentEnvironment.js → emptyObject.js} +6 -5
- package/lib/escapeTextForBrowser.js +2 -3
- package/lib/flattenChildren.js +9 -7
- package/lib/focusNode.js +33 -0
- package/lib/getEventKey.js +35 -5
- package/lib/getEventModifierState.js +52 -0
- package/lib/getMarkupWrap.js +2 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/hyphenate.js +3 -0
- package/lib/hyphenateStyleName.js +46 -0
- package/lib/instantiateReactComponent.js +62 -0
- package/lib/invariant.js +17 -19
- package/lib/isNode.js +1 -1
- package/lib/{objMap.js → mapObject.js} +8 -3
- package/lib/mergeHelpers.js +11 -0
- package/lib/mergeInto.js +3 -2
- package/lib/monitorCodeUse.js +37 -0
- package/lib/onlyChild.js +3 -3
- package/lib/performance.js +33 -0
- package/lib/performanceNow.js +5 -14
- package/lib/setInnerHTML.js +77 -0
- package/lib/shouldUpdateReactComponent.js +14 -28
- package/lib/toArray.js +1 -1
- package/lib/traverseAllChildren.js +9 -5
- package/lib/update.js +171 -0
- package/package.json +4 -3
- package/lib/ReactEventTopLevelCallback.js +0 -149
- package/lib/createObjectFrom.js +0 -61
- package/lib/objMapKeyVal.js +0 -47
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule performance
|
|
17
|
+
* @typechecks
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
23
|
+
|
|
24
|
+
var performance;
|
|
25
|
+
|
|
26
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
27
|
+
performance =
|
|
28
|
+
window.performance ||
|
|
29
|
+
window.msPerformance ||
|
|
30
|
+
window.webkitPerformance;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = performance || {};
|
package/lib/performanceNow.js
CHANGED
|
@@ -14,25 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
16
|
* @providesModule performanceNow
|
|
17
|
-
* @typechecks
|
|
17
|
+
* @typechecks
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
20
|
+
var performance = require("./performance");
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
|
-
* Detect if we can use window.performance.now() and gracefully
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* infrastructure.
|
|
23
|
+
* Detect if we can use `window.performance.now()` and gracefully fallback to
|
|
24
|
+
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
|
|
25
|
+
* because of Facebook's testing infrastructure.
|
|
29
26
|
*/
|
|
30
|
-
var performance = null;
|
|
31
|
-
|
|
32
|
-
if (ExecutionEnvironment.canUseDOM) {
|
|
33
|
-
performance = window.performance || window.webkitPerformance;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
27
|
if (!performance || !performance.now) {
|
|
37
28
|
performance = Date;
|
|
38
29
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule setInnerHTML
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Set the innerHTML property of a node, ensuring that whitespace is preserved
|
|
25
|
+
* even in IE8.
|
|
26
|
+
*
|
|
27
|
+
* @param {DOMElement} node
|
|
28
|
+
* @param {string} html
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
var setInnerHTML = function(node, html) {
|
|
32
|
+
node.innerHTML = html;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
36
|
+
// IE8: When updating a just created node with innerHTML only leading
|
|
37
|
+
// whitespace is removed. When updating an existing node with innerHTML
|
|
38
|
+
// whitespace in root TextNodes is also collapsed.
|
|
39
|
+
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
|
|
40
|
+
|
|
41
|
+
// Feature detection; only IE8 is known to behave improperly like this.
|
|
42
|
+
var testElement = document.createElement('div');
|
|
43
|
+
testElement.innerHTML = ' ';
|
|
44
|
+
if (testElement.innerHTML === '') {
|
|
45
|
+
setInnerHTML = function(node, html) {
|
|
46
|
+
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
47
|
+
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
48
|
+
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
49
|
+
// the initial and more favorable whitespace behavior.
|
|
50
|
+
// TODO: What to do on a detached node?
|
|
51
|
+
if (node.parentNode) {
|
|
52
|
+
node.parentNode.replaceChild(node, node);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// We also implement a workaround for non-visible tags disappearing into
|
|
56
|
+
// thin air on IE8, this only happens if there is no visible text
|
|
57
|
+
// in-front of the non-visible tags. Piggyback on the whitespace fix
|
|
58
|
+
// and simply check if any non-visible tags appear in the source.
|
|
59
|
+
if (html.match(/^[ \r\n\t\f]/) ||
|
|
60
|
+
html[0] === '<' && (
|
|
61
|
+
html.indexOf('<noscript') !== -1 ||
|
|
62
|
+
html.indexOf('<script') !== -1 ||
|
|
63
|
+
html.indexOf('<style') !== -1 ||
|
|
64
|
+
html.indexOf('<meta') !== -1 ||
|
|
65
|
+
html.indexOf('<link') !== -1)) {
|
|
66
|
+
// Recover leading whitespace by temporarily prepending any character.
|
|
67
|
+
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
68
|
+
node.innerHTML = '\uFEFF' + html;
|
|
69
|
+
node.firstChild.deleteData(0, 1);
|
|
70
|
+
} else {
|
|
71
|
+
node.innerHTML = html;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = setInnerHTML;
|
|
@@ -20,37 +20,23 @@
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Given a `
|
|
24
|
-
* should be updated as opposed to being destroyed or replaced
|
|
23
|
+
* Given a `prevDescriptor` and `nextDescriptor`, determines if the existing
|
|
24
|
+
* instance should be updated as opposed to being destroyed or replaced by a new
|
|
25
|
+
* instance. Both arguments are descriptors. This ensures that this logic can
|
|
26
|
+
* operate on stateless trees without any backing instance.
|
|
25
27
|
*
|
|
26
|
-
* @param {?object}
|
|
27
|
-
* @param {?object}
|
|
28
|
-
* @return {boolean} True if
|
|
28
|
+
* @param {?object} prevDescriptor
|
|
29
|
+
* @param {?object} nextDescriptor
|
|
30
|
+
* @return {boolean} True if the existing instance should be updated.
|
|
29
31
|
* @protected
|
|
30
32
|
*/
|
|
31
|
-
function shouldUpdateReactComponent(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (prevComponent._owner === nextComponent._owner) {
|
|
39
|
-
return true;
|
|
40
|
-
} else {
|
|
41
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
42
|
-
if (prevComponent.state) {
|
|
43
|
-
console.warn(
|
|
44
|
-
'A recent change to React has been found to impact your code. ' +
|
|
45
|
-
'A mounted component will now be unmounted and replaced by a ' +
|
|
46
|
-
'component (of the same class) if their owners are different. ' +
|
|
47
|
-
'Previously, ownership was not considered when updating.',
|
|
48
|
-
prevComponent,
|
|
49
|
-
nextComponent
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
33
|
+
function shouldUpdateReactComponent(prevDescriptor, nextDescriptor) {
|
|
34
|
+
if (prevDescriptor && nextDescriptor &&
|
|
35
|
+
prevDescriptor.type === nextDescriptor.type && (
|
|
36
|
+
(prevDescriptor.props && prevDescriptor.props.key) ===
|
|
37
|
+
(nextDescriptor.props && nextDescriptor.props.key)
|
|
38
|
+
) && prevDescriptor._owner === nextDescriptor._owner) {
|
|
39
|
+
return true;
|
|
54
40
|
}
|
|
55
41
|
return false;
|
|
56
42
|
}
|
package/lib/toArray.js
CHANGED
|
@@ -25,7 +25,7 @@ var invariant = require("./invariant");
|
|
|
25
25
|
* This API assumes the caller knows the contents of the data type. For less
|
|
26
26
|
* well defined inputs use createArrayFrom.
|
|
27
27
|
*
|
|
28
|
-
* @param {object|function} obj
|
|
28
|
+
* @param {object|function|filelist} obj
|
|
29
29
|
* @return {array}
|
|
30
30
|
*/
|
|
31
31
|
function toArray(obj) {
|
|
@@ -126,7 +126,8 @@ var traverseAllChildrenImpl =
|
|
|
126
126
|
// All of the above are perceived as null.
|
|
127
127
|
callback(traverseContext, null, storageName, indexSoFar);
|
|
128
128
|
subtreeCount = 1;
|
|
129
|
-
} else if (children.
|
|
129
|
+
} else if (children.type && children.type.prototype &&
|
|
130
|
+
children.type.prototype.mountComponentIntoNode) {
|
|
130
131
|
callback(traverseContext, children, storageName, indexSoFar);
|
|
131
132
|
subtreeCount = 1;
|
|
132
133
|
} else {
|
|
@@ -152,11 +153,11 @@ var traverseAllChildrenImpl =
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
} else if (type === 'string') {
|
|
155
|
-
var normalizedText =
|
|
156
|
+
var normalizedText = ReactTextComponent(children);
|
|
156
157
|
callback(traverseContext, normalizedText, storageName, indexSoFar);
|
|
157
158
|
subtreeCount += 1;
|
|
158
159
|
} else if (type === 'number') {
|
|
159
|
-
var normalizedNumber =
|
|
160
|
+
var normalizedNumber = ReactTextComponent('' + children);
|
|
160
161
|
callback(traverseContext, normalizedNumber, storageName, indexSoFar);
|
|
161
162
|
subtreeCount += 1;
|
|
162
163
|
}
|
|
@@ -179,11 +180,14 @@ var traverseAllChildrenImpl =
|
|
|
179
180
|
* @param {?*} children Children tree object.
|
|
180
181
|
* @param {!function} callback To invoke upon traversing each child.
|
|
181
182
|
* @param {?*} traverseContext Context for traversal.
|
|
183
|
+
* @return {!number} The number of children in this subtree.
|
|
182
184
|
*/
|
|
183
185
|
function traverseAllChildren(children, callback, traverseContext) {
|
|
184
|
-
if (children
|
|
185
|
-
|
|
186
|
+
if (children == null) {
|
|
187
|
+
return 0;
|
|
186
188
|
}
|
|
189
|
+
|
|
190
|
+
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
module.exports = traverseAllChildren;
|
package/lib/update.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule update
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var copyProperties = require("./copyProperties");
|
|
22
|
+
var keyOf = require("./keyOf");
|
|
23
|
+
var invariant = require("./invariant");
|
|
24
|
+
|
|
25
|
+
function shallowCopy(x) {
|
|
26
|
+
if (Array.isArray(x)) {
|
|
27
|
+
return x.concat();
|
|
28
|
+
} else if (x && typeof x === 'object') {
|
|
29
|
+
return copyProperties(new x.constructor(), x);
|
|
30
|
+
} else {
|
|
31
|
+
return x;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var COMMAND_PUSH = keyOf({$push: null});
|
|
36
|
+
var COMMAND_UNSHIFT = keyOf({$unshift: null});
|
|
37
|
+
var COMMAND_SPLICE = keyOf({$splice: null});
|
|
38
|
+
var COMMAND_SET = keyOf({$set: null});
|
|
39
|
+
var COMMAND_MERGE = keyOf({$merge: null});
|
|
40
|
+
var COMMAND_APPLY = keyOf({$apply: null});
|
|
41
|
+
|
|
42
|
+
var ALL_COMMANDS_LIST = [
|
|
43
|
+
COMMAND_PUSH,
|
|
44
|
+
COMMAND_UNSHIFT,
|
|
45
|
+
COMMAND_SPLICE,
|
|
46
|
+
COMMAND_SET,
|
|
47
|
+
COMMAND_MERGE,
|
|
48
|
+
COMMAND_APPLY
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
var ALL_COMMANDS_SET = {};
|
|
52
|
+
|
|
53
|
+
ALL_COMMANDS_LIST.forEach(function(command) {
|
|
54
|
+
ALL_COMMANDS_SET[command] = true;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function invariantArrayCase(value, spec, command) {
|
|
58
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
59
|
+
Array.isArray(value),
|
|
60
|
+
'update(): expected target of %s to be an array; got %s.',
|
|
61
|
+
command,
|
|
62
|
+
value
|
|
63
|
+
) : invariant(Array.isArray(value)));
|
|
64
|
+
var specValue = spec[command];
|
|
65
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
66
|
+
Array.isArray(specValue),
|
|
67
|
+
'update(): expected spec of %s to be an array; got %s. ' +
|
|
68
|
+
'Did you forget to wrap your parameter in an array?',
|
|
69
|
+
command,
|
|
70
|
+
specValue
|
|
71
|
+
) : invariant(Array.isArray(specValue)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function update(value, spec) {
|
|
75
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
76
|
+
typeof spec === 'object',
|
|
77
|
+
'update(): You provided a key path to update() that did not contain one ' +
|
|
78
|
+
'of %s. Did you forget to include {%s: ...}?',
|
|
79
|
+
ALL_COMMANDS_LIST.join(', '),
|
|
80
|
+
COMMAND_SET
|
|
81
|
+
) : invariant(typeof spec === 'object'));
|
|
82
|
+
|
|
83
|
+
if (spec.hasOwnProperty(COMMAND_SET)) {
|
|
84
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
85
|
+
Object.keys(spec).length === 1,
|
|
86
|
+
'Cannot have more than one key in an object with %s',
|
|
87
|
+
COMMAND_SET
|
|
88
|
+
) : invariant(Object.keys(spec).length === 1));
|
|
89
|
+
|
|
90
|
+
return spec[COMMAND_SET];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var nextValue = shallowCopy(value);
|
|
94
|
+
|
|
95
|
+
if (spec.hasOwnProperty(COMMAND_MERGE)) {
|
|
96
|
+
var mergeObj = spec[COMMAND_MERGE];
|
|
97
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
98
|
+
mergeObj && typeof mergeObj === 'object',
|
|
99
|
+
'update(): %s expects a spec of type \'object\'; got %s',
|
|
100
|
+
COMMAND_MERGE,
|
|
101
|
+
mergeObj
|
|
102
|
+
) : invariant(mergeObj && typeof mergeObj === 'object'));
|
|
103
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
104
|
+
nextValue && typeof nextValue === 'object',
|
|
105
|
+
'update(): %s expects a target of type \'object\'; got %s',
|
|
106
|
+
COMMAND_MERGE,
|
|
107
|
+
nextValue
|
|
108
|
+
) : invariant(nextValue && typeof nextValue === 'object'));
|
|
109
|
+
copyProperties(nextValue, spec[COMMAND_MERGE]);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (spec.hasOwnProperty(COMMAND_PUSH)) {
|
|
113
|
+
invariantArrayCase(value, spec, COMMAND_PUSH);
|
|
114
|
+
spec[COMMAND_PUSH].forEach(function(item) {
|
|
115
|
+
nextValue.push(item);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (spec.hasOwnProperty(COMMAND_UNSHIFT)) {
|
|
120
|
+
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
|
|
121
|
+
spec[COMMAND_UNSHIFT].forEach(function(item) {
|
|
122
|
+
nextValue.unshift(item);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (spec.hasOwnProperty(COMMAND_SPLICE)) {
|
|
127
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
128
|
+
Array.isArray(value),
|
|
129
|
+
'Expected %s target to be an array; got %s',
|
|
130
|
+
COMMAND_SPLICE,
|
|
131
|
+
value
|
|
132
|
+
) : invariant(Array.isArray(value)));
|
|
133
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
134
|
+
Array.isArray(spec[COMMAND_SPLICE]),
|
|
135
|
+
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
|
136
|
+
'Did you forget to wrap your parameters in an array?',
|
|
137
|
+
COMMAND_SPLICE,
|
|
138
|
+
spec[COMMAND_SPLICE]
|
|
139
|
+
) : invariant(Array.isArray(spec[COMMAND_SPLICE])));
|
|
140
|
+
spec[COMMAND_SPLICE].forEach(function(args) {
|
|
141
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
142
|
+
Array.isArray(args),
|
|
143
|
+
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
|
144
|
+
'Did you forget to wrap your parameters in an array?',
|
|
145
|
+
COMMAND_SPLICE,
|
|
146
|
+
spec[COMMAND_SPLICE]
|
|
147
|
+
) : invariant(Array.isArray(args)));
|
|
148
|
+
nextValue.splice.apply(nextValue, args);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (spec.hasOwnProperty(COMMAND_APPLY)) {
|
|
153
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
154
|
+
typeof spec[COMMAND_APPLY] === 'function',
|
|
155
|
+
'update(): expected spec of %s to be a function; got %s.',
|
|
156
|
+
COMMAND_APPLY,
|
|
157
|
+
spec[COMMAND_APPLY]
|
|
158
|
+
) : invariant(typeof spec[COMMAND_APPLY] === 'function'));
|
|
159
|
+
nextValue = spec[COMMAND_APPLY](nextValue);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
for (var k in spec) {
|
|
163
|
+
if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) {
|
|
164
|
+
nextValue[k] = update(value[k], spec[k]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return nextValue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = update;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react",
|
|
3
3
|
"description": "React is a JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"addons.js",
|
|
19
19
|
"react.js",
|
|
20
|
+
"dist/",
|
|
20
21
|
"lib/"
|
|
21
22
|
],
|
|
22
23
|
"main": "react.js",
|
|
@@ -27,8 +28,8 @@
|
|
|
27
28
|
"engines": {
|
|
28
29
|
"node": ">=0.10.0"
|
|
29
30
|
},
|
|
30
|
-
"
|
|
31
|
-
"envify": "
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"envify": "^2.0.0"
|
|
32
33
|
},
|
|
33
34
|
"browserify": {
|
|
34
35
|
"transform": [
|