From 367594a2139b08e56dfcb7554d76ece0f9282a6c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 20 Apr 2016 18:20:14 +0100 Subject: [PATCH] Enforce that info about children is available by the time onSetChildren() fires --- src/isomorphic/__tests__/ReactDebugTool-test.js | 7 +++++++ src/renderers/dom/shared/ReactDOMComponent.js | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/isomorphic/__tests__/ReactDebugTool-test.js b/src/isomorphic/__tests__/ReactDebugTool-test.js index faff237152..85d6d64b02 100644 --- a/src/isomorphic/__tests__/ReactDebugTool-test.js +++ b/src/isomorphic/__tests__/ReactDebugTool-test.js @@ -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) { diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 5f94467911..50db5019d4 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -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) {