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
package/lib/getEventKey.js
CHANGED
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
|
+
var invariant = require("./invariant");
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
|
-
* Normalization of deprecated HTML5
|
|
25
|
+
* Normalization of deprecated HTML5 `key` values
|
|
24
26
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
25
27
|
*/
|
|
26
28
|
var normalizeKey = {
|
|
@@ -39,7 +41,7 @@ var normalizeKey = {
|
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
|
-
* Translation from legacy
|
|
44
|
+
* Translation from legacy `which`/`keyCode` to HTML5 `key`
|
|
43
45
|
* Only special keys supported, all others depend on keyboard layout or browser
|
|
44
46
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
45
47
|
*/
|
|
@@ -77,9 +79,37 @@ var translateToKey = {
|
|
|
77
79
|
* @return {string} Normalized `key` property.
|
|
78
80
|
*/
|
|
79
81
|
function getEventKey(nativeEvent) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
if (nativeEvent.key) {
|
|
83
|
+
// Normalize inconsistent values reported by browsers due to
|
|
84
|
+
// implementations of a working draft specification.
|
|
85
|
+
|
|
86
|
+
// FireFox implements `key` but returns `MozPrintableKey` for all
|
|
87
|
+
// printable characters (normalized to `Unidentified`), ignore it.
|
|
88
|
+
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
|
|
89
|
+
if (key !== 'Unidentified') {
|
|
90
|
+
return key;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Browser does not implement `key`, polyfill as much of it as we can.
|
|
95
|
+
if (nativeEvent.type === 'keypress') {
|
|
96
|
+
// Create the character from the `charCode` ourselves and use as an almost
|
|
97
|
+
// perfect replacement.
|
|
98
|
+
var charCode = 'charCode' in nativeEvent ?
|
|
99
|
+
nativeEvent.charCode :
|
|
100
|
+
nativeEvent.keyCode;
|
|
101
|
+
|
|
102
|
+
// The enter-key is technically both printable and non-printable and can
|
|
103
|
+
// thus be captured by `keypress`, no other non-printable key should.
|
|
104
|
+
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
|
|
105
|
+
}
|
|
106
|
+
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
|
|
107
|
+
// While user keyboard layout determines the actual meaning of each
|
|
108
|
+
// `keyCode` value, almost all function keys have a universal value.
|
|
109
|
+
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
("production" !== process.env.NODE_ENV ? invariant(false, "Unexpected keyboard event type: %s", nativeEvent.type) : invariant(false));
|
|
83
113
|
}
|
|
84
114
|
|
|
85
115
|
module.exports = getEventKey;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 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 getEventModifierState
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Translation from modifier key to the associated property in the event.
|
|
24
|
+
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
var modifierKeyToProp = {
|
|
28
|
+
'alt': 'altKey',
|
|
29
|
+
'control': 'ctrlKey',
|
|
30
|
+
'meta': 'metaKey',
|
|
31
|
+
'shift': 'shiftKey'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// IE8 does not implement getModifierState so we simply map it to the only
|
|
35
|
+
// modifier keys exposed by the event itself, does not support Lock-keys.
|
|
36
|
+
// Currently, all major browsers except Chrome seems to support Lock-keys.
|
|
37
|
+
function modifierStateGetter(keyArg) {
|
|
38
|
+
/*jshint validthis:true */
|
|
39
|
+
var syntheticEvent = this;
|
|
40
|
+
var nativeEvent = syntheticEvent.nativeEvent;
|
|
41
|
+
if (nativeEvent.getModifierState) {
|
|
42
|
+
return nativeEvent.getModifierState(keyArg);
|
|
43
|
+
}
|
|
44
|
+
var keyProp = modifierKeyToProp[keyArg.toLowerCase()];
|
|
45
|
+
return keyProp && nativeEvent[keyProp];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getEventModifierState(nativeEvent) {
|
|
49
|
+
return modifierStateGetter;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = getEventModifierState;
|
package/lib/getMarkupWrap.js
CHANGED
|
@@ -37,6 +37,7 @@ var shouldWrap = {
|
|
|
37
37
|
// they will be initialized in the wrong namespace (and will not display).
|
|
38
38
|
'circle': true,
|
|
39
39
|
'defs': true,
|
|
40
|
+
'ellipse': true,
|
|
40
41
|
'g': true,
|
|
41
42
|
'line': true,
|
|
42
43
|
'linearGradient': true,
|
|
@@ -78,6 +79,7 @@ var markupWrap = {
|
|
|
78
79
|
|
|
79
80
|
'circle': svgWrap,
|
|
80
81
|
'defs': svgWrap,
|
|
82
|
+
'ellipse': svgWrap,
|
|
81
83
|
'g': svgWrap,
|
|
82
84
|
'line': svgWrap,
|
|
83
85
|
'linearGradient': svgWrap,
|
|
@@ -32,7 +32,7 @@ function getTextContentAccessor() {
|
|
|
32
32
|
if (!contentKey && ExecutionEnvironment.canUseDOM) {
|
|
33
33
|
// Prefer textContent to innerText because many browsers support both but
|
|
34
34
|
// SVG <text> elements don't support innerText even when <div> does.
|
|
35
|
-
contentKey = 'textContent' in document.
|
|
35
|
+
contentKey = 'textContent' in document.documentElement ?
|
|
36
36
|
'textContent' :
|
|
37
37
|
'innerText';
|
|
38
38
|
}
|
package/lib/hyphenate.js
CHANGED
|
@@ -25,6 +25,9 @@ var _uppercasePattern = /([A-Z])/g;
|
|
|
25
25
|
* > hyphenate('backgroundColor')
|
|
26
26
|
* < "background-color"
|
|
27
27
|
*
|
|
28
|
+
* For CSS style names, use `hyphenateStyleName` instead which works properly
|
|
29
|
+
* with all vendor prefixes, including `ms`.
|
|
30
|
+
*
|
|
28
31
|
* @param {string} string
|
|
29
32
|
* @return {string}
|
|
30
33
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
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 hyphenateStyleName
|
|
17
|
+
* @typechecks
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var hyphenate = require("./hyphenate");
|
|
23
|
+
|
|
24
|
+
var msPattern = /^ms-/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hyphenates a camelcased CSS property name, for example:
|
|
28
|
+
*
|
|
29
|
+
* > hyphenate('backgroundColor')
|
|
30
|
+
* < "background-color"
|
|
31
|
+
* > hyphenate('MozTransition')
|
|
32
|
+
* < "-moz-transition"
|
|
33
|
+
* > hyphenate('msTransition')
|
|
34
|
+
* < "-ms-transition"
|
|
35
|
+
*
|
|
36
|
+
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
|
37
|
+
* is converted to `-ms-`.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} string
|
|
40
|
+
* @return {string}
|
|
41
|
+
*/
|
|
42
|
+
function hyphenateStyleName(string) {
|
|
43
|
+
return hyphenate(string).replace(msPattern, '-ms-');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = hyphenateStyleName;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 instantiateReactComponent
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var invariant = require("./invariant");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Validate a `componentDescriptor`. This should be exposed publicly in a follow
|
|
26
|
+
* up diff.
|
|
27
|
+
*
|
|
28
|
+
* @param {object} descriptor
|
|
29
|
+
* @return {boolean} Returns true if this is a valid descriptor of a Component.
|
|
30
|
+
*/
|
|
31
|
+
function isValidComponentDescriptor(descriptor) {
|
|
32
|
+
return (
|
|
33
|
+
descriptor &&
|
|
34
|
+
typeof descriptor.type === 'function' &&
|
|
35
|
+
typeof descriptor.type.prototype.mountComponent === 'function' &&
|
|
36
|
+
typeof descriptor.type.prototype.receiveComponent === 'function'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Given a `componentDescriptor` create an instance that will actually be
|
|
42
|
+
* mounted. Currently it just extracts an existing clone from composite
|
|
43
|
+
* components but this is an implementation detail which will change.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} descriptor
|
|
46
|
+
* @return {object} A new instance of componentDescriptor's constructor.
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
49
|
+
function instantiateReactComponent(descriptor) {
|
|
50
|
+
|
|
51
|
+
// TODO: Make warning
|
|
52
|
+
// if (__DEV__) {
|
|
53
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
54
|
+
isValidComponentDescriptor(descriptor),
|
|
55
|
+
'Only React Components are valid for mounting.'
|
|
56
|
+
) : invariant(isValidComponentDescriptor(descriptor)));
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
return new descriptor.type(descriptor);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = instantiateReactComponent;
|
package/lib/invariant.js
CHANGED
|
@@ -29,34 +29,32 @@
|
|
|
29
29
|
* will remain to ensure logic does not differ in production.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
var invariant = function(condition) {
|
|
33
|
-
if (
|
|
34
|
-
var error = new Error(
|
|
35
|
-
'Minified exception occured; use the non-minified dev environment for ' +
|
|
36
|
-
'the full error message and additional helpful warnings.'
|
|
37
|
-
);
|
|
38
|
-
error.framesToPop = 1;
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
44
|
-
invariant = function(condition, format, a, b, c, d, e, f) {
|
|
32
|
+
var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
33
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
45
34
|
if (format === undefined) {
|
|
46
35
|
throw new Error('invariant requires an error message argument');
|
|
47
36
|
}
|
|
37
|
+
}
|
|
48
38
|
|
|
49
|
-
|
|
39
|
+
if (!condition) {
|
|
40
|
+
var error;
|
|
41
|
+
if (format === undefined) {
|
|
42
|
+
error = new Error(
|
|
43
|
+
'Minified exception occurred; use the non-minified dev environment ' +
|
|
44
|
+
'for the full error message and additional helpful warnings.'
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
50
47
|
var args = [a, b, c, d, e, f];
|
|
51
48
|
var argIndex = 0;
|
|
52
|
-
|
|
49
|
+
error = new Error(
|
|
53
50
|
'Invariant Violation: ' +
|
|
54
51
|
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
55
52
|
);
|
|
56
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
57
|
-
throw error;
|
|
58
53
|
}
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
|
|
55
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
61
59
|
|
|
62
60
|
module.exports = invariant;
|
package/lib/isNode.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
function isNode(object) {
|
|
25
25
|
return !!(object && (
|
|
26
|
-
typeof Node
|
|
26
|
+
typeof Node === 'function' ? object instanceof Node :
|
|
27
27
|
typeof object === 'object' &&
|
|
28
28
|
typeof object.nodeType === 'number' &&
|
|
29
29
|
typeof object.nodeName === 'string'
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
|
-
* @providesModule
|
|
16
|
+
* @providesModule mapObject
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
@@ -25,12 +25,17 @@
|
|
|
25
25
|
*
|
|
26
26
|
* func(value, key, iteration)
|
|
27
27
|
*
|
|
28
|
+
* Grepable names:
|
|
29
|
+
*
|
|
30
|
+
* function objectMap()
|
|
31
|
+
* function objMap()
|
|
32
|
+
*
|
|
28
33
|
* @param {?object} obj Object to map keys over
|
|
29
34
|
* @param {function} func Invoked for each key/val pair.
|
|
30
35
|
* @param {?*} context
|
|
31
36
|
* @return {?object} Result of mapping or null if obj is falsey
|
|
32
37
|
*/
|
|
33
|
-
function
|
|
38
|
+
function mapObject(obj, func, context) {
|
|
34
39
|
if (!obj) {
|
|
35
40
|
return null;
|
|
36
41
|
}
|
|
@@ -44,4 +49,4 @@ function objMap(obj, func, context) {
|
|
|
44
49
|
return ret;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
module.exports =
|
|
52
|
+
module.exports = mapObject;
|
package/lib/mergeHelpers.js
CHANGED
|
@@ -92,6 +92,17 @@ var mergeHelpers = {
|
|
|
92
92
|
) : invariant(!isTerminal(arg) && !Array.isArray(arg)));
|
|
93
93
|
},
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @param {*} arg
|
|
97
|
+
*/
|
|
98
|
+
checkMergeIntoObjectArg: function(arg) {
|
|
99
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
100
|
+
(!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg),
|
|
101
|
+
'Tried to merge into an object, instead got %s.',
|
|
102
|
+
arg
|
|
103
|
+
) : invariant((!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg)));
|
|
104
|
+
},
|
|
105
|
+
|
|
95
106
|
/**
|
|
96
107
|
* Checks that a merge was not given a circular object or an object that had
|
|
97
108
|
* too great of depth.
|
package/lib/mergeInto.js
CHANGED
|
@@ -22,15 +22,16 @@
|
|
|
22
22
|
var mergeHelpers = require("./mergeHelpers");
|
|
23
23
|
|
|
24
24
|
var checkMergeObjectArg = mergeHelpers.checkMergeObjectArg;
|
|
25
|
+
var checkMergeIntoObjectArg = mergeHelpers.checkMergeIntoObjectArg;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Shallow merges two structures by mutating the first parameter.
|
|
28
29
|
*
|
|
29
|
-
* @param {object} one Object to be merged into.
|
|
30
|
+
* @param {object|function} one Object to be merged into.
|
|
30
31
|
* @param {?object} two Optional object with properties to merge from.
|
|
31
32
|
*/
|
|
32
33
|
function mergeInto(one, two) {
|
|
33
|
-
|
|
34
|
+
checkMergeIntoObjectArg(one);
|
|
34
35
|
if (two != null) {
|
|
35
36
|
checkMergeObjectArg(two);
|
|
36
37
|
for (var key in two) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 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 monitorCodeUse
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var invariant = require("./invariant");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Provides open-source compatible instrumentation for monitoring certain API
|
|
25
|
+
* uses before we're ready to issue a warning or refactor. It accepts an event
|
|
26
|
+
* name which may only contain the characters [a-z0-9_] and an optional data
|
|
27
|
+
* object with further information.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function monitorCodeUse(eventName, data) {
|
|
31
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
32
|
+
eventName && !/[^a-z0-9_]/.test(eventName),
|
|
33
|
+
'You must provide an eventName using only the characters [a-z0-9_]'
|
|
34
|
+
) : invariant(eventName && !/[^a-z0-9_]/.test(eventName)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = monitorCodeUse;
|
package/lib/onlyChild.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
"use strict";
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var ReactDescriptor = require("./ReactDescriptor");
|
|
21
21
|
|
|
22
22
|
var invariant = require("./invariant");
|
|
23
23
|
|
|
@@ -34,9 +34,9 @@ var invariant = require("./invariant");
|
|
|
34
34
|
*/
|
|
35
35
|
function onlyChild(children) {
|
|
36
36
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
37
|
-
|
|
37
|
+
ReactDescriptor.isValidDescriptor(children),
|
|
38
38
|
'onlyChild must be passed a children with exactly one child.'
|
|
39
|
-
) : invariant(
|
|
39
|
+
) : invariant(ReactDescriptor.isValidDescriptor(children)));
|
|
40
40
|
return children;
|
|
41
41
|
}
|
|
42
42
|
|