@@ -53,14 +53,14 @@ var markupQueue = [];
53
53
* @param {number } toIndex Destination index.
54
54
* @private
55
55
*/
56
- function enqueueMarkup ( parentID , markup , toIndex ) {
56
+ function enqueueInsertMarkup ( parentID , markup , toIndex ) {
57
57
// NOTE: Null values reduce hidden classes.
58
58
updateQueue . push ( {
59
59
parentID : parentID ,
60
60
parentNode : null ,
61
61
type : ReactMultiChildUpdateTypes . INSERT_MARKUP ,
62
62
markupIndex : markupQueue . push ( markup ) - 1 ,
63
- textContent : null ,
63
+ content : null ,
64
64
fromIndex : null ,
65
65
toIndex : toIndex ,
66
66
} ) ;
@@ -81,7 +81,7 @@ function enqueueMove(parentID, fromIndex, toIndex) {
81
81
parentNode : null ,
82
82
type : ReactMultiChildUpdateTypes . MOVE_EXISTING ,
83
83
markupIndex : null ,
84
- textContent : null ,
84
+ content : null ,
85
85
fromIndex : fromIndex ,
86
86
toIndex : toIndex ,
87
87
} ) ;
@@ -101,12 +101,32 @@ function enqueueRemove(parentID, fromIndex) {
101
101
parentNode : null ,
102
102
type : ReactMultiChildUpdateTypes . REMOVE_NODE ,
103
103
markupIndex : null ,
104
- textContent : null ,
104
+ content : null ,
105
105
fromIndex : fromIndex ,
106
106
toIndex : null ,
107
107
} ) ;
108
108
}
109
109
110
+ /**
111
+ * Enqueues setting the markup of a node.
112
+ *
113
+ * @param {string } parentID ID of the parent component.
114
+ * @param {string } markup Markup that renders into an element.
115
+ * @private
116
+ */
117
+ function enqueueSetMarkup ( parentID , markup ) {
118
+ // NOTE: Null values reduce hidden classes.
119
+ updateQueue . push ( {
120
+ parentID : parentID ,
121
+ parentNode : null ,
122
+ type : ReactMultiChildUpdateTypes . SET_MARKUP ,
123
+ markupIndex : null ,
124
+ content : markup ,
125
+ fromIndex : null ,
126
+ toIndex : null ,
127
+ } ) ;
128
+ }
129
+
110
130
/**
111
131
* Enqueues setting the text content.
112
132
*
@@ -121,7 +141,7 @@ function enqueueTextContent(parentID, textContent) {
121
141
parentNode : null ,
122
142
type : ReactMultiChildUpdateTypes . TEXT_CONTENT ,
123
143
markupIndex : null ,
124
- textContent : textContent ,
144
+ content : textContent ,
125
145
fromIndex : null ,
126
146
toIndex : null ,
127
147
} ) ;
@@ -237,6 +257,38 @@ var ReactMultiChild = {
237
257
}
238
258
} ,
239
259
260
+ /**
261
+ * Replaces any rendered children with a markup string.
262
+ *
263
+ * @param {string } nextMarkup String of markup.
264
+ * @internal
265
+ */
266
+ updateMarkup : function ( nextMarkup ) {
267
+ updateDepth ++ ;
268
+ var errorThrown = true ;
269
+ try {
270
+ var prevChildren = this . _renderedChildren ;
271
+ // Remove any rendered children.
272
+ ReactChildReconciler . unmountChildren ( prevChildren ) ;
273
+ for ( var name in prevChildren ) {
274
+ if ( prevChildren . hasOwnProperty ( name ) ) {
275
+ this . _unmountChildByName ( prevChildren [ name ] , name ) ;
276
+ }
277
+ }
278
+ this . setMarkup ( nextMarkup ) ;
279
+ errorThrown = false ;
280
+ } finally {
281
+ updateDepth -- ;
282
+ if ( ! updateDepth ) {
283
+ if ( errorThrown ) {
284
+ clearQueue ( ) ;
285
+ } else {
286
+ processQueue ( ) ;
287
+ }
288
+ }
289
+ }
290
+ } ,
291
+
240
292
/**
241
293
* Updates the rendered children with new children.
242
294
*
@@ -355,7 +407,7 @@ var ReactMultiChild = {
355
407
* @protected
356
408
*/
357
409
createChild : function ( child , mountImage ) {
358
- enqueueMarkup ( this . _rootNodeID , mountImage , child . _mountIndex ) ;
410
+ enqueueInsertMarkup ( this . _rootNodeID , mountImage , child . _mountIndex ) ;
359
411
} ,
360
412
361
413
/**
@@ -378,6 +430,16 @@ var ReactMultiChild = {
378
430
enqueueTextContent ( this . _rootNodeID , textContent ) ;
379
431
} ,
380
432
433
+ /**
434
+ * Sets this markup string.
435
+ *
436
+ * @param {string } markup Markup to set.
437
+ * @protected
438
+ */
439
+ setMarkup : function ( markup ) {
440
+ enqueueSetMarkup ( this . _rootNodeID , markup ) ;
441
+ } ,
442
+
381
443
/**
382
444
* Mounts a child with the supplied name.
383
445
*
0 commit comments