@samitouri / QOS-React / commits / 1587abf6f0

Don't report children for empty and text nodes

Dan Abramov committed Apr 20, 2016 at 18:12 UTC 1587abf6f06f4c3ab164eb69c256f3f8ceb3c526
3 files changed +11 -55
src/isomorphic/__tests__/ReactDebugTool-test.js
+5 -52
@@ -35,9 +35,11 @@ describe('ReactDebugTool', () => {
35 isComposite: item.isComposite,
36 displayName: item.displayName,
37 };
38 - result.children = item.childDebugIDs.map(childDebugID =>
39 - getTree(childDebugID, includeOwner)
40 - );
38 + if (item.childDebugIDs) {
39 + result.children = item.childDebugIDs.map(childDebugID =>
40 + getTree(childDebugID, includeOwner)
41 + );
42 + }
43 if (item.text != null) {
44 result.text = item.text;
45 }
@@ -299,13 +301,11 @@ describe('ReactDebugTool', () => {
301 isComposite: false,
302 displayName: '#text',
303 text: 'Hi!',
302 - children: [],
304 }],
305 }, {
306 isComposite: false,
307 displayName: '#text',
308 text: 'Wow.',
308 - children: [],
309 }],
310 }, {
311 isComposite: false,
@@ -395,13 +395,11 @@ describe('ReactDebugTool', () => {
395 isComposite: false,
396 displayName: '#text',
397 text: 'Hi,',
398 - children: [],
398 }],
399 }, {
400 isComposite: false,
401 displayName: '#text',
402 text: 'Mom',
404 - children: [],
403 }],
404 }],
405 }, {
@@ -411,7 +409,6 @@ describe('ReactDebugTool', () => {
409 isComposite: false,
410 displayName: '#text',
411 text: 'Click me.',
414 - children: [],
412 }],
413 }],
414 }],
@@ -458,12 +455,10 @@ describe('ReactDebugTool', () => {
455 isComposite: false,
456 displayName: '#text',
457 text: '1',
461 - children: [],
458 }, {
459 isComposite: false,
460 displayName: '#text',
461 text: '2',
466 - children: [],
462 }],
463 };
464 assertTreeMatches([element, tree]);
@@ -478,7 +473,6 @@ describe('ReactDebugTool', () => {
473 isComposite: false,
474 displayName: '#text',
475 text: '1',
481 - children: [],
476 }],
477 };
478 assertTreeMatches([element, tree]);
@@ -493,7 +487,6 @@ describe('ReactDebugTool', () => {
487 isComposite: false,
488 displayName: '#text',
489 text: '42',
496 - children: [],
490 }],
491 };
492 assertTreeMatches([element, tree]);
@@ -508,7 +501,6 @@ describe('ReactDebugTool', () => {
501 isComposite: false,
502 displayName: '#text',
503 text: '0',
511 - children: [],
504 }],
505 };
506 assertTreeMatches([element, tree]);
@@ -534,12 +526,10 @@ describe('ReactDebugTool', () => {
526 isComposite: false,
527 displayName: '#text',
528 text: 'hi',
537 - children: [],
529 }, {
530 isComposite: false,
531 displayName: '#text',
532 text: '42',
542 - children: [],
533 }, {
534 isComposite: true,
535 displayName: 'Foo',
@@ -575,7 +565,6 @@ describe('ReactDebugTool', () => {
565 isComposite: false,
566 displayName: '#text',
567 text: 'Hi.',
578 - children: [],
568 }],
569 };
570
@@ -587,7 +576,6 @@ describe('ReactDebugTool', () => {
576 isComposite: false,
577 displayName: '#text',
578 text: 'Bye.',
590 - children: [],
579 }],
580 };
581
@@ -613,7 +601,6 @@ describe('ReactDebugTool', () => {
601 isComposite: false,
602 displayName: '#text',
603 text: 'Hi.',
616 - children: [],
604 }],
605 };
606
@@ -632,7 +619,6 @@ describe('ReactDebugTool', () => {
619 isComposite: false,
620 displayName: '#text',
621 text: 'Hi.',
635 - children: [],
622 }],
623 };
624
@@ -665,7 +651,6 @@ describe('ReactDebugTool', () => {
651 isComposite: false,
652 displayName: '#text',
653 text: 'Hi.',
668 - children: [],
654 }],
655 };
656
@@ -684,7 +669,6 @@ describe('ReactDebugTool', () => {
669 isComposite: false,
670 displayName: '#text',
671 text: 'Hi.',
687 - children: [],
672 }],
673 };
674
@@ -717,12 +701,10 @@ describe('ReactDebugTool', () => {
701 isComposite: false,
702 displayName: '#text',
703 text: 'Hi.',
720 - children: [],
704 }, {
705 isComposite: false,
706 displayName: '#text',
707 text: 'Bye.',
725 - children: [],
708 }],
709 };
710
@@ -741,12 +723,10 @@ describe('ReactDebugTool', () => {
723 isComposite: false,
724 displayName: '#text',
725 text: 'Hi.',
744 - children: [],
726 }, {
727 isComposite: false,
728 displayName: '#text',
729 text: 'Bye.',
749 - children: [],
730 }],
731 };
732
@@ -779,12 +759,10 @@ describe('ReactDebugTool', () => {
759 isComposite: false,
760 displayName: '#text',
761 text: 'Hi.',
782 - children: [],
762 }, {
763 isComposite: false,
764 displayName: '#text',
765 text: 'Bye.',
787 - children: [],
766 }],
767 };
768
@@ -803,12 +781,10 @@ describe('ReactDebugTool', () => {
781 isComposite: false,
782 displayName: '#text',
783 text: 'Hi.',
806 - children: [],
784 }, {
785 isComposite: false,
786 displayName: '#text',
787 text: 'Bye.',
811 - children: [],
788 }],
789 };
790
@@ -876,7 +852,6 @@ describe('ReactDebugTool', () => {
852 isComposite: false,
853 displayName: '#text',
854 text: 'Hi.',
879 - children: [],
855 }],
856 };
857
@@ -888,12 +863,10 @@ describe('ReactDebugTool', () => {
863 isComposite: false,
864 displayName: '#text',
865 text: 'Hi.',
891 - children: [],
866 }, {
867 isComposite: false,
868 displayName: '#text',
869 text: 'Bye.',
896 - children: [],
870 }],
871 };
872
@@ -912,12 +885,10 @@ describe('ReactDebugTool', () => {
885 isComposite: false,
886 displayName: '#text',
887 text: 'Hi.',
915 - children: [],
888 }, {
889 isComposite: false,
890 displayName: '#text',
891 text: 'Bye.',
920 - children: [],
892 }],
893 };
894
@@ -929,7 +900,6 @@ describe('ReactDebugTool', () => {
900 isComposite: false,
901 displayName: '#text',
902 text: 'Hi.',
932 - children: [],
903 }],
904 };
905 assertTreeMatches([
@@ -947,12 +917,10 @@ describe('ReactDebugTool', () => {
917 isComposite: false,
918 displayName: '#text',
919 text: 'Hi.',
950 - children: [],
920 }, {
921 isComposite: false,
922 displayName: '#text',
923 text: 'Bye.',
955 - children: [],
924 }],
925 };
926
@@ -964,12 +932,10 @@ describe('ReactDebugTool', () => {
932 isComposite: false,
933 displayName: '#text',
934 text: 'Bye.',
967 - children: [],
935 }, {
936 isComposite: false,
937 displayName: '#text',
938 text: 'Hi.',
972 - children: [],
939 }],
940 };
941 assertTreeMatches([
@@ -995,7 +961,6 @@ describe('ReactDebugTool', () => {
961 isComposite: false,
962 displayName: '#text',
963 text: 'Hi.',
998 - children: [],
964 }],
965 }, {
966 isComposite: false,
@@ -1004,7 +969,6 @@ describe('ReactDebugTool', () => {
969 isComposite: false,
970 displayName: '#text',
971 text: 'Bye.',
1007 - children: [],
972 }],
973 }],
974 };
@@ -1025,7 +989,6 @@ describe('ReactDebugTool', () => {
989 isComposite: false,
990 displayName: '#text',
991 text: 'Bye.',
1028 - children: [],
992 }],
993 }, {
994 isComposite: false,
@@ -1034,7 +997,6 @@ describe('ReactDebugTool', () => {
997 isComposite: false,
998 displayName: '#text',
999 text: 'Hi.',
1037 - children: [],
1000 }],
1001 }],
1002 };
@@ -1062,7 +1024,6 @@ describe('ReactDebugTool', () => {
1024 isComposite: false,
1025 displayName: '#text',
1026 text: 'Hi.',
1065 - children: [],
1027 }],
1028 }, {
1029 isComposite: false,
@@ -1071,7 +1032,6 @@ describe('ReactDebugTool', () => {
1032 isComposite: false,
1033 displayName: '#text',
1034 text: 'Bye.',
1074 - children: [],
1035 }],
1036 }],
1037 };
@@ -1092,7 +1052,6 @@ describe('ReactDebugTool', () => {
1052 isComposite: false,
1053 displayName: '#text',
1054 text: 'Bye.',
1095 - children: [],
1055 }],
1056 }, {
1057 isComposite: false,
@@ -1101,7 +1060,6 @@ describe('ReactDebugTool', () => {
1060 isComposite: false,
1061 displayName: '#text',
1062 text: 'Hi.',
1104 - children: [],
1063 }],
1064 }],
1065 };
@@ -1268,12 +1226,10 @@ describe('ReactDebugTool', () => {
1226 isComposite: false,
1227 displayName: '#text',
1228 text: 'hi',
1271 - children: [],
1229 }, {
1230 isComposite: false,
1231 displayName: '#text',
1232 text: '42',
1276 - children: [],
1233 }, {
1234 isComposite: true,
1235 displayName: 'Foo',
@@ -1308,7 +1264,6 @@ describe('ReactDebugTool', () => {
1264 isComposite: false,
1265 displayName: '#text',
1266 text: 'hi',
1311 - children: [],
1267 }],
1268 };
1269
@@ -1863,13 +1818,11 @@ describe('ReactDebugTool', () => {
1818 isComposite: false,
1819 displayName: '#text',
1820 text: 'Hi.',
1866 - children: [],
1821 }],
1822 }, {
1823 isComposite: false,
1824 displayName: '#text',
1825 text: ' Mom',
1872 - children: [],
1826 }],
1827 }],
1828 }],
src/renderers/dom/shared/ReactDOMComponent.js
-2
@@ -762,7 +762,6 @@ ReactDOMComponent.Mixin = {
762 ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
763 ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
764 ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
765 - ReactInstrumentation.debugTool.onSetChildren(inlinedTextDebugID, []);
765 ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + contentToUse);
766 }
767 DOMLazyTree.queueText(lazyTree, contentToUse);
@@ -1025,7 +1024,6 @@ ReactDOMComponent.Mixin = {
1024 ReactInstrumentation.debugTool.onSetChildren(this._debugID, [inlinedTextDebugID]);
1025 ReactInstrumentation.debugTool.onSetIsComposite(inlinedTextDebugID, false);
1026 ReactInstrumentation.debugTool.onSetDisplayName(inlinedTextDebugID, '#text');
1028 - ReactInstrumentation.debugTool.onSetChildren(inlinedTextDebugID, []);
1027 ReactInstrumentation.debugTool.onSetText(inlinedTextDebugID, '' + nextContent);
1028 }
1029 }
src/renderers/shared/reconciler/instantiateReactComponent.js
+6 -1
@@ -85,6 +85,7 @@ function instantiateReactComponent(node) {
85 var instance;
86
87 var isEmpty = false;
88 + var isNative = false;
89 var isComposite = false;
90
91 if (node === null || node === false) {
@@ -103,8 +104,10 @@ function instantiateReactComponent(node) {
104
105 // Special case string values
106 if (typeof element.type === 'string') {
107 + isNative = true;
108 instance = ReactNativeComponent.createInternalComponent(element);
109 } else if (isInternalComponentType(element.type)) {
110 + isComposite = true;
111 // This is temporarily available for custom components that are not string
112 // representations. I.e. ART. Once those are updated to use the string
113 // representation, we can drop this code path.
@@ -149,7 +152,9 @@ function instantiateReactComponent(node) {
152 var displayName = getDisplayName(instance);
153 ReactInstrumentation.debugTool.onSetIsComposite(instance._debugID, isComposite);
154 ReactInstrumentation.debugTool.onSetDisplayName(instance._debugID, displayName);
152 - ReactInstrumentation.debugTool.onSetChildren(instance._debugID, []);
155 + if (isNative || isComposite) {
156 + ReactInstrumentation.debugTool.onSetChildren(instance._debugID, []);
157 + }
158 var owner = node && node._owner;
159 if (owner) {
160 ReactInstrumentation.debugTool.onSetOwner(instance._debugID, owner._debugID);