@samitouri / QOS-React / commits / be2ec3d5b8

Fix findDOMNode for empty children

If there is no child there is nothing to tell us that this was the workInProgress branch. Therefore, we need to look at the other branch if there are children in it to see if *that* was the workInProgress branch.

Sebastian Markbage committed Nov 20, 2016 at 20:27 UTC be2ec3d5b8333660ad203ba4dfb378473c6c0827
3 files changed +9 -3
scripts/fiber/tests-failing.txt
-3
@@ -121,9 +121,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponentNestedSta
121
122 src/renderers/shared/stack/reconciler/__tests__/ReactEmptyComponent-test.js
123 * should still throw when rendering to undefined
124 -* should be able to switch between rendering null and a normal tag
125 -* should be able to switch in a list of children
126 -* should distinguish between a script placeholder and an actual script tag
124 * throws when rendering null at the top level
125 * preserves the dom node during updates
126
scripts/fiber/tests-passing.txt
+3
@@ -1298,6 +1298,9 @@ src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponentState-tes
1298
1299 src/renderers/shared/stack/reconciler/__tests__/ReactEmptyComponent-test.js
1300 * should not produce child DOM nodes for null and false
1301 +* should be able to switch between rendering null and a normal tag
1302 +* should be able to switch in a list of children
1303 +* should distinguish between a script placeholder and an actual script tag
1304 * should have findDOMNode return null when multiple layers of composite components render to the same null placeholder
1305 * works when switching components
1306 * does not break when updating during mount
src/renderers/shared/fiber/ReactFiberTreeReflection.js
+6
@@ -85,6 +85,12 @@ exports.findCurrentHostFiber = function(parent : Fiber) : Fiber | null {
85
86 let didTryOtherTree = false;
87
88 + // If the component doesn't have a child we first check the alternate to see
89 + // if it has any and if so, if those were just recently inserted.
90 + if (!parent.child && parent.alternate) {
91 + parent = parent.alternate;
92 + }
93 +
94 // Next we'll drill down this component to find the first HostComponent/Text.
95 let node : Fiber = parent;
96 while (true) {