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.
This commit is contained in:
Dan Abramov
2016-08-13 19:36:21 +01:00
committed by GitHub
parent cba2b19b84
commit a73886456e
2 changed files with 12 additions and 1 deletions
@@ -259,7 +259,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) {