react 0.12.1 → 0.13.0-beta.1
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/dist/JSXTransformer.js +352 -251
- package/dist/react-with-addons.js +5409 -4242
- package/dist/react-with-addons.min.js +5 -6
- package/dist/react.js +5012 -4136
- package/dist/react.min.js +5 -6
- package/lib/AutoFocusMixin.js +1 -1
- package/lib/BeforeInputEventPlugin.js +389 -112
- package/lib/CSSProperty.js +6 -3
- package/lib/CSSPropertyOperations.js +57 -10
- package/lib/CallbackQueue.js +2 -2
- package/lib/ChangeEventPlugin.js +3 -3
- package/lib/ClientReactRootIndex.js +1 -1
- package/lib/DOMChildrenOperations.js +6 -4
- package/lib/DOMProperty.js +1 -1
- package/lib/DOMPropertyOperations.js +4 -2
- package/lib/Danger.js +7 -6
- package/lib/DefaultEventPluginOrder.js +1 -2
- package/lib/EnterLeaveEventPlugin.js +1 -1
- package/lib/EventConstants.js +1 -1
- package/lib/EventPluginHub.js +9 -7
- package/lib/EventPluginRegistry.js +1 -1
- package/lib/EventPluginUtils.js +1 -1
- package/lib/EventPropagators.js +1 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +19 -7
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +3 -3
- package/lib/LocalEventTrapMixin.js +9 -2
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/Object.assign.js +3 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +17 -51
- package/lib/ReactBrowserComponentMixin.js +3 -13
- package/lib/ReactBrowserEventEmitter.js +4 -6
- package/lib/ReactCSSTransitionGroup.js +4 -1
- package/lib/ReactCSSTransitionGroupChild.js +12 -2
- package/lib/ReactChildReconciler.js +125 -0
- package/lib/ReactChildren.js +10 -8
- package/lib/ReactClass.js +916 -0
- package/lib/ReactComponent.js +81 -404
- package/lib/ReactComponentBrowserEnvironment.js +10 -83
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +533 -1132
- package/lib/ReactContext.js +6 -2
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +3 -8
- package/lib/ReactDOMButton.js +5 -6
- package/lib/ReactDOMComponent.js +110 -92
- package/lib/ReactDOMForm.js +5 -6
- package/lib/ReactDOMIDOperations.js +56 -74
- package/lib/ReactDOMImg.js +4 -6
- package/lib/ReactDOMInput.js +5 -6
- package/lib/ReactDOMOption.js +5 -6
- package/lib/ReactDOMSelect.js +57 -65
- package/lib/ReactDOMSelection.js +6 -2
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -35
- package/lib/ReactDOMTextarea.js +5 -6
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +14 -8
- package/lib/ReactDefaultPerf.js +16 -7
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +23 -15
- package/lib/ReactElementValidator.js +209 -57
- package/lib/ReactEmptyComponent.js +29 -11
- package/lib/ReactEventEmitterMixin.js +1 -1
- package/lib/ReactEventListener.js +3 -4
- package/lib/ReactInjection.js +7 -5
- package/lib/ReactInputSelection.js +3 -4
- package/lib/ReactInstanceHandles.js +3 -2
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLifeCycle.js +35 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +239 -68
- package/lib/ReactMultiChild.js +49 -47
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +72 -25
- package/lib/ReactOwner.js +4 -48
- package/lib/ReactPerf.js +21 -1
- package/lib/ReactPropTransferer.js +2 -57
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +14 -22
- package/lib/ReactPutListenerQueue.js +1 -1
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +107 -0
- package/lib/ReactRef.js +70 -0
- package/lib/ReactRootIndex.js +1 -1
- package/lib/ReactServerRendering.js +5 -3
- package/lib/ReactServerRenderingTransaction.js +1 -1
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +112 -26
- package/lib/ReactTransitionChildMapping.js +1 -1
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +48 -7
- package/lib/ReactUpdateQueue.js +264 -0
- package/lib/ReactUpdates.js +48 -61
- package/lib/ReactWithAddons.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +3 -3
- package/lib/ServerReactRootIndex.js +1 -1
- package/lib/SimpleEventPlugin.js +1 -1
- package/lib/SyntheticClipboardEvent.js +1 -2
- package/lib/SyntheticCompositionEvent.js +1 -2
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +11 -3
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -2
- package/lib/SyntheticKeyboardEvent.js +1 -1
- package/lib/SyntheticMouseEvent.js +2 -4
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +2 -5
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +3 -3
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +3 -3
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/escapeTextForBrowser.js +6 -6
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +11 -22
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +42 -0
- package/lib/getNodeForCharacterOffset.js +2 -2
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +85 -67
- package/lib/isEventSupported.js +1 -1
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +2 -3
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/memoizeStringOnly.js +4 -5
- package/lib/onlyChild.js +1 -1
- package/lib/setInnerHTML.js +12 -1
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +48 -6
- package/lib/traverseAllChildren.js +111 -55
- package/lib/update.js +1 -1
- package/lib/warning.js +12 -1
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/deprecated.js +0 -47
package/lib/cloneWithProps.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @providesModule cloneWithProps
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
var ReactElement = require("./ReactElement");
|
|
16
16
|
var ReactPropTransferer = require("./ReactPropTransferer");
|
|
@@ -25,8 +25,8 @@ var CHILDREN_PROP = keyOf({children: null});
|
|
|
25
25
|
* this is to add a CSS class.
|
|
26
26
|
*
|
|
27
27
|
* @param {object} child child component you'd like to clone
|
|
28
|
-
* @param {object} props props you'd like to modify.
|
|
29
|
-
*
|
|
28
|
+
* @param {object} props props you'd like to modify. className and style will be
|
|
29
|
+
* merged automatically.
|
|
30
30
|
* @return {object} a clone of child with props merged in.
|
|
31
31
|
*/
|
|
32
32
|
function cloneWithProps(child, props) {
|
package/lib/copyProperties.js
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
// Defeat circular references by requiring this directly.
|
|
16
|
-
var
|
|
16
|
+
var ReactClass = require("./ReactClass");
|
|
17
17
|
var ReactElement = require("./ReactElement");
|
|
18
18
|
|
|
19
19
|
var invariant = require("./invariant");
|
|
@@ -32,7 +32,7 @@ var invariant = require("./invariant");
|
|
|
32
32
|
function createFullPageComponent(tag) {
|
|
33
33
|
var elementFactory = ReactElement.createFactory(tag);
|
|
34
34
|
|
|
35
|
-
var FullPageComponent =
|
|
35
|
+
var FullPageComponent = ReactClass.createClass({
|
|
36
36
|
displayName: 'ReactFullPageComponent' + tag,
|
|
37
37
|
|
|
38
38
|
componentWillUnmount: function() {
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
var ESCAPE_LOOKUP = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
16
|
+
'&': '&',
|
|
17
|
+
'>': '>',
|
|
18
|
+
'<': '<',
|
|
19
|
+
'"': '"',
|
|
20
|
+
'\'': '''
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
var ESCAPE_REGEX = /[&><"']/g;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule findDOMNode
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
15
|
+
var ReactMount = require("./ReactMount");
|
|
16
|
+
|
|
17
|
+
var invariant = require("./invariant");
|
|
18
|
+
var isNode = require("./isNode");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the DOM node rendered by this element.
|
|
22
|
+
*
|
|
23
|
+
* @param {ReactComponent|DOMElement} componentOrElement
|
|
24
|
+
* @return {DOMElement} The root node of this element.
|
|
25
|
+
*/
|
|
26
|
+
function findDOMNode(componentOrElement) {
|
|
27
|
+
if (componentOrElement == null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (isNode(componentOrElement)) {
|
|
31
|
+
return componentOrElement;
|
|
32
|
+
}
|
|
33
|
+
if (ReactInstanceMap.has(componentOrElement)) {
|
|
34
|
+
return ReactMount.getNodeFromInstance(componentOrElement);
|
|
35
|
+
}
|
|
36
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
37
|
+
componentOrElement.render == null ||
|
|
38
|
+
typeof componentOrElement.render !== 'function',
|
|
39
|
+
'Component (with keys: %s) contains `render` method ' +
|
|
40
|
+
'but is not mounted in the DOM',
|
|
41
|
+
Object.keys(componentOrElement)
|
|
42
|
+
) : invariant(componentOrElement.render == null ||
|
|
43
|
+
typeof componentOrElement.render !== 'function'));
|
|
44
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
45
|
+
false,
|
|
46
|
+
'Element appears to be neither ReactComponent nor DOMNode (keys: %s)',
|
|
47
|
+
Object.keys(componentOrElement)
|
|
48
|
+
) : invariant(false));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = findDOMNode;
|
package/lib/flattenChildren.js
CHANGED
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
* @providesModule flattenChildren
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var ReactTextComponent = require("./ReactTextComponent");
|
|
12
|
+
'use strict';
|
|
15
13
|
|
|
16
14
|
var traverseAllChildren = require("./traverseAllChildren");
|
|
17
15
|
var warning = require("./warning");
|
|
@@ -25,26 +23,17 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
|
25
23
|
// We found a component instance.
|
|
26
24
|
var result = traverseContext;
|
|
27
25
|
var keyUnique = !result.hasOwnProperty(name);
|
|
28
|
-
("production" !== process.env.NODE_ENV
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
27
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
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);
|
|
34
|
+
}
|
|
35
35
|
if (keyUnique && child != null) {
|
|
36
|
-
|
|
37
|
-
var normalizedValue;
|
|
38
|
-
|
|
39
|
-
if (type === 'string') {
|
|
40
|
-
normalizedValue = ReactTextComponent(child);
|
|
41
|
-
} else if (type === 'number') {
|
|
42
|
-
normalizedValue = ReactTextComponent('' + child);
|
|
43
|
-
} else {
|
|
44
|
-
normalizedValue = child;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
result[name] = normalizedValue;
|
|
36
|
+
result[name] = child;
|
|
48
37
|
}
|
|
49
38
|
}
|
|
50
39
|
|
package/lib/getEventCharCode.js
CHANGED
package/lib/getEventKey.js
CHANGED
package/lib/getEventTarget.js
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule getIteratorFn
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
/* global Symbol */
|
|
16
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
17
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the iterator method function contained on the iterable object.
|
|
21
|
+
*
|
|
22
|
+
* Be sure to invoke the function with the iterable as context:
|
|
23
|
+
*
|
|
24
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
25
|
+
* if (iteratorFn) {
|
|
26
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
27
|
+
* ...
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @param {?object} maybeIterable
|
|
31
|
+
* @return {?function}
|
|
32
|
+
*/
|
|
33
|
+
function getIteratorFn(maybeIterable) {
|
|
34
|
+
var iteratorFn = maybeIterable && (
|
|
35
|
+
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
|
|
36
|
+
);
|
|
37
|
+
if (typeof iteratorFn === 'function') {
|
|
38
|
+
return iteratorFn;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = getIteratorFn;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @providesModule getNodeForCharacterOffset
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Given any node return the first leaf node without children.
|
|
@@ -53,7 +53,7 @@ function getNodeForCharacterOffset(root, offset) {
|
|
|
53
53
|
var nodeEnd = 0;
|
|
54
54
|
|
|
55
55
|
while (node) {
|
|
56
|
-
if (node.nodeType
|
|
56
|
+
if (node.nodeType === 3) {
|
|
57
57
|
nodeEnd = nodeStart + node.textContent.length;
|
|
58
58
|
|
|
59
59
|
if (nodeStart <= offset && nodeEnd >= offset) {
|
|
@@ -10,99 +10,117 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
|
+
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
16
|
+
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
17
|
+
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
18
|
+
|
|
19
|
+
var assign = require("./Object.assign");
|
|
20
|
+
var invariant = require("./invariant");
|
|
15
21
|
var warning = require("./warning");
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
// To avoid a cyclic dependency, we create the final class in this module
|
|
24
|
+
var ReactCompositeComponentWrapper = function() { };
|
|
25
|
+
assign(
|
|
26
|
+
ReactCompositeComponentWrapper.prototype,
|
|
27
|
+
ReactCompositeComponent.Mixin,
|
|
28
|
+
{
|
|
29
|
+
_instantiateReactComponent: instantiateReactComponent
|
|
30
|
+
}
|
|
31
|
+
);
|
|
21
32
|
|
|
22
33
|
/**
|
|
23
|
-
*
|
|
34
|
+
* Check if the type reference is a known internal type. I.e. not a user
|
|
35
|
+
* provided composite type.
|
|
24
36
|
*
|
|
25
|
-
* @param {
|
|
37
|
+
* @param {function} type
|
|
38
|
+
* @return {boolean} Returns true if this is a valid internal type.
|
|
39
|
+
*/
|
|
40
|
+
function isInternalComponentType(type) {
|
|
41
|
+
return (
|
|
42
|
+
typeof type === 'function' &&
|
|
43
|
+
typeof type.prototype.mountComponent === 'function' &&
|
|
44
|
+
typeof type.prototype.receiveComponent === 'function'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Given a ReactNode, create an instance that will actually be mounted.
|
|
50
|
+
*
|
|
51
|
+
* @param {ReactNode} node
|
|
26
52
|
* @param {*} parentCompositeType The composite type that resolved this.
|
|
27
53
|
* @return {object} A new instance of the element's constructor.
|
|
28
54
|
* @protected
|
|
29
55
|
*/
|
|
30
|
-
function instantiateReactComponent(
|
|
56
|
+
function instantiateReactComponent(node, parentCompositeType) {
|
|
31
57
|
var instance;
|
|
32
58
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
typeof element.type === 'string'),
|
|
37
|
-
'Only functions or strings can be mounted as React components.'
|
|
38
|
-
) : null);
|
|
39
|
-
|
|
40
|
-
// Resolve mock instances
|
|
41
|
-
if (element.type._mockedReactClassConstructor) {
|
|
42
|
-
// If this is a mocked class, we treat the legacy factory as if it was the
|
|
43
|
-
// class constructor for future proofing unit tests. Because this might
|
|
44
|
-
// be mocked as a legacy factory, we ignore any warnings triggerd by
|
|
45
|
-
// this temporary hack.
|
|
46
|
-
ReactLegacyElement._isLegacyCallWarningEnabled = false;
|
|
47
|
-
try {
|
|
48
|
-
instance = new element.type._mockedReactClassConstructor(
|
|
49
|
-
element.props
|
|
50
|
-
);
|
|
51
|
-
} finally {
|
|
52
|
-
ReactLegacyElement._isLegacyCallWarningEnabled = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// If the mock implementation was a legacy factory, then it returns a
|
|
56
|
-
// element. We need to turn this into a real component instance.
|
|
57
|
-
if (ReactElement.isValidElement(instance)) {
|
|
58
|
-
instance = new instance.type(instance.props);
|
|
59
|
-
}
|
|
59
|
+
if (node === null || node === false) {
|
|
60
|
+
node = ReactEmptyComponent.emptyElement;
|
|
61
|
+
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Auto-mocked components may have a prototype with a mocked render
|
|
70
|
-
// function. For those, we'll need to mock the result of the render
|
|
71
|
-
// since we consider undefined to be invalid results from render.
|
|
72
|
-
render.mockImplementation(
|
|
73
|
-
ReactEmptyComponent.getEmptyComponent
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
instance.construct(element);
|
|
77
|
-
return instance;
|
|
78
|
-
}
|
|
63
|
+
if (typeof node === 'object') {
|
|
64
|
+
var element = node;
|
|
65
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
66
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
67
|
+
element && (typeof element.type === 'function' ||
|
|
68
|
+
typeof element.type === 'string'),
|
|
69
|
+
'Only functions or strings can be mounted as React components.'
|
|
70
|
+
) : null);
|
|
79
71
|
}
|
|
80
|
-
}
|
|
81
72
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
element
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
// Special case string values
|
|
74
|
+
if (parentCompositeType === element.type &&
|
|
75
|
+
typeof element.type === 'string') {
|
|
76
|
+
// Avoid recursion if the wrapper renders itself.
|
|
77
|
+
instance = ReactNativeComponent.createInternalComponent(element);
|
|
78
|
+
// All native components are currently wrapped in a composite so we're
|
|
79
|
+
// safe to assume that this is what we should instantiate.
|
|
80
|
+
} else if (isInternalComponentType(element.type)) {
|
|
81
|
+
// This is temporarily available for custom components that are not string
|
|
82
|
+
// represenations. I.e. ART. Once those are updated to use the string
|
|
83
|
+
// representation, we can drop this code path.
|
|
84
|
+
instance = new element.type(element);
|
|
85
|
+
} else {
|
|
86
|
+
instance = new ReactCompositeComponentWrapper();
|
|
87
|
+
}
|
|
88
|
+
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
89
|
+
instance = ReactNativeComponent.createInstanceForText(node);
|
|
89
90
|
} else {
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
92
|
+
false,
|
|
93
|
+
'Encountered invalid React node of type %s',
|
|
94
|
+
typeof node
|
|
95
|
+
) : invariant(false));
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
if ("production" !== process.env.NODE_ENV) {
|
|
95
99
|
("production" !== process.env.NODE_ENV ? warning(
|
|
96
100
|
typeof instance.construct === 'function' &&
|
|
97
101
|
typeof instance.mountComponent === 'function' &&
|
|
98
|
-
typeof instance.receiveComponent === 'function'
|
|
102
|
+
typeof instance.receiveComponent === 'function' &&
|
|
103
|
+
typeof instance.unmountComponent === 'function',
|
|
99
104
|
'Only React Components can be mounted.'
|
|
100
105
|
) : null);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
// Sets up the instance. This can probably just move into the constructor now.
|
|
109
|
+
instance.construct(node);
|
|
110
|
+
|
|
111
|
+
// These two fields are used by the DOM and ART diffing algorithms
|
|
112
|
+
// respectively. Instead of using expandos on components, we should be
|
|
113
|
+
// storing the state needed by the diffing algorithms elsewhere.
|
|
114
|
+
instance._mountIndex = 0;
|
|
115
|
+
instance._mountImage = null;
|
|
116
|
+
|
|
117
|
+
// Internal instances should fully constructed at this point, so they should
|
|
118
|
+
// not get any new fields added to them at this point.
|
|
119
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
120
|
+
if (Object.preventExtensions) {
|
|
121
|
+
Object.preventExtensions(instance);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
106
124
|
|
|
107
125
|
return instance;
|
|
108
126
|
}
|