Enforce that info about children is available by the time onSetChildren() fires

This commit is contained in:
Dan Abramov
2016-04-20 18:20:14 +01:00
parent 1587abf6f0
commit 367594a213
2 changed files with 9 additions and 2 deletions
@@ -57,6 +57,13 @@ describe('ReactDebugTool', () => {
updateTree(debugID, item => item.displayName = displayName);
},
onSetChildren(debugID, childDebugIDs) {
childDebugIDs.forEach(childDebugID => {
var childItem = tree[childDebugID];
expect(childItem).toBeDefined();
expect(childItem.isComposite).toBeDefined();
expect(childItem.displayName).toBeDefined();
expect(childItem.childDebugIDs || childItem.text).toBeDefined();
});
updateTree(debugID, item => item.childDebugIDs = childDebugIDs);
},
onSetOwner(debugID, ownerDebugID) {
@@ -759,10 +759,10 @@ ReactDOMComponent.Mixin = {
// TODO: Validate that text is allowed as a child of this node
if (__DEV__) {
var inlinedTextDebugID = this._debugID + '#text';
ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + contentToUse);
ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
}
DOMLazyTree.queueText(lazyTree, contentToUse);
} else if (childrenToUse != null) {
@@ -1021,10 +1021,10 @@ ReactDOMComponent.Mixin = {
this.updateTextContent('' + nextContent);
if (__DEV__) {
var inlinedTextDebugID = this._debugID + '#text';
ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + nextContent);
ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
}
}
} else if (nextHtml != null) {