@samitouri / QOS-React / commits / 2f893b5914

Revert normalized text node fix (#8231)

This reverts the implementation in 33325ad0097e0689fd415703a1a7c1665629be7e. I didn't mean to merge the implementation since it is incorrect and incomplete. I meant to just merge the unit test.

Sebastian Markbåge committed Nov 7, 2016 at 18:27 UTC 2f893b5914b30aae7c7ce79c410f9c4dc71dbda3
5 files changed +6 -33
scripts/fiber/tests-failing.txt
+3
@@ -189,6 +189,9 @@ src/renderers/dom/shared/__tests__/ReactDOMInvalidARIAHook-test.js
189
190 src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
191 * can reconcile text merged by Node.normalize() alongside other elements
192 +* can reconcile text merged by Node.normalize()
193 +* can reconcile text arbitrarily split into multiple nodes
194 +* can reconcile text arbitrarily split into multiple nodes on some substitutions only
195
196 src/renderers/dom/shared/__tests__/ReactEventIndependence-test.js
197 * does not crash with other react inside
scripts/fiber/tests-passing.txt
-3
@@ -539,10 +539,7 @@ src/renderers/dom/shared/__tests__/ReactDOMSVG-test.js
539 src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
540 * updates a mounted text component in place
541 * can be toggled in and out of the markup
542 -* can reconcile text merged by Node.normalize()
542 * can reconcile text from pre-rendered markup
544 -* can reconcile text arbitrarily split into multiple nodes
545 -* can reconcile text arbitrarily split into multiple nodes on some substitutions only
543
544 src/renderers/dom/shared/__tests__/ReactEventListener-test.js
545 * should dispatch events from outside React tree
src/renderers/dom/fiber/ReactDOMFiber.js
+1 -28
@@ -13,11 +13,9 @@
13 'use strict';
14
15 import type { HostChildren } from 'ReactFiberReconciler';
16 -import type { Fiber } from 'ReactFiber';
16
17 var ReactFiberReconciler = require('ReactFiberReconciler');
18 var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
20 -var ReactTypeOfWork = require('ReactTypeOfWork');
19
20 var warning = require('warning');
21
@@ -90,33 +88,8 @@ var DOMRenderer = ReactFiberReconciler({
88 return document.createTextNode(text);
89 },
90
93 - commitTextUpdate(textInstance : TextInstance, oldText : string, newText : string, current: ?Fiber) : void {
94 - let nodeValueLen = textInstance.nodeValue.length;
95 - let nextSibling : ?Node = textInstance.nextSibling;
96 - // The Node may have been split in this case we need to clean up some next sibling nodes
97 - while (nextSibling && nodeValueLen < oldText.length) {
98 - const currentSibling : Node = nextSibling;
99 - nextSibling = currentSibling.nextSibling;
100 - nodeValueLen += currentSibling.nodeValue.length;
101 - const parentNode = currentSibling.parentElement;
102 - if (parentNode) {
103 - parentNode.removeChild(currentSibling);
104 - }
105 - }
91 + commitTextUpdate(textInstance : TextInstance, oldText : string, newText : string) : void {
92 textInstance.nodeValue = newText;
107 - // After a Node#normalize() on a parent, we need to reattach to the tree
108 - if (!textInstance.parentNode) {
109 - // We may need to go back through different types of work (not necessarily an host node)
110 - // That's why, we're going up the stack testing for an HostComponent type of work
111 - let parentFiber: ?Fiber = current && current.return;
112 - while (parentFiber) {
113 - if (parentFiber.tag === ReactTypeOfWork.HostComponent) {
114 - (parentFiber.stateNode: Instance).appendChild(textInstance);
115 - break;
116 - }
117 - parentFiber = parentFiber.return;
118 - }
119 - }
93 },
94
95 appendChild(parentInstance : Instance, child : Instance | TextInstance) : void {
src/renderers/shared/fiber/ReactFiberCommitWork.js
+1 -1
@@ -288,7 +288,7 @@ module.exports = function<T, P, I, TI, C>(
288 const textInstance : TI = finishedWork.stateNode;
289 const newText : string = finishedWork.memoizedProps;
290 const oldText : string = current.memoizedProps;
291 - commitTextUpdate(textInstance, oldText, newText, current);
291 + commitTextUpdate(textInstance, oldText, newText);
292 return;
293 }
294 default:
src/renderers/shared/fiber/ReactFiberReconciler.js
+1 -1
@@ -49,7 +49,7 @@ export type HostConfig<T, P, I, TI, C> = {
49 commitUpdate(instance : I, oldProps : P, newProps : P) : void,
50
51 createTextInstance(text : string) : TI,
52 - commitTextUpdate(textInstance : TI, oldText : string, newText : string, parentInstance: ?Fiber) : void,
52 + commitTextUpdate(textInstance : TI, oldText : string, newText : string) : void,
53
54 appendChild(parentInstance : I, child : I | TI) : void,
55 insertBefore(parentInstance : I, child : I | TI, beforeChild : I | TI) : void,