react 15.1.0-alpha.1 → 15.2.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/dist/react-with-addons.js +2145 -1396
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1941 -1329
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +15 -8
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +17 -3
- package/lib/Danger.js +10 -8
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +99 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +66 -106
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +7 -1
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMInput.js +52 -16
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +132 -45
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactErrorUtils.js +15 -65
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +9 -4
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactMount.js +25 -14
- package/lib/ReactMultiChild.js +31 -9
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +7 -1
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +5 -3
- package/lib/ReactNoop.js +76 -0
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +8 -2
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +126 -0
- package/lib/ReactTestReconcileTransaction.js +100 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +21 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +40 -6
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +9 -8
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +8 -6
- package/lib/ResponderTouchHistoryStore.js +6 -4
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +3 -1
- package/lib/accumulateInto.js +3 -1
- package/lib/checkReactTypeSpec.js +71 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +13 -4
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/instantiateReactComponent.js +20 -17
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +38 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
22
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
21
23
|
var ReactElement = require('./ReactElement');
|
|
22
24
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
+
|
|
26
|
+
var checkReactTypeSpec = require('./checkReactTypeSpec');
|
|
25
27
|
|
|
26
28
|
var canDefineProperty = require('./canDefineProperty');
|
|
27
29
|
var getIteratorFn = require('./getIteratorFn');
|
|
28
|
-
var invariant = require('fbjs/lib/invariant');
|
|
29
30
|
var warning = require('fbjs/lib/warning');
|
|
30
31
|
|
|
31
32
|
function getDeclarationErrorAddendum() {
|
|
@@ -45,13 +46,24 @@ function getDeclarationErrorAddendum() {
|
|
|
45
46
|
*/
|
|
46
47
|
var ownerHasKeyUseWarning = {};
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
50
|
+
var info = getDeclarationErrorAddendum();
|
|
51
|
+
|
|
52
|
+
if (!info) {
|
|
53
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
54
|
+
if (parentName) {
|
|
55
|
+
info = ' Check the top-level render call using <' + parentName + '>.';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return info;
|
|
59
|
+
}
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
62
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
52
63
|
* This element is in an array. The array could grow and shrink or be
|
|
53
64
|
* reordered. All children that haven't already been validated are required to
|
|
54
|
-
* have a "key" property assigned to it.
|
|
65
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
66
|
+
* will only be shown once.
|
|
55
67
|
*
|
|
56
68
|
* @internal
|
|
57
69
|
* @param {ReactElement} element Element that requires a key.
|
|
@@ -63,54 +75,24 @@ function validateExplicitKey(element, parentType) {
|
|
|
63
75
|
}
|
|
64
76
|
element._store.validated = true;
|
|
65
77
|
|
|
66
|
-
var
|
|
67
|
-
if (addenda === null) {
|
|
68
|
-
// we already showed the warning
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : void 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Shared warning and monitoring code for the key warnings.
|
|
76
|
-
*
|
|
77
|
-
* @internal
|
|
78
|
-
* @param {string} messageType A key used for de-duping warnings.
|
|
79
|
-
* @param {ReactElement} element Component that requires a key.
|
|
80
|
-
* @param {*} parentType element's parent's type.
|
|
81
|
-
* @returns {?object} A set of addenda to use in the warning message, or null
|
|
82
|
-
* if the warning has already been shown before (and shouldn't be shown again).
|
|
83
|
-
*/
|
|
84
|
-
function getAddendaForKeyUse(messageType, element, parentType) {
|
|
85
|
-
var addendum = getDeclarationErrorAddendum();
|
|
86
|
-
if (!addendum) {
|
|
87
|
-
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
88
|
-
if (parentName) {
|
|
89
|
-
addendum = ' Check the top-level render call using <' + parentName + '>.';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
78
|
+
var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
|
|
92
79
|
|
|
93
|
-
var
|
|
94
|
-
if (memoizer[
|
|
95
|
-
return
|
|
80
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
81
|
+
if (memoizer[currentComponentErrorInfo]) {
|
|
82
|
+
return;
|
|
96
83
|
}
|
|
97
|
-
memoizer[
|
|
98
|
-
|
|
99
|
-
var addenda = {
|
|
100
|
-
parentOrOwner: addendum,
|
|
101
|
-
url: ' See https://fb.me/react-warning-keys for more information.',
|
|
102
|
-
childOwner: null
|
|
103
|
-
};
|
|
84
|
+
memoizer[currentComponentErrorInfo] = true;
|
|
104
85
|
|
|
105
86
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
106
87
|
// property, it may be the creator of the child that's responsible for
|
|
107
88
|
// assigning it a key.
|
|
89
|
+
var childOwner = '';
|
|
108
90
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
109
91
|
// Give the component that originally created this child.
|
|
110
|
-
|
|
92
|
+
childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
|
|
111
93
|
}
|
|
112
94
|
|
|
113
|
-
|
|
95
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeDevtool.getCurrentStackAddendum(element)) : void 0;
|
|
114
96
|
}
|
|
115
97
|
|
|
116
98
|
/**
|
|
@@ -155,43 +137,6 @@ function validateChildKeys(node, parentType) {
|
|
|
155
137
|
}
|
|
156
138
|
}
|
|
157
139
|
|
|
158
|
-
/**
|
|
159
|
-
* Assert that the props are valid
|
|
160
|
-
*
|
|
161
|
-
* @param {string} componentName Name of the component for error messages.
|
|
162
|
-
* @param {object} propTypes Map of prop name to a ReactPropType
|
|
163
|
-
* @param {object} props
|
|
164
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
function checkPropTypes(componentName, propTypes, props, location) {
|
|
168
|
-
for (var propName in propTypes) {
|
|
169
|
-
if (propTypes.hasOwnProperty(propName)) {
|
|
170
|
-
var error;
|
|
171
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
172
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
173
|
-
// After these have been cleaned up, we'll let them throw.
|
|
174
|
-
try {
|
|
175
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
176
|
-
// behavior as without this statement except with a better message.
|
|
177
|
-
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : void 0;
|
|
178
|
-
error = propTypes[propName](props, propName, componentName, location);
|
|
179
|
-
} catch (ex) {
|
|
180
|
-
error = ex;
|
|
181
|
-
}
|
|
182
|
-
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : void 0;
|
|
183
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
184
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
185
|
-
// same error.
|
|
186
|
-
loggedTypeFailures[error.message] = true;
|
|
187
|
-
|
|
188
|
-
var addendum = getDeclarationErrorAddendum();
|
|
189
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : void 0;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
140
|
/**
|
|
196
141
|
* Given an element, validate that its props follow the propTypes definition,
|
|
197
142
|
* provided by the type.
|
|
@@ -205,7 +150,7 @@ function validatePropTypes(element) {
|
|
|
205
150
|
}
|
|
206
151
|
var name = componentClass.displayName || componentClass.name;
|
|
207
152
|
if (componentClass.propTypes) {
|
|
208
|
-
|
|
153
|
+
checkReactTypeSpec(componentClass.propTypes, element.props, ReactPropTypeLocations.prop, name, element, null);
|
|
209
154
|
}
|
|
210
155
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
211
156
|
process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var SyntheticDragEvent = require('./SyntheticDragEvent');
|
|
15
|
-
|
|
16
14
|
var caughtError = null;
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -57,70 +55,22 @@ var ReactErrorUtils = {
|
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
if (process.env.NODE_ENV !== 'production') {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!(ev instanceof SyntheticDragEvent)) {
|
|
75
|
-
return true;
|
|
76
|
-
} else if (cacheCanWrapEvent !== null) {
|
|
77
|
-
return cacheCanWrapEvent;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var canAccessDropEffect = false;
|
|
81
|
-
function handleWrappedEvent() {
|
|
82
|
-
try {
|
|
83
|
-
ev.dataTransfer.dropEffect; // eslint-disable-line no-unused-expressions
|
|
84
|
-
canAccessDropEffect = true;
|
|
85
|
-
} catch (e) {}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var wrappedEventName = 'react-wrappeddragevent';
|
|
89
|
-
var wrappedEvent = document.createEvent('Event');
|
|
90
|
-
wrappedEvent.initEvent(wrappedEventName, false, false);
|
|
91
|
-
fakeNode.addEventListener(wrappedEventName, handleWrappedEvent, false);
|
|
92
|
-
fakeNode.dispatchEvent(wrappedEvent);
|
|
93
|
-
fakeNode.removeEventListener(wrappedEventName, handleWrappedEvent, false);
|
|
94
|
-
|
|
95
|
-
cacheCanWrapEvent = canAccessDropEffect;
|
|
96
|
-
return canAccessDropEffect;
|
|
58
|
+
/**
|
|
59
|
+
* To help development we can get better devtools integration by simulating a
|
|
60
|
+
* real browser event.
|
|
61
|
+
*/
|
|
62
|
+
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
|
63
|
+
var fakeNode = document.createElement('react');
|
|
64
|
+
ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
|
|
65
|
+
var boundFunc = func.bind(null, a, b);
|
|
66
|
+
var evtType = 'react-' + name;
|
|
67
|
+
fakeNode.addEventListener(evtType, boundFunc, false);
|
|
68
|
+
var evt = document.createEvent('Event');
|
|
69
|
+
evt.initEvent(evtType, false, false);
|
|
70
|
+
fakeNode.dispatchEvent(evt);
|
|
71
|
+
fakeNode.removeEventListener(evtType, boundFunc, false);
|
|
97
72
|
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* To help development we can get better devtools integration by simulating a
|
|
101
|
-
* real browser event.
|
|
102
|
-
*/
|
|
103
|
-
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
|
104
|
-
fakeNode = document.createElement('react');
|
|
105
|
-
|
|
106
|
-
ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
|
|
107
|
-
if (!canWrapEvent(a)) {
|
|
108
|
-
invokeGuardedCallback(name, func, a, b);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var boundFunc = func.bind(null, a, b);
|
|
113
|
-
var evtType = 'react-' + name;
|
|
114
|
-
fakeNode.addEventListener(evtType, boundFunc, false);
|
|
115
|
-
var evt = document.createEvent('Event');
|
|
116
|
-
evt.initEvent(evtType, false, false);
|
|
117
|
-
fakeNode.dispatchEvent(evt);
|
|
118
|
-
fakeNode.removeEventListener(evtType, boundFunc, false);
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
cacheCanWrapEvent = null;
|
|
123
|
-
})();
|
|
73
|
+
}
|
|
124
74
|
}
|
|
125
75
|
|
|
126
76
|
module.exports = ReactErrorUtils;
|
|
@@ -31,8 +31,8 @@ function findParent(inst) {
|
|
|
31
31
|
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
|
|
32
32
|
// traversal, but caching is difficult to do correctly without using a
|
|
33
33
|
// mutation observer to listen for all DOM changes.
|
|
34
|
-
while (inst.
|
|
35
|
-
inst = inst.
|
|
34
|
+
while (inst._hostParent) {
|
|
35
|
+
inst = inst._hostParent;
|
|
36
36
|
}
|
|
37
37
|
var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
38
38
|
var container = rootNode.parentNode;
|
package/lib/ReactFragment.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactChildren = require('./ReactChildren');
|
|
15
17
|
var ReactElement = require('./ReactElement');
|
|
16
18
|
|
|
@@ -46,7 +48,7 @@ var ReactFragment = {
|
|
|
46
48
|
return object;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
!(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM
|
|
51
|
+
!(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.') : _prodInvariant('0') : void 0;
|
|
50
52
|
|
|
51
53
|
var result = [];
|
|
52
54
|
|
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule
|
|
9
|
+
* @providesModule ReactHostComponent
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
+
_assign = require('object-assign');
|
|
15
16
|
|
|
16
17
|
var invariant = require('fbjs/lib/invariant');
|
|
17
18
|
|
|
18
|
-
var autoGenerateWrapperClass = null;
|
|
19
19
|
var genericComponentClass = null;
|
|
20
|
-
// This registry keeps track of wrapper classes around
|
|
20
|
+
// This registry keeps track of wrapper classes around host tags.
|
|
21
21
|
var tagToComponentClass = {};
|
|
22
22
|
var textComponentClass = null;
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var ReactHostComponentInjection = {
|
|
25
25
|
// This accepts a class that receives the tag string. This is a catch all
|
|
26
26
|
// that can render any kind of tag.
|
|
27
27
|
injectGenericComponentClass: function (componentClass) {
|
|
@@ -40,31 +40,13 @@ var ReactNativeComponentInjection = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Get a
|
|
44
|
-
*
|
|
45
|
-
* @param {ReactElement} element The tag for which to get the class.
|
|
46
|
-
* @return {function} The React class constructor function.
|
|
47
|
-
*/
|
|
48
|
-
function getComponentClassForElement(element) {
|
|
49
|
-
if (typeof element.type === 'function') {
|
|
50
|
-
return element.type;
|
|
51
|
-
}
|
|
52
|
-
var tag = element.type;
|
|
53
|
-
var componentClass = tagToComponentClass[tag];
|
|
54
|
-
if (componentClass == null) {
|
|
55
|
-
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
|
|
56
|
-
}
|
|
57
|
-
return componentClass;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Get a native internal component class for a specific tag.
|
|
43
|
+
* Get a host internal component class for a specific tag.
|
|
62
44
|
*
|
|
63
45
|
* @param {ReactElement} element The element to create.
|
|
64
46
|
* @return {function} The internal class constructor function.
|
|
65
47
|
*/
|
|
66
48
|
function createInternalComponent(element) {
|
|
67
|
-
!genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) :
|
|
49
|
+
!genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : _prodInvariant('111', element.type) : void 0;
|
|
68
50
|
return new genericComponentClass(element);
|
|
69
51
|
}
|
|
70
52
|
|
|
@@ -84,12 +66,11 @@ function isTextComponent(component) {
|
|
|
84
66
|
return component instanceof textComponentClass;
|
|
85
67
|
}
|
|
86
68
|
|
|
87
|
-
var
|
|
88
|
-
getComponentClassForElement: getComponentClassForElement,
|
|
69
|
+
var ReactHostComponent = {
|
|
89
70
|
createInternalComponent: createInternalComponent,
|
|
90
71
|
createInstanceForText: createInstanceForText,
|
|
91
72
|
isTextComponent: isTextComponent,
|
|
92
|
-
injection:
|
|
73
|
+
injection: ReactHostComponentInjection
|
|
93
74
|
};
|
|
94
75
|
|
|
95
|
-
module.exports =
|
|
76
|
+
module.exports = ReactHostComponent;
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule
|
|
9
|
+
* @providesModule ReactHostOperationHistoryDevtool
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var history = [];
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
|
|
16
|
+
var ReactHostOperationHistoryDevtool = {
|
|
17
|
+
onHostOperation: function (debugID, type, payload) {
|
|
18
18
|
history.push({
|
|
19
19
|
instanceID: debugID,
|
|
20
20
|
type: type,
|
|
@@ -22,6 +22,11 @@ var ReactNativeOperationHistoryDevtool = {
|
|
|
22
22
|
});
|
|
23
23
|
},
|
|
24
24
|
clearHistory: function () {
|
|
25
|
+
if (ReactHostOperationHistoryDevtool._preventClearing) {
|
|
26
|
+
// Should only be used for tests.
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
history = [];
|
|
26
31
|
},
|
|
27
32
|
getHistory: function () {
|
|
@@ -29,4 +34,4 @@ var ReactNativeOperationHistoryDevtool = {
|
|
|
29
34
|
}
|
|
30
35
|
};
|
|
31
36
|
|
|
32
|
-
module.exports =
|
|
37
|
+
module.exports = ReactHostOperationHistoryDevtool;
|
package/lib/ReactInjection.js
CHANGED
|
@@ -18,7 +18,7 @@ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
|
18
18
|
var ReactClass = require('./ReactClass');
|
|
19
19
|
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
20
20
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
21
|
-
var
|
|
21
|
+
var ReactHostComponent = require('./ReactHostComponent');
|
|
22
22
|
var ReactUpdates = require('./ReactUpdates');
|
|
23
23
|
|
|
24
24
|
var ReactInjection = {
|
|
@@ -29,7 +29,7 @@ var ReactInjection = {
|
|
|
29
29
|
EventPluginHub: EventPluginHub.injection,
|
|
30
30
|
EventPluginUtils: EventPluginUtils.injection,
|
|
31
31
|
EventEmitter: ReactBrowserEventEmitter.injection,
|
|
32
|
-
|
|
32
|
+
HostComponent: ReactHostComponent.injection,
|
|
33
33
|
Updates: ReactUpdates.injection
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var invariant = require('fbjs/lib/invariant');
|
|
15
17
|
|
|
16
18
|
var SEPARATOR = '.';
|
|
@@ -88,8 +90,8 @@ function getParentID(id) {
|
|
|
88
90
|
* @private
|
|
89
91
|
*/
|
|
90
92
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
91
|
-
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) :
|
|
92
|
-
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about
|
|
93
|
+
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : _prodInvariant('112', ancestorID, destinationID) : void 0;
|
|
94
|
+
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : _prodInvariant('113', ancestorID, destinationID) : void 0;
|
|
93
95
|
if (ancestorID === destinationID) {
|
|
94
96
|
return ancestorID;
|
|
95
97
|
}
|
|
@@ -131,7 +133,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
134
|
-
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) :
|
|
136
|
+
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : _prodInvariant('114', oneID, twoID, longestCommonID) : void 0;
|
|
135
137
|
return longestCommonID;
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -151,9 +153,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
151
153
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
152
154
|
start = start || '';
|
|
153
155
|
stop = stop || '';
|
|
154
|
-
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) :
|
|
156
|
+
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : _prodInvariant('115', start) : void 0;
|
|
155
157
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
156
|
-
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do
|
|
158
|
+
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do not have a parent path.', start, stop) : _prodInvariant('116', start, stop) : void 0;
|
|
157
159
|
// Traverse from `start` to `stop` one depth at a time.
|
|
158
160
|
var depth = 0;
|
|
159
161
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
@@ -166,7 +168,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
166
168
|
// Only break //after// visiting `stop`.
|
|
167
169
|
break;
|
|
168
170
|
}
|
|
169
|
-
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while
|
|
171
|
+
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : _prodInvariant('117', start, stop, id) : void 0;
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
|