Skip to content

Commit

Permalink
Fix ReactComponentTreeHook.getRegisteredIDs() to work with inlined co…
Browse files Browse the repository at this point in the history
…ntent (#7490)

I broke this in #7463: parseInt() cuts off #text at the end.
Changing to just use negative numbers instead.
  • Loading branch information
gaearon authored Aug 13, 2016
1 parent cba2b19 commit a738864
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a738864

Please sign in to comment.