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.
(cherry picked from commit a73886456e)
This commit is contained in:
Dan Abramov
2016-08-15 15:20:25 -07:00
committed by Paul O’Shannessy
parent 8e79c9fd30
commit ce24114a01
2 changed files with 12 additions and 1 deletions
@@ -258,7 +258,8 @@ if (__DEV__) {
setContentChildForInstrumentation = function(content) {
var hasExistingContent = this._contentDebugID != null;
var debugID = this._debugID;
var contentDebugID = debugID + '#text';
// This ID represents the inlined child that has no backing instance:
var contentDebugID = -debugID;
if (content == null) {
if (hasExistingContent) {
@@ -1721,6 +1721,16 @@ describe('ReactComponentTreeHook', () => {
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
});
it('registers inlined text nodes', () => {
var node = document.createElement('div');
ReactDOM.render(<div>hi</div>, node);
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
ReactDOM.unmountComponentAtNode(node);
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
});
describe('stack addenda', () => {
it('gets created', () => {
function getAddendum(element) {