react 0.15.0-alpha.1 → 15.0.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/react-with-addons.js +2579 -1792
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2457 -1651
- package/dist/react.min.js +6 -6
- package/lib/CSSProperty.js +7 -0
- package/lib/CSSPropertyOperations.js +32 -16
- package/lib/CallbackQueue.js +4 -3
- package/lib/DOMChildrenOperations.js +75 -6
- package/lib/DOMLazyTree.js +14 -4
- package/lib/DOMProperty.js +11 -37
- package/lib/DOMPropertyOperations.js +21 -63
- package/lib/Danger.js +8 -8
- package/lib/EventConstants.js +4 -0
- package/lib/EventPluginHub.js +7 -7
- package/lib/EventPluginRegistry.js +7 -7
- package/lib/EventPluginUtils.js +5 -5
- package/lib/EventPropagators.js +1 -1
- package/lib/FallbackCompositionState.js +3 -2
- package/lib/HTMLDOMPropertyConfig.js +129 -148
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/OrderedMap.js +16 -15
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +68 -9
- package/lib/ReactBrowserEventEmitter.js +16 -3
- package/lib/ReactCSSTransitionGroup.js +3 -3
- package/lib/ReactChildReconciler.js +5 -5
- package/lib/ReactChildren.js +2 -1
- package/lib/ReactClass.js +27 -26
- package/lib/ReactComponent.js +7 -5
- package/lib/ReactComponentEnvironment.js +1 -1
- package/lib/ReactCompositeComponent.js +74 -47
- package/lib/ReactCurrentOwner.js +1 -0
- package/lib/ReactDOM.js +3 -3
- package/lib/ReactDOMComponent.js +44 -39
- package/lib/ReactDOMComponentTree.js +4 -4
- package/lib/ReactDOMDebugTool.js +1 -9
- package/lib/ReactDOMEmptyComponent.js +3 -4
- package/lib/ReactDOMInput.js +29 -8
- package/lib/ReactDOMOption.js +15 -4
- package/lib/ReactDOMSelect.js +11 -8
- package/lib/ReactDOMSelection.js +2 -2
- package/lib/ReactDOMTextComponent.js +59 -37
- package/lib/ReactDOMTextarea.js +10 -9
- package/lib/ReactDOMTreeTraversal.js +5 -5
- package/lib/ReactDOMUnknownPropertyDevtool.js +2 -2
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +3 -2
- package/lib/ReactDefaultPerf.js +59 -10
- package/lib/ReactDefaultPerfAnalysis.js +7 -6
- package/lib/ReactElement.js +54 -18
- package/lib/ReactElementValidator.js +7 -7
- package/lib/ReactEventListener.js +3 -2
- package/lib/ReactFragment.js +4 -4
- package/lib/ReactInputSelection.js +1 -1
- package/lib/ReactInstanceHandles.js +6 -6
- package/lib/ReactInstanceMap.js +1 -0
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +7 -2
- package/lib/ReactMount.js +25 -19
- package/lib/ReactMultiChild.js +6 -6
- package/lib/ReactNativeComponent.js +5 -4
- package/lib/ReactNodeTypes.js +1 -1
- package/lib/ReactNoopUpdateQueue.js +1 -1
- package/lib/ReactOwner.js +6 -5
- package/lib/ReactPerf.js +1 -0
- package/lib/ReactPropTransferer.js +4 -3
- package/lib/ReactPropTypes.js +19 -1
- package/lib/ReactReconcileTransaction.js +3 -3
- package/lib/ReactReconciler.js +16 -2
- package/lib/ReactServerRendering.js +2 -2
- package/lib/ReactServerRenderingTransaction.js +3 -3
- package/lib/ReactSimpleEmptyComponent.js +3 -4
- package/lib/ReactTestUtils.js +23 -14
- package/lib/ReactTransitionEvents.js +7 -43
- package/lib/ReactTransitionGroup.js +3 -2
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +23 -65
- package/lib/ReactUpdates.js +10 -9
- package/lib/ReactVersion.js +1 -1
- package/lib/ReactWithAddons.js +0 -18
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/ResponderSyntheticEvent.js +1 -1
- package/lib/ResponderTouchHistoryStore.js +4 -4
- package/lib/SVGDOMPropertyConfig.js +266 -56
- package/lib/SimpleEventPlugin.js +39 -1
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +93 -15
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +1 -1
- package/lib/SyntheticMouseEvent.js +1 -1
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/Transaction.js +2 -2
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +6 -3
- package/lib/findDOMNode.js +3 -3
- package/lib/flattenChildren.js +1 -1
- package/lib/forEachAccumulated.js +1 -0
- package/lib/getEventCharCode.js +1 -0
- package/lib/getEventTarget.js +7 -0
- package/lib/getIteratorFn.js +1 -0
- package/lib/getNodeForCharacterOffset.js +1 -0
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +10 -10
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +1 -0
- package/lib/onlyChild.js +1 -1
- package/lib/reactComponentExpect.js +4 -3
- package/lib/setInnerHTML.js +5 -13
- package/lib/shouldUpdateReactComponent.js +1 -0
- package/lib/traverseAllChildren.js +2 -2
- package/lib/update.js +15 -14
- package/lib/validateDOMNesting.js +10 -4
- package/package.json +6 -5
- package/addons.js +0 -13
- package/lib/LinkedInput.js +0 -49
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +0 -57
- package/lib/ReactIsomorphic.js +0 -74
package/lib/ReactDOMTextarea.js
CHANGED
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
15
17
|
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
16
18
|
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
17
19
|
var ReactUpdates = require('./ReactUpdates');
|
|
18
20
|
|
|
19
|
-
var assign = require('./Object.assign');
|
|
20
21
|
var invariant = require('fbjs/lib/invariant');
|
|
21
22
|
var warning = require('fbjs/lib/warning');
|
|
22
23
|
|
|
@@ -33,7 +34,7 @@ function forceUpdateIfMounted() {
|
|
|
33
34
|
|
|
34
35
|
function warnIfValueIsNull(props) {
|
|
35
36
|
if (props != null && props.value === null && !didWarnValueNull) {
|
|
36
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `textarea` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.') :
|
|
37
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `textarea` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.') : void 0;
|
|
37
38
|
|
|
38
39
|
didWarnValueNull = true;
|
|
39
40
|
}
|
|
@@ -56,11 +57,11 @@ function warnIfValueIsNull(props) {
|
|
|
56
57
|
*/
|
|
57
58
|
var ReactDOMTextarea = {
|
|
58
59
|
getNativeProps: function (inst, props) {
|
|
59
|
-
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) :
|
|
60
|
+
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : void 0;
|
|
60
61
|
|
|
61
62
|
// Always set children to the same thing. In IE9, the selection range will
|
|
62
63
|
// get reset if `textContent` is mutated.
|
|
63
|
-
var nativeProps =
|
|
64
|
+
var nativeProps = _assign({}, props, {
|
|
64
65
|
defaultValue: undefined,
|
|
65
66
|
value: undefined,
|
|
66
67
|
children: inst._wrapperState.initialValue,
|
|
@@ -74,11 +75,11 @@ var ReactDOMTextarea = {
|
|
|
74
75
|
if (process.env.NODE_ENV !== 'production') {
|
|
75
76
|
LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
|
|
76
77
|
if (props.valueLink !== undefined && !didWarnValueLink) {
|
|
77
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.') :
|
|
78
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.') : void 0;
|
|
78
79
|
didWarnValueLink = true;
|
|
79
80
|
}
|
|
80
81
|
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
|
|
81
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') :
|
|
82
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
|
|
82
83
|
didWarnValDefaultVal = true;
|
|
83
84
|
}
|
|
84
85
|
warnIfValueIsNull(props);
|
|
@@ -89,11 +90,11 @@ var ReactDOMTextarea = {
|
|
|
89
90
|
var children = props.children;
|
|
90
91
|
if (children != null) {
|
|
91
92
|
if (process.env.NODE_ENV !== 'production') {
|
|
92
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') :
|
|
93
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : void 0;
|
|
93
94
|
}
|
|
94
|
-
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) :
|
|
95
|
+
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : void 0;
|
|
95
96
|
if (Array.isArray(children)) {
|
|
96
|
-
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) :
|
|
97
|
+
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : void 0;
|
|
97
98
|
children = children[0];
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -18,8 +18,8 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
18
18
|
* different trees.
|
|
19
19
|
*/
|
|
20
20
|
function getLowestCommonAncestor(instA, instB) {
|
|
21
|
-
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) :
|
|
22
|
-
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) :
|
|
21
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
22
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
23
23
|
|
|
24
24
|
var depthA = 0;
|
|
25
25
|
for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
|
|
@@ -58,8 +58,8 @@ function getLowestCommonAncestor(instA, instB) {
|
|
|
58
58
|
* Return if A is an ancestor of B.
|
|
59
59
|
*/
|
|
60
60
|
function isAncestor(instA, instB) {
|
|
61
|
-
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) :
|
|
62
|
-
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) :
|
|
61
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
62
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
63
63
|
|
|
64
64
|
while (instB) {
|
|
65
65
|
if (instB === instA) {
|
|
@@ -74,7 +74,7 @@ function isAncestor(instA, instB) {
|
|
|
74
74
|
* Return the parent instance of the passed-in instance.
|
|
75
75
|
*/
|
|
76
76
|
function getParentInstance(inst) {
|
|
77
|
-
!('_nativeNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : invariant(false) :
|
|
77
|
+
!('_nativeNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : invariant(false) : void 0;
|
|
78
78
|
|
|
79
79
|
return inst._nativeParent;
|
|
80
80
|
}
|
|
@@ -41,11 +41,11 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
41
41
|
|
|
42
42
|
// For now, only warn when we have a suggested correction. This prevents
|
|
43
43
|
// logging too much when using transferPropsTo.
|
|
44
|
-
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) :
|
|
44
|
+
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : void 0;
|
|
45
45
|
|
|
46
46
|
var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry.possibleRegistrationNames[lowerCasedName] : null;
|
|
47
47
|
|
|
48
|
-
process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?', name, registrationName) :
|
|
48
|
+
process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?', name, registrationName) : void 0;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016-present, 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 ReactDebugInstanceMap
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var warning = require('fbjs/lib/warning');
|
|
15
|
+
|
|
16
|
+
function checkValidInstance(internalInstance) {
|
|
17
|
+
if (!internalInstance) {
|
|
18
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received %s. ' + 'Please report this as a bug in React.', internalInstance) : void 0;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var isValid = typeof internalInstance.mountComponent === 'function';
|
|
22
|
+
process.env.NODE_ENV !== 'production' ? warning(isValid, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received an object with the following ' + 'keys: %s. Please report this as a bug in React.', Object.keys(internalInstance).join(', ')) : void 0;
|
|
23
|
+
return isValid;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var idCounter = 1;
|
|
27
|
+
var instancesByIDs = {};
|
|
28
|
+
var instancesToIDs;
|
|
29
|
+
|
|
30
|
+
function getIDForInstance(internalInstance) {
|
|
31
|
+
if (!instancesToIDs) {
|
|
32
|
+
instancesToIDs = new WeakMap();
|
|
33
|
+
}
|
|
34
|
+
if (instancesToIDs.has(internalInstance)) {
|
|
35
|
+
return instancesToIDs.get(internalInstance);
|
|
36
|
+
} else {
|
|
37
|
+
var instanceID = (idCounter++).toString();
|
|
38
|
+
instancesToIDs.set(internalInstance, instanceID);
|
|
39
|
+
return instanceID;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getInstanceByID(instanceID) {
|
|
44
|
+
return instancesByIDs[instanceID] || null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isRegisteredInstance(internalInstance) {
|
|
48
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
49
|
+
if (instanceID) {
|
|
50
|
+
return instancesByIDs.hasOwnProperty(instanceID);
|
|
51
|
+
} else {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function registerInstance(internalInstance) {
|
|
57
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
58
|
+
if (instanceID) {
|
|
59
|
+
instancesByIDs[instanceID] = internalInstance;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function unregisterInstance(internalInstance) {
|
|
64
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
65
|
+
if (instanceID) {
|
|
66
|
+
delete instancesByIDs[instanceID];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var ReactDebugInstanceMap = {
|
|
71
|
+
getIDForInstance: function (internalInstance) {
|
|
72
|
+
if (!checkValidInstance(internalInstance)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return getIDForInstance(internalInstance);
|
|
76
|
+
},
|
|
77
|
+
getInstanceByID: function (instanceID) {
|
|
78
|
+
return getInstanceByID(instanceID);
|
|
79
|
+
},
|
|
80
|
+
isRegisteredInstance: function (internalInstance) {
|
|
81
|
+
if (!checkValidInstance(internalInstance)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return isRegisteredInstance(internalInstance);
|
|
85
|
+
},
|
|
86
|
+
registerInstance: function (internalInstance) {
|
|
87
|
+
if (!checkValidInstance(internalInstance)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
process.env.NODE_ENV !== 'production' ? warning(!isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'A registered instance should not be registered again. ' + 'Please report this as a bug in React.') : void 0;
|
|
91
|
+
registerInstance(internalInstance);
|
|
92
|
+
},
|
|
93
|
+
unregisterInstance: function (internalInstance) {
|
|
94
|
+
if (!checkValidInstance(internalInstance)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
process.env.NODE_ENV !== 'production' ? warning(isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'An unregistered instance should not be unregistered again. ' + 'Please report this as a bug in React.') : void 0;
|
|
98
|
+
unregisterInstance(internalInstance);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
module.exports = ReactDebugInstanceMap;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016-present, 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 ReactDebugTool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
|
|
15
|
+
var warning = require('fbjs/lib/warning');
|
|
16
|
+
|
|
17
|
+
var eventHandlers = [];
|
|
18
|
+
var handlerDoesThrowForEvent = {};
|
|
19
|
+
|
|
20
|
+
function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
21
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
+
eventHandlers.forEach(function (handler) {
|
|
23
|
+
try {
|
|
24
|
+
if (handler[handlerFunctionName]) {
|
|
25
|
+
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
process.env.NODE_ENV !== 'production' ? warning(!handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e.message) : void 0;
|
|
29
|
+
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var ReactDebugTool = {
|
|
36
|
+
addDevtool: function (devtool) {
|
|
37
|
+
eventHandlers.push(devtool);
|
|
38
|
+
},
|
|
39
|
+
removeDevtool: function (devtool) {
|
|
40
|
+
for (var i = 0; i < eventHandlers.length; i++) {
|
|
41
|
+
if (eventHandlers[i] === devtool) {
|
|
42
|
+
eventHandlers.splice(i, 1);
|
|
43
|
+
i--;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onBeginProcessingChildContext: function () {
|
|
48
|
+
emitEvent('onBeginProcessingChildContext');
|
|
49
|
+
},
|
|
50
|
+
onEndProcessingChildContext: function () {
|
|
51
|
+
emitEvent('onEndProcessingChildContext');
|
|
52
|
+
},
|
|
53
|
+
onSetState: function () {
|
|
54
|
+
emitEvent('onSetState');
|
|
55
|
+
},
|
|
56
|
+
onMountRootComponent: function (internalInstance) {
|
|
57
|
+
emitEvent('onMountRootComponent', internalInstance);
|
|
58
|
+
},
|
|
59
|
+
onMountComponent: function (internalInstance) {
|
|
60
|
+
emitEvent('onMountComponent', internalInstance);
|
|
61
|
+
},
|
|
62
|
+
onUpdateComponent: function (internalInstance) {
|
|
63
|
+
emitEvent('onUpdateComponent', internalInstance);
|
|
64
|
+
},
|
|
65
|
+
onUnmountComponent: function (internalInstance) {
|
|
66
|
+
emitEvent('onUnmountComponent', internalInstance);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
|
|
71
|
+
|
|
72
|
+
module.exports = ReactDebugTool;
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var ReactUpdates = require('./ReactUpdates');
|
|
15
17
|
var Transaction = require('./Transaction');
|
|
16
18
|
|
|
17
|
-
var assign = require('./Object.assign');
|
|
18
19
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
19
20
|
|
|
20
21
|
var RESET_BATCHED_UPDATES = {
|
|
@@ -35,7 +36,7 @@ function ReactDefaultBatchingStrategyTransaction() {
|
|
|
35
36
|
this.reinitializeTransaction();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
_assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction.Mixin, {
|
|
39
40
|
getTransactionWrappers: function () {
|
|
40
41
|
return TRANSACTION_WRAPPERS;
|
|
41
42
|
}
|
package/lib/ReactDefaultPerf.js
CHANGED
|
@@ -18,6 +18,7 @@ var ReactMount = require('./ReactMount');
|
|
|
18
18
|
var ReactPerf = require('./ReactPerf');
|
|
19
19
|
|
|
20
20
|
var performanceNow = require('fbjs/lib/performanceNow');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
21
22
|
|
|
22
23
|
function roundFloat(val) {
|
|
23
24
|
return Math.floor(val * 100) / 100;
|
|
@@ -27,7 +28,7 @@ function addValue(obj, key, val) {
|
|
|
27
28
|
obj[key] = (obj[key] || 0) + val;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
//
|
|
31
|
+
// Composite/text components don't have any built-in ID: we have to make our own
|
|
31
32
|
var compositeIDMap;
|
|
32
33
|
var compositeIDCounter = 17000;
|
|
33
34
|
function getIDOfComposite(inst) {
|
|
@@ -43,6 +44,39 @@ function getIDOfComposite(inst) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
function getID(inst) {
|
|
48
|
+
if (inst.hasOwnProperty('_rootNodeID')) {
|
|
49
|
+
return inst._rootNodeID;
|
|
50
|
+
} else {
|
|
51
|
+
return getIDOfComposite(inst);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function stripComplexValues(key, value) {
|
|
56
|
+
if (typeof value !== 'object' || Array.isArray(value) || value == null) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
var prototype = Object.getPrototypeOf(value);
|
|
60
|
+
if (!prototype || prototype === Object.prototype) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
return '<not serializable>';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// This implementation of ReactPerf is going away some time mid 15.x.
|
|
67
|
+
// While we plan to keep most of the API, the actual format of measurements
|
|
68
|
+
// will change dramatically. To signal this, we wrap them into an opaque-ish
|
|
69
|
+
// object to discourage reaching into it until the API stabilizes.
|
|
70
|
+
function wrapLegacyMeasurements(measurements) {
|
|
71
|
+
return { __unstable_this_format_will_change: measurements };
|
|
72
|
+
}
|
|
73
|
+
function unwrapLegacyMeasurements(measurements) {
|
|
74
|
+
return measurements && measurements.__unstable_this_format_will_change || measurements;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var warnedAboutPrintDOM = false;
|
|
78
|
+
var warnedAboutGetMeasurementsSummaryMap = false;
|
|
79
|
+
|
|
46
80
|
var ReactDefaultPerf = {
|
|
47
81
|
_allMeasurements: [], // last item in the list is the current one
|
|
48
82
|
_mountStack: [0],
|
|
@@ -63,11 +97,11 @@ var ReactDefaultPerf = {
|
|
|
63
97
|
},
|
|
64
98
|
|
|
65
99
|
getLastMeasurements: function () {
|
|
66
|
-
return ReactDefaultPerf._allMeasurements;
|
|
100
|
+
return wrapLegacyMeasurements(ReactDefaultPerf._allMeasurements);
|
|
67
101
|
},
|
|
68
102
|
|
|
69
103
|
printExclusive: function (measurements) {
|
|
70
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
104
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
71
105
|
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
|
|
72
106
|
console.table(summary.map(function (item) {
|
|
73
107
|
return {
|
|
@@ -85,7 +119,7 @@ var ReactDefaultPerf = {
|
|
|
85
119
|
},
|
|
86
120
|
|
|
87
121
|
printInclusive: function (measurements) {
|
|
88
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
122
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
89
123
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
|
|
90
124
|
console.table(summary.map(function (item) {
|
|
91
125
|
return {
|
|
@@ -98,6 +132,13 @@ var ReactDefaultPerf = {
|
|
|
98
132
|
},
|
|
99
133
|
|
|
100
134
|
getMeasurementsSummaryMap: function (measurements) {
|
|
135
|
+
process.env.NODE_ENV !== 'production' ? warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.') : void 0;
|
|
136
|
+
warnedAboutGetMeasurementsSummaryMap = true;
|
|
137
|
+
return ReactDefaultPerf.getWasted(measurements);
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
getWasted: function (measurements) {
|
|
141
|
+
measurements = unwrapLegacyMeasurements(measurements);
|
|
101
142
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true);
|
|
102
143
|
return summary.map(function (item) {
|
|
103
144
|
return {
|
|
@@ -109,19 +150,25 @@ var ReactDefaultPerf = {
|
|
|
109
150
|
},
|
|
110
151
|
|
|
111
152
|
printWasted: function (measurements) {
|
|
112
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
113
|
-
console.table(ReactDefaultPerf.
|
|
153
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
154
|
+
console.table(ReactDefaultPerf.getWasted(measurements));
|
|
114
155
|
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
|
|
115
156
|
},
|
|
116
157
|
|
|
117
158
|
printDOM: function (measurements) {
|
|
118
|
-
|
|
159
|
+
process.env.NODE_ENV !== 'production' ? warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.') : void 0;
|
|
160
|
+
warnedAboutPrintDOM = true;
|
|
161
|
+
return ReactDefaultPerf.printOperations(measurements);
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
printOperations: function (measurements) {
|
|
165
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
119
166
|
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
|
|
120
167
|
console.table(summary.map(function (item) {
|
|
121
168
|
var result = {};
|
|
122
169
|
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
|
|
123
170
|
result.type = item.type;
|
|
124
|
-
result.args = JSON.stringify(item.args);
|
|
171
|
+
result.args = JSON.stringify(item.args, stripComplexValues);
|
|
125
172
|
return result;
|
|
126
173
|
}));
|
|
127
174
|
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
|
|
@@ -201,8 +248,10 @@ var ReactDefaultPerf = {
|
|
|
201
248
|
} else if (fnName === 'replaceNodeWithMarkup') {
|
|
202
249
|
// Old node is already unmounted; can't get its instance
|
|
203
250
|
id = ReactDOMComponentTree.getInstanceFromNode(args[1].node)._rootNodeID;
|
|
251
|
+
} else if (fnName === 'replaceDelimitedText') {
|
|
252
|
+
id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
|
|
204
253
|
} else if (typeof id === 'object') {
|
|
205
|
-
id = ReactDOMComponentTree.getInstanceFromNode(args[0])
|
|
254
|
+
id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
|
|
206
255
|
}
|
|
207
256
|
ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
|
|
208
257
|
}
|
|
@@ -255,7 +304,7 @@ var ReactDefaultPerf = {
|
|
|
255
304
|
} else if ((moduleName === 'ReactDOMComponent' || moduleName === 'ReactDOMTextComponent') && (fnName === 'mountComponent' || fnName === 'receiveComponent')) {
|
|
256
305
|
|
|
257
306
|
rv = func.apply(this, args);
|
|
258
|
-
entry.hierarchy[this
|
|
307
|
+
entry.hierarchy[getID(this)] = ReactDefaultPerf._compositeStack.slice();
|
|
259
308
|
return rv;
|
|
260
309
|
} else {
|
|
261
310
|
return func.apply(this, args);
|