Enforce that info about children is available by the time onSetChildren() fires
Dan Abramov committed
Apr 20, 2016 at 18:20 UTC
367594a2139b08e56dfcb7554d76ece0f9282a6c
2 files changed
+9
-2
src/isomorphic/__tests__/ReactDebugTool-test.js
+7
@@ -57,6 +57,13 @@ describe('ReactDebugTool', () => {
57
updateTree(debugID, item => item.displayName = displayName);
58
},
59
onSetChildren(debugID, childDebugIDs) {
60
+ childDebugIDs.forEach(childDebugID => {
61
+ var childItem = tree[childDebugID];
62
+ expect(childItem).toBeDefined();
63
+ expect(childItem.isComposite).toBeDefined();
64
+ expect(childItem.displayName).toBeDefined();
65
+ expect(childItem.childDebugIDs || childItem.text).toBeDefined();
66
+ });
67
updateTree(debugID, item => item.childDebugIDs = childDebugIDs);
68
},
69
onSetOwner(debugID, ownerDebugID) {
src/renderers/dom/shared/ReactDOMComponent.js
+2
-2
@@ -759,10 +759,10 @@ ReactDOMComponent.Mixin = {
759
// TODO: Validate that text is allowed as a child of this node
760
if (__DEV__) {
761
var inlinedTextDebugID = this._debugID + '#text';
762
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
762
ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
763
ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
764
ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + contentToUse);
765
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
766
}
767
DOMLazyTree.queueText(lazyTree, contentToUse);
768
} else if (childrenToUse != null) {
@@ -1021,10 +1021,10 @@ ReactDOMComponent.Mixin = {
1021
this.updateTextContent('' + nextContent);
1022
if (__DEV__) {
1023
var inlinedTextDebugID = this._debugID + '#text';
1024
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
1024
ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
1025
ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
1026
ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + nextContent);
1027
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
1028
}
1029
}
1030
} else if (nextHtml != null) {