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
package/lib/ReactMultiChild.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,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactMultiChild
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -20,156 +19,119 @@ var ReactReconciler = require('./ReactReconciler');
|
|
|
20
19
|
var ReactChildReconciler = require('./ReactChildReconciler');
|
|
21
20
|
|
|
22
21
|
var flattenChildren = require('./flattenChildren');
|
|
22
|
+
var invariant = require('fbjs/lib/invariant');
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* used to batch recursive updates to render markup more efficiently.
|
|
25
|
+
* Make an update for markup to be rendered and inserted at a supplied index.
|
|
27
26
|
*
|
|
28
|
-
* @type {number}
|
|
29
|
-
* @private
|
|
30
|
-
*/
|
|
31
|
-
var updateDepth = 0;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Queue of update configuration objects.
|
|
35
|
-
*
|
|
36
|
-
* Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
|
|
37
|
-
*
|
|
38
|
-
* @type {array<object>}
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
var updateQueue = [];
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Queue of markup to be rendered.
|
|
45
|
-
*
|
|
46
|
-
* @type {array<string>}
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
var markupQueue = [];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Enqueues markup to be rendered and inserted at a supplied index.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} parentID ID of the parent component.
|
|
55
27
|
* @param {string} markup Markup that renders into an element.
|
|
56
28
|
* @param {number} toIndex Destination index.
|
|
57
29
|
* @private
|
|
58
30
|
*/
|
|
59
|
-
function
|
|
31
|
+
function makeInsertMarkup(markup, afterNode, toIndex) {
|
|
60
32
|
// NOTE: Null values reduce hidden classes.
|
|
61
|
-
|
|
62
|
-
parentID: parentID,
|
|
63
|
-
parentNode: null,
|
|
33
|
+
return {
|
|
64
34
|
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
|
|
65
|
-
|
|
66
|
-
content: null,
|
|
35
|
+
content: markup,
|
|
67
36
|
fromIndex: null,
|
|
68
|
-
|
|
69
|
-
|
|
37
|
+
fromNode: null,
|
|
38
|
+
toIndex: toIndex,
|
|
39
|
+
afterNode: afterNode
|
|
40
|
+
};
|
|
70
41
|
}
|
|
71
42
|
|
|
72
43
|
/**
|
|
73
|
-
*
|
|
44
|
+
* Make an update for moving an existing element to another index.
|
|
74
45
|
*
|
|
75
|
-
* @param {string} parentID ID of the parent component.
|
|
76
46
|
* @param {number} fromIndex Source index of the existing element.
|
|
77
47
|
* @param {number} toIndex Destination index of the element.
|
|
78
48
|
* @private
|
|
79
49
|
*/
|
|
80
|
-
function
|
|
50
|
+
function makeMove(child, afterNode, toIndex) {
|
|
81
51
|
// NOTE: Null values reduce hidden classes.
|
|
82
|
-
|
|
83
|
-
parentID: parentID,
|
|
84
|
-
parentNode: null,
|
|
52
|
+
return {
|
|
85
53
|
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
|
|
86
|
-
markupIndex: null,
|
|
87
54
|
content: null,
|
|
88
|
-
fromIndex:
|
|
89
|
-
|
|
90
|
-
|
|
55
|
+
fromIndex: child._mountIndex,
|
|
56
|
+
fromNode: ReactReconciler.getNativeNode(child),
|
|
57
|
+
toIndex: toIndex,
|
|
58
|
+
afterNode: afterNode
|
|
59
|
+
};
|
|
91
60
|
}
|
|
92
61
|
|
|
93
62
|
/**
|
|
94
|
-
*
|
|
63
|
+
* Make an update for removing an element at an index.
|
|
95
64
|
*
|
|
96
|
-
* @param {string} parentID ID of the parent component.
|
|
97
65
|
* @param {number} fromIndex Index of the element to remove.
|
|
98
66
|
* @private
|
|
99
67
|
*/
|
|
100
|
-
function
|
|
68
|
+
function makeRemove(child, node) {
|
|
101
69
|
// NOTE: Null values reduce hidden classes.
|
|
102
|
-
|
|
103
|
-
parentID: parentID,
|
|
104
|
-
parentNode: null,
|
|
70
|
+
return {
|
|
105
71
|
type: ReactMultiChildUpdateTypes.REMOVE_NODE,
|
|
106
|
-
markupIndex: null,
|
|
107
72
|
content: null,
|
|
108
|
-
fromIndex:
|
|
109
|
-
|
|
110
|
-
|
|
73
|
+
fromIndex: child._mountIndex,
|
|
74
|
+
fromNode: node,
|
|
75
|
+
toIndex: null,
|
|
76
|
+
afterNode: null
|
|
77
|
+
};
|
|
111
78
|
}
|
|
112
79
|
|
|
113
80
|
/**
|
|
114
|
-
*
|
|
81
|
+
* Make an update for setting the markup of a node.
|
|
115
82
|
*
|
|
116
|
-
* @param {string} parentID ID of the parent component.
|
|
117
83
|
* @param {string} markup Markup that renders into an element.
|
|
118
84
|
* @private
|
|
119
85
|
*/
|
|
120
|
-
function
|
|
86
|
+
function makeSetMarkup(markup) {
|
|
121
87
|
// NOTE: Null values reduce hidden classes.
|
|
122
|
-
|
|
123
|
-
parentID: parentID,
|
|
124
|
-
parentNode: null,
|
|
88
|
+
return {
|
|
125
89
|
type: ReactMultiChildUpdateTypes.SET_MARKUP,
|
|
126
|
-
markupIndex: null,
|
|
127
90
|
content: markup,
|
|
128
91
|
fromIndex: null,
|
|
129
|
-
|
|
130
|
-
|
|
92
|
+
fromNode: null,
|
|
93
|
+
toIndex: null,
|
|
94
|
+
afterNode: null
|
|
95
|
+
};
|
|
131
96
|
}
|
|
132
97
|
|
|
133
98
|
/**
|
|
134
|
-
*
|
|
99
|
+
* Make an update for setting the text content.
|
|
135
100
|
*
|
|
136
|
-
* @param {string} parentID ID of the parent component.
|
|
137
101
|
* @param {string} textContent Text content to set.
|
|
138
102
|
* @private
|
|
139
103
|
*/
|
|
140
|
-
function
|
|
104
|
+
function makeTextContent(textContent) {
|
|
141
105
|
// NOTE: Null values reduce hidden classes.
|
|
142
|
-
|
|
143
|
-
parentID: parentID,
|
|
144
|
-
parentNode: null,
|
|
106
|
+
return {
|
|
145
107
|
type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
|
|
146
|
-
markupIndex: null,
|
|
147
108
|
content: textContent,
|
|
148
109
|
fromIndex: null,
|
|
149
|
-
|
|
150
|
-
|
|
110
|
+
fromNode: null,
|
|
111
|
+
toIndex: null,
|
|
112
|
+
afterNode: null
|
|
113
|
+
};
|
|
151
114
|
}
|
|
152
115
|
|
|
153
116
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @private
|
|
117
|
+
* Push an update, if any, onto the queue. Creates a new queue if none is
|
|
118
|
+
* passed and always returns the queue. Mutative.
|
|
157
119
|
*/
|
|
158
|
-
function
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
120
|
+
function enqueue(queue, update) {
|
|
121
|
+
if (update) {
|
|
122
|
+
queue = queue || [];
|
|
123
|
+
queue.push(update);
|
|
162
124
|
}
|
|
125
|
+
return queue;
|
|
163
126
|
}
|
|
164
127
|
|
|
165
128
|
/**
|
|
166
|
-
*
|
|
129
|
+
* Processes any enqueued updates.
|
|
167
130
|
*
|
|
168
131
|
* @private
|
|
169
132
|
*/
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
markupQueue.length = 0;
|
|
133
|
+
function processQueue(inst, updateQueue) {
|
|
134
|
+
ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
|
|
173
135
|
}
|
|
174
136
|
|
|
175
137
|
/**
|
|
@@ -203,7 +165,7 @@ var ReactMultiChild = {
|
|
|
203
165
|
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
|
|
204
166
|
},
|
|
205
167
|
|
|
206
|
-
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
|
|
168
|
+
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, removedNodes, transaction, context) {
|
|
207
169
|
var nextChildren;
|
|
208
170
|
if (process.env.NODE_ENV !== 'production') {
|
|
209
171
|
if (this._currentElement) {
|
|
@@ -213,11 +175,13 @@ var ReactMultiChild = {
|
|
|
213
175
|
} finally {
|
|
214
176
|
ReactCurrentOwner.current = null;
|
|
215
177
|
}
|
|
216
|
-
|
|
178
|
+
ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
|
|
179
|
+
return nextChildren;
|
|
217
180
|
}
|
|
218
181
|
}
|
|
219
182
|
nextChildren = flattenChildren(nextNestedChildrenElements);
|
|
220
|
-
|
|
183
|
+
ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
|
|
184
|
+
return nextChildren;
|
|
221
185
|
},
|
|
222
186
|
|
|
223
187
|
/**
|
|
@@ -236,9 +200,7 @@ var ReactMultiChild = {
|
|
|
236
200
|
for (var name in children) {
|
|
237
201
|
if (children.hasOwnProperty(name)) {
|
|
238
202
|
var child = children[name];
|
|
239
|
-
|
|
240
|
-
var rootID = this._rootNodeID + name;
|
|
241
|
-
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
203
|
+
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._nativeContainerInfo, context);
|
|
242
204
|
child._mountIndex = index++;
|
|
243
205
|
mountImages.push(mountImage);
|
|
244
206
|
}
|
|
@@ -253,31 +215,17 @@ var ReactMultiChild = {
|
|
|
253
215
|
* @internal
|
|
254
216
|
*/
|
|
255
217
|
updateTextContent: function (nextContent) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// TODO: The setTextContent operation should be enough
|
|
263
|
-
for (var name in prevChildren) {
|
|
264
|
-
if (prevChildren.hasOwnProperty(name)) {
|
|
265
|
-
this._unmountChild(prevChildren[name]);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
// Set new text content.
|
|
269
|
-
this.setTextContent(nextContent);
|
|
270
|
-
errorThrown = false;
|
|
271
|
-
} finally {
|
|
272
|
-
updateDepth--;
|
|
273
|
-
if (!updateDepth) {
|
|
274
|
-
if (errorThrown) {
|
|
275
|
-
clearQueue();
|
|
276
|
-
} else {
|
|
277
|
-
processQueue();
|
|
278
|
-
}
|
|
218
|
+
var prevChildren = this._renderedChildren;
|
|
219
|
+
// Remove any rendered children.
|
|
220
|
+
ReactChildReconciler.unmountChildren(prevChildren, false);
|
|
221
|
+
for (var name in prevChildren) {
|
|
222
|
+
if (prevChildren.hasOwnProperty(name)) {
|
|
223
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : invariant(false) : void 0;
|
|
279
224
|
}
|
|
280
225
|
}
|
|
226
|
+
// Set new text content.
|
|
227
|
+
var updates = [makeTextContent(nextContent)];
|
|
228
|
+
processQueue(this, updates);
|
|
281
229
|
},
|
|
282
230
|
|
|
283
231
|
/**
|
|
@@ -287,29 +235,16 @@ var ReactMultiChild = {
|
|
|
287
235
|
* @internal
|
|
288
236
|
*/
|
|
289
237
|
updateMarkup: function (nextMarkup) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
for (var name in prevChildren) {
|
|
297
|
-
if (prevChildren.hasOwnProperty(name)) {
|
|
298
|
-
this._unmountChildByName(prevChildren[name], name);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
this.setMarkup(nextMarkup);
|
|
302
|
-
errorThrown = false;
|
|
303
|
-
} finally {
|
|
304
|
-
updateDepth--;
|
|
305
|
-
if (!updateDepth) {
|
|
306
|
-
if (errorThrown) {
|
|
307
|
-
clearQueue();
|
|
308
|
-
} else {
|
|
309
|
-
processQueue();
|
|
310
|
-
}
|
|
238
|
+
var prevChildren = this._renderedChildren;
|
|
239
|
+
// Remove any rendered children.
|
|
240
|
+
ReactChildReconciler.unmountChildren(prevChildren, false);
|
|
241
|
+
for (var name in prevChildren) {
|
|
242
|
+
if (prevChildren.hasOwnProperty(name)) {
|
|
243
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : invariant(false) : void 0;
|
|
311
244
|
}
|
|
312
245
|
}
|
|
246
|
+
var updates = [makeSetMarkup(nextMarkup)];
|
|
247
|
+
processQueue(this, updates);
|
|
313
248
|
},
|
|
314
249
|
|
|
315
250
|
/**
|
|
@@ -320,27 +255,11 @@ var ReactMultiChild = {
|
|
|
320
255
|
* @internal
|
|
321
256
|
*/
|
|
322
257
|
updateChildren: function (nextNestedChildrenElements, transaction, context) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
try {
|
|
326
|
-
this._updateChildren(nextNestedChildrenElements, transaction, context);
|
|
327
|
-
errorThrown = false;
|
|
328
|
-
} finally {
|
|
329
|
-
updateDepth--;
|
|
330
|
-
if (!updateDepth) {
|
|
331
|
-
if (errorThrown) {
|
|
332
|
-
clearQueue();
|
|
333
|
-
} else {
|
|
334
|
-
processQueue();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
258
|
+
// Hook used by React ART
|
|
259
|
+
this._updateChildren(nextNestedChildrenElements, transaction, context);
|
|
338
260
|
},
|
|
339
261
|
|
|
340
262
|
/**
|
|
341
|
-
* Improve performance by isolating this hot code path from the try/catch
|
|
342
|
-
* block in `updateChildren`.
|
|
343
|
-
*
|
|
344
263
|
* @param {?object} nextNestedChildrenElements Nested child element maps.
|
|
345
264
|
* @param {ReactReconcileTransaction} transaction
|
|
346
265
|
* @final
|
|
@@ -348,16 +267,18 @@ var ReactMultiChild = {
|
|
|
348
267
|
*/
|
|
349
268
|
_updateChildren: function (nextNestedChildrenElements, transaction, context) {
|
|
350
269
|
var prevChildren = this._renderedChildren;
|
|
351
|
-
var
|
|
352
|
-
this.
|
|
270
|
+
var removedNodes = {};
|
|
271
|
+
var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, removedNodes, transaction, context);
|
|
353
272
|
if (!nextChildren && !prevChildren) {
|
|
354
273
|
return;
|
|
355
274
|
}
|
|
275
|
+
var updates = null;
|
|
356
276
|
var name;
|
|
357
277
|
// `nextIndex` will increment for each child in `nextChildren`, but
|
|
358
278
|
// `lastIndex` will be the last index visited in `prevChildren`.
|
|
359
279
|
var lastIndex = 0;
|
|
360
280
|
var nextIndex = 0;
|
|
281
|
+
var lastPlacedNode = null;
|
|
361
282
|
for (name in nextChildren) {
|
|
362
283
|
if (!nextChildren.hasOwnProperty(name)) {
|
|
363
284
|
continue;
|
|
@@ -365,37 +286,43 @@ var ReactMultiChild = {
|
|
|
365
286
|
var prevChild = prevChildren && prevChildren[name];
|
|
366
287
|
var nextChild = nextChildren[name];
|
|
367
288
|
if (prevChild === nextChild) {
|
|
368
|
-
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
289
|
+
updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex));
|
|
369
290
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
370
291
|
prevChild._mountIndex = nextIndex;
|
|
371
292
|
} else {
|
|
372
293
|
if (prevChild) {
|
|
373
294
|
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
|
|
374
295
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
375
|
-
|
|
296
|
+
// The `removedNodes` loop below will actually remove the child.
|
|
376
297
|
}
|
|
377
298
|
// The child must be instantiated before it's mounted.
|
|
378
|
-
this.
|
|
299
|
+
updates = enqueue(updates, this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context));
|
|
379
300
|
}
|
|
380
301
|
nextIndex++;
|
|
302
|
+
lastPlacedNode = ReactReconciler.getNativeNode(nextChild);
|
|
381
303
|
}
|
|
382
304
|
// Remove children that are no longer present.
|
|
383
|
-
for (name in
|
|
384
|
-
if (
|
|
385
|
-
this._unmountChild(prevChildren[name]);
|
|
305
|
+
for (name in removedNodes) {
|
|
306
|
+
if (removedNodes.hasOwnProperty(name)) {
|
|
307
|
+
updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name]));
|
|
386
308
|
}
|
|
387
309
|
}
|
|
310
|
+
if (updates) {
|
|
311
|
+
processQueue(this, updates);
|
|
312
|
+
}
|
|
313
|
+
this._renderedChildren = nextChildren;
|
|
388
314
|
},
|
|
389
315
|
|
|
390
316
|
/**
|
|
391
317
|
* Unmounts all rendered children. This should be used to clean up children
|
|
392
|
-
* when this component is unmounted.
|
|
318
|
+
* when this component is unmounted. It does not actually perform any
|
|
319
|
+
* backend operations.
|
|
393
320
|
*
|
|
394
321
|
* @internal
|
|
395
322
|
*/
|
|
396
|
-
unmountChildren: function () {
|
|
323
|
+
unmountChildren: function (safely) {
|
|
397
324
|
var renderedChildren = this._renderedChildren;
|
|
398
|
-
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
325
|
+
ReactChildReconciler.unmountChildren(renderedChildren, safely);
|
|
399
326
|
this._renderedChildren = null;
|
|
400
327
|
},
|
|
401
328
|
|
|
@@ -407,12 +334,12 @@ var ReactMultiChild = {
|
|
|
407
334
|
* @param {number} lastIndex Last index visited of the siblings of `child`.
|
|
408
335
|
* @protected
|
|
409
336
|
*/
|
|
410
|
-
moveChild: function (child, toIndex, lastIndex) {
|
|
337
|
+
moveChild: function (child, afterNode, toIndex, lastIndex) {
|
|
411
338
|
// If the index of `child` is less than `lastIndex`, then it needs to
|
|
412
339
|
// be moved. Otherwise, we do not need to move it because a child will be
|
|
413
340
|
// inserted or moved before `child`.
|
|
414
341
|
if (child._mountIndex < lastIndex) {
|
|
415
|
-
|
|
342
|
+
return makeMove(child, afterNode, toIndex);
|
|
416
343
|
}
|
|
417
344
|
},
|
|
418
345
|
|
|
@@ -423,8 +350,8 @@ var ReactMultiChild = {
|
|
|
423
350
|
* @param {string} mountImage Markup to insert.
|
|
424
351
|
* @protected
|
|
425
352
|
*/
|
|
426
|
-
createChild: function (child, mountImage) {
|
|
427
|
-
|
|
353
|
+
createChild: function (child, afterNode, mountImage) {
|
|
354
|
+
return makeInsertMarkup(mountImage, afterNode, child._mountIndex);
|
|
428
355
|
},
|
|
429
356
|
|
|
430
357
|
/**
|
|
@@ -433,28 +360,8 @@ var ReactMultiChild = {
|
|
|
433
360
|
* @param {ReactComponent} child Child to remove.
|
|
434
361
|
* @protected
|
|
435
362
|
*/
|
|
436
|
-
removeChild: function (child) {
|
|
437
|
-
|
|
438
|
-
},
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Sets this text content string.
|
|
442
|
-
*
|
|
443
|
-
* @param {string} textContent Text content to set.
|
|
444
|
-
* @protected
|
|
445
|
-
*/
|
|
446
|
-
setTextContent: function (textContent) {
|
|
447
|
-
enqueueTextContent(this._rootNodeID, textContent);
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Sets this markup string.
|
|
452
|
-
*
|
|
453
|
-
* @param {string} markup Markup to set.
|
|
454
|
-
* @protected
|
|
455
|
-
*/
|
|
456
|
-
setMarkup: function (markup) {
|
|
457
|
-
enqueueSetMarkup(this._rootNodeID, markup);
|
|
363
|
+
removeChild: function (child, node) {
|
|
364
|
+
return makeRemove(child, node);
|
|
458
365
|
},
|
|
459
366
|
|
|
460
367
|
/**
|
|
@@ -468,12 +375,10 @@ var ReactMultiChild = {
|
|
|
468
375
|
* @param {ReactReconcileTransaction} transaction
|
|
469
376
|
* @private
|
|
470
377
|
*/
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
var rootID = this._rootNodeID + name;
|
|
474
|
-
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
378
|
+
_mountChildAtIndex: function (child, afterNode, index, transaction, context) {
|
|
379
|
+
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._nativeContainerInfo, context);
|
|
475
380
|
child._mountIndex = index;
|
|
476
|
-
this.createChild(child, mountImage);
|
|
381
|
+
return this.createChild(child, afterNode, mountImage);
|
|
477
382
|
},
|
|
478
383
|
|
|
479
384
|
/**
|
|
@@ -484,9 +389,10 @@ var ReactMultiChild = {
|
|
|
484
389
|
* @param {ReactComponent} child Component to unmount.
|
|
485
390
|
* @private
|
|
486
391
|
*/
|
|
487
|
-
_unmountChild: function (child) {
|
|
488
|
-
this.removeChild(child);
|
|
392
|
+
_unmountChild: function (child, node) {
|
|
393
|
+
var update = this.removeChild(child, node);
|
|
489
394
|
child._mountIndex = null;
|
|
395
|
+
return update;
|
|
490
396
|
}
|
|
491
397
|
|
|
492
398
|
}
|