@samitouri / QOS-React / commits / 29dbbc31c9

UpdateQueue fixes

- Incorrect comparison when computing hasUpdate - isReplace should be a property of the node, not the queue

Andrew Clark committed Nov 2, 2016 at 23:00 UTC 29dbbc31c9240c959e20735fa9386545f4e8950b
3 files changed +9 -5
scripts/fiber/tests-failing.txt
+3
@@ -87,6 +87,9 @@ src/renderers/art/__tests__/ReactART-test.js
87 * resolves refs before componentDidMount
88 * resolves refs before componentDidUpdate
89
90 +src/renderers/dom/__tests__/ReactDOMProduction-test.js
91 +* should throw with an error code in production
92 +
93 src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
94 * should set style attribute when styles exist
95 * should warn when using hyphenated style names
scripts/fiber/tests-passing.txt
-1
@@ -438,7 +438,6 @@ src/renderers/dom/__tests__/ReactDOMProduction-test.js
438 * should use prod React
439 * should handle a simple flow
440 * should call lifecycle methods
441 -* should throw with an error code in production
441
442 src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
443 * should render strings as children
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+6 -4
@@ -16,11 +16,11 @@ type UpdateQueueNode = {
16 partialState: any,
17 callback: ?Function,
18 callbackWasCalled: boolean,
19 + isReplace: boolean,
20 next: ?UpdateQueueNode,
21 };
22
23 export type UpdateQueue = UpdateQueueNode & {
23 - isReplace: boolean,
24 isForced: boolean,
25 hasUpdate: boolean,
26 hasCallback: boolean,
@@ -32,8 +32,8 @@ exports.createUpdateQueue = function(partialState : mixed) : UpdateQueue {
32 partialState,
33 callback: null,
34 callbackWasCalled: false,
35 - next: null,
35 isReplace: false,
36 + next: null,
37 isForced: false,
38 hasUpdate: partialState != null,
39 hasCallback: false,
@@ -48,11 +48,12 @@ function addToQueue(queue : UpdateQueue, partialState : mixed) : UpdateQueue {
48 partialState,
49 callback: null,
50 callbackWasCalled: false,
51 + isReplace: false,
52 next: null,
53 };
54 queue.tail.next = node;
55 queue.tail = node;
55 - queue.hasUpdate = queue.hasUpdate || (partialState == null);
56 + queue.hasUpdate = queue.hasUpdate || (partialState != null);
57 return queue;
58 }
59
@@ -86,8 +87,9 @@ exports.callCallbacks = function(queue : UpdateQueue, context : any) {
87
88 exports.mergeUpdateQueue = function(queue : UpdateQueue, instance : any, prevState : any, props : any) : any {
89 let node : ?UpdateQueueNode = queue;
89 - let state = queue.isReplace ? null : Object.assign({}, prevState);
90 + let state = Object.assign({}, prevState);
91 while (node) {
92 + state = node.isReplace ? null : state;
93 let partialState;
94 if (typeof node.partialState === 'function') {
95 const updateFn = node.partialState;