@samitouri / QOS-React / commits / a73886456e

Fix ReactComponentTreeHook.getRegisteredIDs() to work with inlined content (#7490)

I broke this in #7463: parseInt() cuts off #text at the end. Changing to just use negative numbers instead.

Dan Abramov committed Aug 13, 2016 at 19:36 UTC a73886456e0cd07d2c9c93459d3f7625876ff7c9
2 files changed +12 -1
src/renderers/dom/shared/ReactDOMComponent.js
+2 -1
@@ -259,7 +259,8 @@ if (__DEV__) {
259 setContentChildForInstrumentation = function(content) {
260 var hasExistingContent = this._contentDebugID != null;
261 var debugID = this._debugID;
262 - var contentDebugID = debugID + '#text';
262 + // This ID represents the inlined child that has no backing instance:
263 + var contentDebugID = -debugID;
264
265 if (content == null) {
266 if (hasExistingContent) {
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
+10
@@ -1721,6 +1721,16 @@ describe('ReactComponentTreeHook', () => {
1721 expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1722 });
1723
1724 + it('registers inlined text nodes', () => {
1725 + var node = document.createElement('div');
1726 +
1727 + ReactDOM.render(<div>hi</div>, node);
1728 + expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
1729 +
1730 + ReactDOM.unmountComponentAtNode(node);
1731 + expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1732 + });
1733 +
1734 describe('stack addenda', () => {
1735 it('gets created', () => {
1736 function getAddendum(element) {