react 0.14.10 → 15.0.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/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -13,25 +13,23 @@
|
|
|
13
13
|
|
|
14
14
|
var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
|
|
15
15
|
var ChangeEventPlugin = require('./ChangeEventPlugin');
|
|
16
|
-
var ClientReactRootIndex = require('./ClientReactRootIndex');
|
|
17
16
|
var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
|
|
18
17
|
var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
|
|
19
18
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
20
19
|
var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
|
|
21
|
-
var ReactBrowserComponentMixin = require('./ReactBrowserComponentMixin');
|
|
22
20
|
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
23
|
-
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
24
21
|
var ReactDOMComponent = require('./ReactDOMComponent');
|
|
22
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
23
|
+
var ReactDOMEmptyComponent = require('./ReactDOMEmptyComponent');
|
|
24
|
+
var ReactDOMTreeTraversal = require('./ReactDOMTreeTraversal');
|
|
25
25
|
var ReactDOMTextComponent = require('./ReactDOMTextComponent');
|
|
26
|
+
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
26
27
|
var ReactEventListener = require('./ReactEventListener');
|
|
27
28
|
var ReactInjection = require('./ReactInjection');
|
|
28
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
29
|
-
var ReactMount = require('./ReactMount');
|
|
30
29
|
var ReactReconcileTransaction = require('./ReactReconcileTransaction');
|
|
30
|
+
var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
|
|
31
31
|
var SelectEventPlugin = require('./SelectEventPlugin');
|
|
32
|
-
var ServerReactRootIndex = require('./ServerReactRootIndex');
|
|
33
32
|
var SimpleEventPlugin = require('./SimpleEventPlugin');
|
|
34
|
-
var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
|
|
35
33
|
|
|
36
34
|
var alreadyInjected = false;
|
|
37
35
|
|
|
@@ -50,8 +48,8 @@ function inject() {
|
|
|
50
48
|
* Inject modules for resolving DOM hierarchy and plugin ordering.
|
|
51
49
|
*/
|
|
52
50
|
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
|
|
53
|
-
ReactInjection.
|
|
54
|
-
ReactInjection.
|
|
51
|
+
ReactInjection.EventPluginUtils.injectComponentTree(ReactDOMComponentTree);
|
|
52
|
+
ReactInjection.EventPluginUtils.injectTreeTraversal(ReactDOMTreeTraversal);
|
|
55
53
|
|
|
56
54
|
/**
|
|
57
55
|
* Some important event plugins included by default (without having to require
|
|
@@ -69,18 +67,16 @@ function inject() {
|
|
|
69
67
|
|
|
70
68
|
ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent);
|
|
71
69
|
|
|
72
|
-
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
|
|
73
|
-
|
|
74
70
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
|
75
71
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
|
76
72
|
|
|
77
|
-
ReactInjection.EmptyComponent.
|
|
73
|
+
ReactInjection.EmptyComponent.injectEmptyComponentFactory(function (instantiate) {
|
|
74
|
+
return new ReactDOMEmptyComponent(instantiate);
|
|
75
|
+
});
|
|
78
76
|
|
|
79
77
|
ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
|
|
80
78
|
ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
81
79
|
|
|
82
|
-
ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
|
|
83
|
-
|
|
84
80
|
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
|
85
81
|
|
|
86
82
|
if (process.env.NODE_ENV !== 'production') {
|
package/lib/ReactDefaultPerf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactDefaultPerf
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
14
|
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
16
16
|
var ReactDefaultPerfAnalysis = require('./ReactDefaultPerfAnalysis');
|
|
17
17
|
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,9 +28,59 @@ function addValue(obj, key, val) {
|
|
|
27
28
|
obj[key] = (obj[key] || 0) + val;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
// Composite/text components don't have any built-in ID: we have to make our own
|
|
32
|
+
var compositeIDMap;
|
|
33
|
+
var compositeIDCounter = 17000;
|
|
34
|
+
function getIDOfComposite(inst) {
|
|
35
|
+
if (!compositeIDMap) {
|
|
36
|
+
compositeIDMap = new WeakMap();
|
|
37
|
+
}
|
|
38
|
+
if (compositeIDMap.has(inst)) {
|
|
39
|
+
return compositeIDMap.get(inst);
|
|
40
|
+
} else {
|
|
41
|
+
var id = compositeIDCounter++;
|
|
42
|
+
compositeIDMap.set(inst, id);
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
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
|
+
|
|
30
80
|
var ReactDefaultPerf = {
|
|
31
81
|
_allMeasurements: [], // last item in the list is the current one
|
|
32
82
|
_mountStack: [0],
|
|
83
|
+
_compositeStack: [],
|
|
33
84
|
_injected: false,
|
|
34
85
|
|
|
35
86
|
start: function () {
|
|
@@ -46,11 +97,11 @@ var ReactDefaultPerf = {
|
|
|
46
97
|
},
|
|
47
98
|
|
|
48
99
|
getLastMeasurements: function () {
|
|
49
|
-
return ReactDefaultPerf._allMeasurements;
|
|
100
|
+
return wrapLegacyMeasurements(ReactDefaultPerf._allMeasurements);
|
|
50
101
|
},
|
|
51
102
|
|
|
52
103
|
printExclusive: function (measurements) {
|
|
53
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
104
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
54
105
|
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
|
|
55
106
|
console.table(summary.map(function (item) {
|
|
56
107
|
return {
|
|
@@ -68,7 +119,7 @@ var ReactDefaultPerf = {
|
|
|
68
119
|
},
|
|
69
120
|
|
|
70
121
|
printInclusive: function (measurements) {
|
|
71
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
122
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
72
123
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
|
|
73
124
|
console.table(summary.map(function (item) {
|
|
74
125
|
return {
|
|
@@ -81,6 +132,13 @@ var ReactDefaultPerf = {
|
|
|
81
132
|
},
|
|
82
133
|
|
|
83
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);
|
|
84
142
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true);
|
|
85
143
|
return summary.map(function (item) {
|
|
86
144
|
return {
|
|
@@ -92,19 +150,25 @@ var ReactDefaultPerf = {
|
|
|
92
150
|
},
|
|
93
151
|
|
|
94
152
|
printWasted: function (measurements) {
|
|
95
|
-
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
96
|
-
console.table(ReactDefaultPerf.
|
|
153
|
+
measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
|
|
154
|
+
console.table(ReactDefaultPerf.getWasted(measurements));
|
|
97
155
|
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
|
|
98
156
|
},
|
|
99
157
|
|
|
100
158
|
printDOM: function (measurements) {
|
|
101
|
-
|
|
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);
|
|
102
166
|
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
|
|
103
167
|
console.table(summary.map(function (item) {
|
|
104
168
|
var result = {};
|
|
105
169
|
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
|
|
106
170
|
result.type = item.type;
|
|
107
|
-
result.args = JSON.stringify(item.args);
|
|
171
|
+
result.args = JSON.stringify(item.args, stripComplexValues);
|
|
108
172
|
return result;
|
|
109
173
|
}));
|
|
110
174
|
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
|
|
@@ -112,7 +176,8 @@ var ReactDefaultPerf = {
|
|
|
112
176
|
|
|
113
177
|
_recordWrite: function (id, fnName, totalTime, args) {
|
|
114
178
|
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
|
|
115
|
-
var
|
|
179
|
+
var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
|
|
180
|
+
var writes = entry.writes;
|
|
116
181
|
writes[id] = writes[id] || [];
|
|
117
182
|
writes[id].push({
|
|
118
183
|
type: fnName,
|
|
@@ -131,36 +196,38 @@ var ReactDefaultPerf = {
|
|
|
131
196
|
var rv;
|
|
132
197
|
var start;
|
|
133
198
|
|
|
199
|
+
var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
|
|
200
|
+
|
|
134
201
|
if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') {
|
|
135
202
|
// A "measurement" is a set of metrics recorded for each flush. We want
|
|
136
203
|
// to group the metrics for a given flush together so we can look at the
|
|
137
204
|
// components that rendered and the DOM operations that actually
|
|
138
205
|
// happened to determine the amount of "wasted work" performed.
|
|
139
|
-
ReactDefaultPerf._allMeasurements.push({
|
|
206
|
+
ReactDefaultPerf._allMeasurements.push(entry = {
|
|
140
207
|
exclusive: {},
|
|
141
208
|
inclusive: {},
|
|
142
209
|
render: {},
|
|
143
210
|
counts: {},
|
|
144
211
|
writes: {},
|
|
145
212
|
displayNames: {},
|
|
213
|
+
hierarchy: {},
|
|
146
214
|
totalTime: 0,
|
|
147
215
|
created: {}
|
|
148
216
|
});
|
|
149
217
|
start = performanceNow();
|
|
150
218
|
rv = func.apply(this, args);
|
|
151
|
-
|
|
219
|
+
entry.totalTime = performanceNow() - start;
|
|
152
220
|
return rv;
|
|
153
|
-
} else if (fnName === '_mountImageIntoNode' || moduleName === '
|
|
221
|
+
} else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations' || moduleName === 'ReactComponentBrowserEnvironment') {
|
|
154
222
|
start = performanceNow();
|
|
155
223
|
rv = func.apply(this, args);
|
|
156
224
|
totalTime = performanceNow() - start;
|
|
157
225
|
|
|
158
226
|
if (fnName === '_mountImageIntoNode') {
|
|
159
|
-
|
|
160
|
-
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
|
|
227
|
+
ReactDefaultPerf._recordWrite('', fnName, totalTime, args[0]);
|
|
161
228
|
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
|
|
162
229
|
// special format
|
|
163
|
-
args[
|
|
230
|
+
args[1].forEach(function (update) {
|
|
164
231
|
var writeArgs = {};
|
|
165
232
|
if (update.fromIndex !== null) {
|
|
166
233
|
writeArgs.fromIndex = update.fromIndex;
|
|
@@ -168,19 +235,23 @@ var ReactDefaultPerf = {
|
|
|
168
235
|
if (update.toIndex !== null) {
|
|
169
236
|
writeArgs.toIndex = update.toIndex;
|
|
170
237
|
}
|
|
171
|
-
if (update.
|
|
172
|
-
writeArgs.
|
|
238
|
+
if (update.content !== null) {
|
|
239
|
+
writeArgs.content = update.content;
|
|
173
240
|
}
|
|
174
|
-
|
|
175
|
-
writeArgs.markup = args[1][update.markupIndex];
|
|
176
|
-
}
|
|
177
|
-
ReactDefaultPerf._recordWrite(update.parentID, update.type, totalTime, writeArgs);
|
|
241
|
+
ReactDefaultPerf._recordWrite(args[0]._rootNodeID, update.type, totalTime, writeArgs);
|
|
178
242
|
});
|
|
179
243
|
} else {
|
|
180
244
|
// basic format
|
|
181
245
|
var id = args[0];
|
|
182
|
-
if (
|
|
183
|
-
id =
|
|
246
|
+
if (moduleName === 'EventPluginHub') {
|
|
247
|
+
id = id._rootNodeID;
|
|
248
|
+
} else if (fnName === 'replaceNodeWithMarkup') {
|
|
249
|
+
// Old node is already unmounted; can't get its instance
|
|
250
|
+
id = ReactDOMComponentTree.getInstanceFromNode(args[1].node)._rootNodeID;
|
|
251
|
+
} else if (fnName === 'replaceDelimitedText') {
|
|
252
|
+
id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
|
|
253
|
+
} else if (typeof id === 'object') {
|
|
254
|
+
id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
|
|
184
255
|
}
|
|
185
256
|
ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
|
|
186
257
|
}
|
|
@@ -192,12 +263,11 @@ var ReactDefaultPerf = {
|
|
|
192
263
|
return func.apply(this, args);
|
|
193
264
|
}
|
|
194
265
|
|
|
195
|
-
var rootNodeID =
|
|
266
|
+
var rootNodeID = getIDOfComposite(this);
|
|
196
267
|
var isRender = fnName === '_renderValidatedComponent';
|
|
197
268
|
var isMount = fnName === 'mountComponent';
|
|
198
269
|
|
|
199
270
|
var mountStack = ReactDefaultPerf._mountStack;
|
|
200
|
-
var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
|
|
201
271
|
|
|
202
272
|
if (isRender) {
|
|
203
273
|
addValue(entry.counts, rootNodeID, 1);
|
|
@@ -206,10 +276,14 @@ var ReactDefaultPerf = {
|
|
|
206
276
|
mountStack.push(0);
|
|
207
277
|
}
|
|
208
278
|
|
|
279
|
+
ReactDefaultPerf._compositeStack.push(rootNodeID);
|
|
280
|
+
|
|
209
281
|
start = performanceNow();
|
|
210
282
|
rv = func.apply(this, args);
|
|
211
283
|
totalTime = performanceNow() - start;
|
|
212
284
|
|
|
285
|
+
ReactDefaultPerf._compositeStack.pop();
|
|
286
|
+
|
|
213
287
|
if (isRender) {
|
|
214
288
|
addValue(entry.render, rootNodeID, totalTime);
|
|
215
289
|
} else if (isMount) {
|
|
@@ -226,6 +300,11 @@ var ReactDefaultPerf = {
|
|
|
226
300
|
owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>'
|
|
227
301
|
};
|
|
228
302
|
|
|
303
|
+
return rv;
|
|
304
|
+
} else if ((moduleName === 'ReactDOMComponent' || moduleName === 'ReactDOMTextComponent') && (fnName === 'mountComponent' || fnName === 'receiveComponent')) {
|
|
305
|
+
|
|
306
|
+
rv = func.apply(this, args);
|
|
307
|
+
entry.hierarchy[getID(this)] = ReactDefaultPerf._compositeStack.slice();
|
|
229
308
|
return rv;
|
|
230
309
|
} else {
|
|
231
310
|
return func.apply(this, args);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var assign = require('./Object.assign');
|
|
15
|
-
|
|
16
14
|
// Don't try to save users less than 1.2ms (a number I made up)
|
|
15
|
+
|
|
16
|
+
var _assign = require('object-assign');
|
|
17
|
+
|
|
17
18
|
var DONT_CARE_THRESHOLD = 1.2;
|
|
18
19
|
var DOM_OPERATION_TYPES = {
|
|
19
20
|
'_mountImageIntoNode': 'set innerHTML',
|
|
@@ -27,7 +28,7 @@ var DOM_OPERATION_TYPES = {
|
|
|
27
28
|
'deleteValueForProperty': 'remove attribute',
|
|
28
29
|
'setValueForStyles': 'update styles',
|
|
29
30
|
'replaceNodeWithMarkup': 'replace',
|
|
30
|
-
'
|
|
31
|
+
'replaceDelimitedText': 'replace'
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
function getTotalTime(measurements) {
|
|
@@ -65,7 +66,7 @@ function getExclusiveSummary(measurements) {
|
|
|
65
66
|
|
|
66
67
|
for (var i = 0; i < measurements.length; i++) {
|
|
67
68
|
var measurement = measurements[i];
|
|
68
|
-
var allIDs =
|
|
69
|
+
var allIDs = _assign({}, measurement.exclusive, measurement.inclusive);
|
|
69
70
|
|
|
70
71
|
for (var id in allIDs) {
|
|
71
72
|
displayName = measurement.displayNames[id].current;
|
|
@@ -113,7 +114,7 @@ function getInclusiveSummary(measurements, onlyClean) {
|
|
|
113
114
|
|
|
114
115
|
for (var i = 0; i < measurements.length; i++) {
|
|
115
116
|
var measurement = measurements[i];
|
|
116
|
-
var allIDs =
|
|
117
|
+
var allIDs = _assign({}, measurement.exclusive, measurement.inclusive);
|
|
117
118
|
var cleanComponents;
|
|
118
119
|
|
|
119
120
|
if (onlyClean) {
|
|
@@ -167,18 +168,25 @@ function getUnchangedComponents(measurement) {
|
|
|
167
168
|
// render anything to the DOM and return a mapping of their ID to
|
|
168
169
|
// the amount of time it took to render the entire subtree.
|
|
169
170
|
var cleanComponents = {};
|
|
170
|
-
var
|
|
171
|
-
var
|
|
171
|
+
var writes = measurement.writes;
|
|
172
|
+
var dirtyComposites = {};
|
|
173
|
+
Object.keys(writes).forEach(function (id) {
|
|
174
|
+
writes[id].forEach(function (write) {
|
|
175
|
+
// Root mounting (innerHTML set) is recorded with an ID of ''
|
|
176
|
+
if (id !== '') {
|
|
177
|
+
measurement.hierarchy[id].forEach(function (c) {
|
|
178
|
+
return dirtyComposites[c] = true;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
var allIDs = _assign({}, measurement.exclusive, measurement.inclusive);
|
|
172
184
|
|
|
173
185
|
for (var id in allIDs) {
|
|
174
186
|
var isDirty = false;
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (dirtyLeafIDs[i].indexOf(id) === 0) {
|
|
179
|
-
isDirty = true;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
187
|
+
// See if any of the DOM operations applied to this component's subtree.
|
|
188
|
+
if (dirtyComposites[id]) {
|
|
189
|
+
isDirty = true;
|
|
182
190
|
}
|
|
183
191
|
// check if component newly created
|
|
184
192
|
if (measurement.created[id]) {
|