react 0.13.3 → 0.14.0-beta1
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 +5 -2
- package/addons.js +7 -0
- package/dist/JSXTransformer.js +4101 -2432
- package/dist/react-with-addons.js +4389 -6277
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +4028 -5697
- package/dist/react.min.js +5 -6
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +26 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +86 -147
- package/lib/DOMPropertyOperations.js +91 -67
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +33 -44
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +15 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +71 -89
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +20 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +26 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +24 -31
- package/lib/ReactClass.js +96 -267
- package/lib/ReactComponent.js +28 -57
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +6 -7
- package/lib/ReactCompositeComponent.js +115 -381
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +16 -28
- package/lib/ReactDOMClient.js +90 -0
- package/lib/ReactDOMComponent.js +468 -156
- package/lib/ReactDOMIDOperations.js +25 -22
- package/lib/ReactDOMInput.js +79 -108
- package/lib/ReactDOMOption.js +58 -20
- package/lib/ReactDOMSelect.js +95 -83
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +44 -69
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +20 -76
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +26 -120
- package/lib/ReactElementValidator.js +56 -192
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +3 -3
- package/lib/ReactEventEmitterMixin.js +3 -13
- package/lib/ReactEventListener.js +58 -40
- package/lib/ReactFragment.js +33 -59
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +14 -23
- package/lib/ReactInstanceHandles.js +29 -58
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +142 -285
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -15
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +11 -36
- package/lib/ReactReconciler.js +14 -26
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +20 -15
- package/lib/ReactServerRenderingTransaction.js +9 -34
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +137 -190
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +69 -107
- package/lib/ReactUpdates.js +26 -81
- package/lib/ReactWithAddons.js +5 -6
- package/lib/SVGDOMPropertyConfig.js +39 -4
- package/lib/SelectEventPlugin.js +31 -33
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +138 -130
- package/lib/SyntheticClipboardEvent.js +5 -9
- package/lib/SyntheticCompositionEvent.js +4 -10
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +14 -15
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +4 -10
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +10 -16
- package/lib/SyntheticTouchEvent.js +3 -3
- package/lib/SyntheticUIEvent.js +5 -5
- package/lib/SyntheticWheelEvent.js +13 -17
- package/lib/Transaction.js +22 -28
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +6 -12
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +7 -27
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +3 -3
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +18 -40
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +23 -43
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +3 -3
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +23 -90
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +15 -17
- package/package.json +3 -3
- package/react.js +53 -1
- package/lib/LocalEventTrapMixin.js +0 -53
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactContext.js +0 -74
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/createFullPageComponent.js +0 -58
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/flattenChildren.js
CHANGED
|
@@ -22,15 +22,9 @@ var warning = require("./warning");
|
|
|
22
22
|
function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
23
23
|
// We found a component instance.
|
|
24
24
|
var result = traverseContext;
|
|
25
|
-
var keyUnique =
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
keyUnique,
|
|
29
|
-
'flattenChildren(...): Encountered two children with the same key, ' +
|
|
30
|
-
'`%s`. Child keys must be unique; when two children share a key, only ' +
|
|
31
|
-
'the first child will be used.',
|
|
32
|
-
name
|
|
33
|
-
) : null);
|
|
25
|
+
var keyUnique = result[name] === undefined;
|
|
26
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
27
|
+
'production' !== process.env.NODE_ENV ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
|
|
34
28
|
}
|
|
35
29
|
if (keyUnique && child != null) {
|
|
36
30
|
result[name] = child;
|
|
@@ -51,4 +45,4 @@ function flattenChildren(children) {
|
|
|
51
45
|
return result;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
|
-
module.exports = flattenChildren;
|
|
48
|
+
module.exports = flattenChildren;
|
package/lib/focusNode.js
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {array} an "accumulation" of items which is either an Array or
|
|
15
|
+
* @param {array} arr an "accumulation" of items which is either an Array or
|
|
16
16
|
* a single item. Useful when paired with the `accumulate` module. This is a
|
|
17
17
|
* simple utility that allows us to reason about a collection of items, but
|
|
18
18
|
* handling the case when there is exactly one item (and we do not need to
|
|
19
19
|
* allocate an array).
|
|
20
20
|
*/
|
|
21
|
-
var forEachAccumulated = function(arr, cb, scope) {
|
|
21
|
+
var forEachAccumulated = function (arr, cb, scope) {
|
|
22
22
|
if (Array.isArray(arr)) {
|
|
23
23
|
arr.forEach(cb, scope);
|
|
24
24
|
} else if (arr) {
|
|
@@ -26,4 +26,4 @@ var forEachAccumulated = function(arr, cb, scope) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
module.exports = forEachAccumulated;
|
|
29
|
+
module.exports = forEachAccumulated;
|
package/lib/getActiveElement.js
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
*
|
|
17
17
|
* The activeElement will be null only if the document body is not yet defined.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
function getActiveElement() /*?DOMElement*/{
|
|
20
22
|
try {
|
|
21
23
|
return document.activeElement || document.body;
|
|
22
24
|
} catch (e) {
|
|
@@ -24,4 +26,4 @@ function getActiveElement() /*?DOMElement*/ {
|
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
module.exports = getActiveElement;
|
|
29
|
+
module.exports = getActiveElement;
|
package/lib/getEventCharCode.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* presumably because it does not produce a tab-character in browsers.
|
|
21
21
|
*
|
|
22
22
|
* @param {object} nativeEvent Native browser event.
|
|
23
|
-
* @return {
|
|
23
|
+
* @return {number} Normalized `charCode` property.
|
|
24
24
|
*/
|
|
25
25
|
function getEventCharCode(nativeEvent) {
|
|
26
26
|
var charCode;
|
|
@@ -47,4 +47,4 @@ function getEventCharCode(nativeEvent) {
|
|
|
47
47
|
return 0;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
module.exports = getEventCharCode;
|
|
50
|
+
module.exports = getEventCharCode;
|
package/lib/getEventKey.js
CHANGED
|
@@ -28,7 +28,6 @@ var modifierKeyToProp = {
|
|
|
28
28
|
// modifier keys exposed by the event itself, does not support Lock-keys.
|
|
29
29
|
// Currently, all major browsers except Chrome seems to support Lock-keys.
|
|
30
30
|
function modifierStateGetter(keyArg) {
|
|
31
|
-
/*jshint validthis:true */
|
|
32
31
|
var syntheticEvent = this;
|
|
33
32
|
var nativeEvent = syntheticEvent.nativeEvent;
|
|
34
33
|
if (nativeEvent.getModifierState) {
|
|
@@ -42,4 +41,4 @@ function getEventModifierState(nativeEvent) {
|
|
|
42
41
|
return modifierStateGetter;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
module.exports = getEventModifierState;
|
|
44
|
+
module.exports = getEventModifierState;
|
package/lib/getEventTarget.js
CHANGED
package/lib/getIteratorFn.js
CHANGED
|
@@ -31,12 +31,10 @@ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
|
31
31
|
* @return {?function}
|
|
32
32
|
*/
|
|
33
33
|
function getIteratorFn(maybeIterable) {
|
|
34
|
-
var iteratorFn = maybeIterable && (
|
|
35
|
-
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
|
|
36
|
-
);
|
|
34
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
37
35
|
if (typeof iteratorFn === 'function') {
|
|
38
36
|
return iteratorFn;
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
module.exports = getIteratorFn;
|
|
40
|
+
module.exports = getIteratorFn;
|
package/lib/getMarkupWrap.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* @providesModule getMarkupWrap
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
12
14
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
13
15
|
|
|
14
16
|
var invariant = require("./invariant");
|
|
@@ -16,8 +18,7 @@ var invariant = require("./invariant");
|
|
|
16
18
|
/**
|
|
17
19
|
* Dummy container used to detect which wraps are necessary.
|
|
18
20
|
*/
|
|
19
|
-
var dummyNode =
|
|
20
|
-
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
|
21
|
+
var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Some browsers cannot use `innerHTML` to render certain elements standalone,
|
|
@@ -25,30 +26,14 @@ var dummyNode =
|
|
|
25
26
|
*
|
|
26
27
|
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// they will be initialized in the wrong namespace (and will not display).
|
|
31
|
-
'circle': true,
|
|
32
|
-
'clipPath': true,
|
|
33
|
-
'defs': true,
|
|
34
|
-
'ellipse': true,
|
|
35
|
-
'g': true,
|
|
36
|
-
'line': true,
|
|
37
|
-
'linearGradient': true,
|
|
38
|
-
'path': true,
|
|
39
|
-
'polygon': true,
|
|
40
|
-
'polyline': true,
|
|
41
|
-
'radialGradient': true,
|
|
42
|
-
'rect': true,
|
|
43
|
-
'stop': true,
|
|
44
|
-
'text': true
|
|
45
|
-
};
|
|
29
|
+
|
|
30
|
+
var shouldWrap = {};
|
|
46
31
|
|
|
47
32
|
var selectWrap = [1, '<select multiple="true">', '</select>'];
|
|
48
33
|
var tableWrap = [1, '<table>', '</table>'];
|
|
49
34
|
var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
|
|
50
35
|
|
|
51
|
-
var svgWrap = [1, '<svg>', '</svg>'];
|
|
36
|
+
var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
|
|
52
37
|
|
|
53
38
|
var markupWrap = {
|
|
54
39
|
'*': [1, '?<div>', '</div>'],
|
|
@@ -69,24 +54,18 @@ var markupWrap = {
|
|
|
69
54
|
'thead': tableWrap,
|
|
70
55
|
|
|
71
56
|
'td': trWrap,
|
|
72
|
-
'th': trWrap
|
|
73
|
-
|
|
74
|
-
'circle': svgWrap,
|
|
75
|
-
'clipPath': svgWrap,
|
|
76
|
-
'defs': svgWrap,
|
|
77
|
-
'ellipse': svgWrap,
|
|
78
|
-
'g': svgWrap,
|
|
79
|
-
'line': svgWrap,
|
|
80
|
-
'linearGradient': svgWrap,
|
|
81
|
-
'path': svgWrap,
|
|
82
|
-
'polygon': svgWrap,
|
|
83
|
-
'polyline': svgWrap,
|
|
84
|
-
'radialGradient': svgWrap,
|
|
85
|
-
'rect': svgWrap,
|
|
86
|
-
'stop': svgWrap,
|
|
87
|
-
'text': svgWrap
|
|
57
|
+
'th': trWrap
|
|
88
58
|
};
|
|
89
59
|
|
|
60
|
+
// Initilize the SVG elements since we know they'll always need to be wrapped
|
|
61
|
+
// consistently. If they are created inside a <div> they will be initialized in
|
|
62
|
+
// the wrong namespace (and will not display).
|
|
63
|
+
var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
|
|
64
|
+
svgElements.forEach(function (nodeName) {
|
|
65
|
+
markupWrap[nodeName] = svgWrap;
|
|
66
|
+
shouldWrap[nodeName] = true;
|
|
67
|
+
});
|
|
68
|
+
|
|
90
69
|
/**
|
|
91
70
|
* Gets the markup wrap configuration for the supplied `nodeName`.
|
|
92
71
|
*
|
|
@@ -96,7 +75,7 @@ var markupWrap = {
|
|
|
96
75
|
* @return {?array} Markup wrap configuration, if applicable.
|
|
97
76
|
*/
|
|
98
77
|
function getMarkupWrap(nodeName) {
|
|
99
|
-
|
|
78
|
+
!!!dummyNode ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : undefined;
|
|
100
79
|
if (!markupWrap.hasOwnProperty(nodeName)) {
|
|
101
80
|
nodeName = '*';
|
|
102
81
|
}
|
|
@@ -111,5 +90,4 @@ function getMarkupWrap(nodeName) {
|
|
|
111
90
|
return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
|
|
112
91
|
}
|
|
113
92
|
|
|
114
|
-
|
|
115
|
-
module.exports = getMarkupWrap;
|
|
93
|
+
module.exports = getMarkupWrap;
|
|
@@ -25,11 +25,9 @@ function getTextContentAccessor() {
|
|
|
25
25
|
if (!contentKey && ExecutionEnvironment.canUseDOM) {
|
|
26
26
|
// Prefer textContent to innerText because many browsers support both but
|
|
27
27
|
// SVG <text> elements don't support innerText even when <div> does.
|
|
28
|
-
contentKey = 'textContent' in document.documentElement ?
|
|
29
|
-
'textContent' :
|
|
30
|
-
'innerText';
|
|
28
|
+
contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
|
|
31
29
|
}
|
|
32
30
|
return contentKey;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
module.exports = getTextContentAccessor;
|
|
33
|
+
module.exports = getTextContentAccessor;
|
package/lib/hyphenate.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
13
15
|
var _uppercasePattern = /([A-Z])/g;
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -28,4 +30,4 @@ function hyphenate(string) {
|
|
|
28
30
|
return string.replace(_uppercasePattern, '-$1').toLowerCase();
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
module.exports = hyphenate;
|
|
33
|
+
module.exports = hyphenate;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
var hyphenate = require("./hyphenate");
|
|
16
16
|
|
|
@@ -36,4 +36,4 @@ function hyphenateStyleName(string) {
|
|
|
36
36
|
return hyphenate(string).replace(msPattern, '-ms-');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
module.exports = hyphenateStyleName;
|
|
39
|
+
module.exports = hyphenateStyleName;
|
|
@@ -21,14 +21,20 @@ var invariant = require("./invariant");
|
|
|
21
21
|
var warning = require("./warning");
|
|
22
22
|
|
|
23
23
|
// To avoid a cyclic dependency, we create the final class in this module
|
|
24
|
-
var ReactCompositeComponentWrapper = function() {
|
|
25
|
-
assign(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
var ReactCompositeComponentWrapper = function () {};
|
|
25
|
+
assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
26
|
+
_instantiateReactComponent: instantiateReactComponent
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function getDeclarationErrorAddendum(owner) {
|
|
30
|
+
if (owner) {
|
|
31
|
+
var name = owner.getName();
|
|
32
|
+
if (name) {
|
|
33
|
+
return ' Check the render method of `' + name + '`.';
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Check if the type reference is a known internal type. I.e. not a user
|
|
@@ -38,23 +44,17 @@ assign(
|
|
|
38
44
|
* @return {boolean} Returns true if this is a valid internal type.
|
|
39
45
|
*/
|
|
40
46
|
function isInternalComponentType(type) {
|
|
41
|
-
return
|
|
42
|
-
typeof type === 'function' &&
|
|
43
|
-
typeof type.prototype !== 'undefined' &&
|
|
44
|
-
typeof type.prototype.mountComponent === 'function' &&
|
|
45
|
-
typeof type.prototype.receiveComponent === 'function'
|
|
46
|
-
);
|
|
47
|
+
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* Given a ReactNode, create an instance that will actually be mounted.
|
|
51
52
|
*
|
|
52
53
|
* @param {ReactNode} node
|
|
53
|
-
* @param {*} parentCompositeType The composite type that resolved this.
|
|
54
54
|
* @return {object} A new instance of the element's constructor.
|
|
55
55
|
* @protected
|
|
56
56
|
*/
|
|
57
|
-
function instantiateReactComponent(node
|
|
57
|
+
function instantiateReactComponent(node) {
|
|
58
58
|
var instance;
|
|
59
59
|
|
|
60
60
|
if (node === null || node === false) {
|
|
@@ -63,21 +63,11 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
63
63
|
|
|
64
64
|
if (typeof node === 'object') {
|
|
65
65
|
var element = node;
|
|
66
|
-
|
|
67
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
68
|
-
element && (typeof element.type === 'function' ||
|
|
69
|
-
typeof element.type === 'string'),
|
|
70
|
-
'Only functions or strings can be mounted as React components.'
|
|
71
|
-
) : null);
|
|
72
|
-
}
|
|
66
|
+
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
|
|
73
67
|
|
|
74
68
|
// Special case string values
|
|
75
|
-
if (
|
|
76
|
-
typeof element.type === 'string') {
|
|
77
|
-
// Avoid recursion if the wrapper renders itself.
|
|
69
|
+
if (typeof element.type === 'string') {
|
|
78
70
|
instance = ReactNativeComponent.createInternalComponent(element);
|
|
79
|
-
// All native components are currently wrapped in a composite so we're
|
|
80
|
-
// safe to assume that this is what we should instantiate.
|
|
81
71
|
} else if (isInternalComponentType(element.type)) {
|
|
82
72
|
// This is temporarily available for custom components that are not string
|
|
83
73
|
// represenations. I.e. ART. Once those are updated to use the string
|
|
@@ -89,21 +79,11 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
89
79
|
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
90
80
|
instance = ReactNativeComponent.createInstanceForText(node);
|
|
91
81
|
} else {
|
|
92
|
-
|
|
93
|
-
false,
|
|
94
|
-
'Encountered invalid React node of type %s',
|
|
95
|
-
typeof node
|
|
96
|
-
) : invariant(false));
|
|
82
|
+
!false ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined;
|
|
97
83
|
}
|
|
98
84
|
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
typeof instance.construct === 'function' &&
|
|
102
|
-
typeof instance.mountComponent === 'function' &&
|
|
103
|
-
typeof instance.receiveComponent === 'function' &&
|
|
104
|
-
typeof instance.unmountComponent === 'function',
|
|
105
|
-
'Only React Components can be mounted.'
|
|
106
|
-
) : null);
|
|
85
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
86
|
+
'production' !== process.env.NODE_ENV ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined;
|
|
107
87
|
}
|
|
108
88
|
|
|
109
89
|
// Sets up the instance. This can probably just move into the constructor now.
|
|
@@ -115,14 +95,14 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
115
95
|
instance._mountIndex = 0;
|
|
116
96
|
instance._mountImage = null;
|
|
117
97
|
|
|
118
|
-
if (
|
|
98
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
119
99
|
instance._isOwnerNecessary = false;
|
|
120
100
|
instance._warnedAboutRefsInRender = false;
|
|
121
101
|
}
|
|
122
102
|
|
|
123
103
|
// Internal instances should fully constructed at this point, so they should
|
|
124
104
|
// not get any new fields added to them at this point.
|
|
125
|
-
if (
|
|
105
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
126
106
|
if (Object.preventExtensions) {
|
|
127
107
|
Object.preventExtensions(instance);
|
|
128
108
|
}
|
|
@@ -131,4 +111,4 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
131
111
|
return instance;
|
|
132
112
|
}
|
|
133
113
|
|
|
134
|
-
module.exports = instantiateReactComponent;
|
|
114
|
+
module.exports = instantiateReactComponent;
|
package/lib/invariant.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @providesModule invariant
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Use invariant() to assert state which your program assumes to be true.
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* will remain to ensure logic does not differ in production.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
26
|
-
if (
|
|
25
|
+
var invariant = function (condition, format, a, b, c, d, e, f) {
|
|
26
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
27
27
|
if (format === undefined) {
|
|
28
28
|
throw new Error('invariant requires an error message argument');
|
|
29
29
|
}
|
|
@@ -32,17 +32,13 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
|
32
32
|
if (!condition) {
|
|
33
33
|
var error;
|
|
34
34
|
if (format === undefined) {
|
|
35
|
-
error = new Error(
|
|
36
|
-
'Minified exception occurred; use the non-minified dev environment ' +
|
|
37
|
-
'for the full error message and additional helpful warnings.'
|
|
38
|
-
);
|
|
35
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
39
36
|
} else {
|
|
40
37
|
var args = [a, b, c, d, e, f];
|
|
41
38
|
var argIndex = 0;
|
|
42
|
-
error = new Error(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
39
|
+
error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () {
|
|
40
|
+
return args[argIndex++];
|
|
41
|
+
}));
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
@@ -50,4 +46,4 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
|
50
46
|
}
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
module.exports = invariant;
|
|
49
|
+
module.exports = invariant;
|