UpdateQueue fixes

- Incorrect comparison when computing hasUpdate
- isReplace should be a property of the node, not the queue
This commit is contained in:
Andrew Clark
2016-11-02 23:00:00 -07:00
parent 3410ecadd1
commit 29dbbc31c9
3 changed files with 9 additions and 5 deletions
+3
View File
@@ -87,6 +87,9 @@ src/renderers/art/__tests__/ReactART-test.js
* resolves refs before componentDidMount
* resolves refs before componentDidUpdate
src/renderers/dom/__tests__/ReactDOMProduction-test.js
* should throw with an error code in production
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
* should set style attribute when styles exist
* should warn when using hyphenated style names
-1
View File
@@ -438,7 +438,6 @@ src/renderers/dom/__tests__/ReactDOMProduction-test.js
* should use prod React
* should handle a simple flow
* should call lifecycle methods
* should throw with an error code in production
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
* should render strings as children
@@ -16,11 +16,11 @@ type UpdateQueueNode = {
partialState: any,
callback: ?Function,
callbackWasCalled: boolean,
isReplace: boolean,
next: ?UpdateQueueNode,
};
export type UpdateQueue = UpdateQueueNode & {
isReplace: boolean,
isForced: boolean,
hasUpdate: boolean,
hasCallback: boolean,
@@ -32,8 +32,8 @@ exports.createUpdateQueue = function(partialState : mixed) : UpdateQueue {
partialState,
callback: null,
callbackWasCalled: false,
next: null,
isReplace: false,
next: null,
isForced: false,
hasUpdate: partialState != null,
hasCallback: false,
@@ -48,11 +48,12 @@ function addToQueue(queue : UpdateQueue, partialState : mixed) : UpdateQueue {
partialState,
callback: null,
callbackWasCalled: false,
isReplace: false,
next: null,
};
queue.tail.next = node;
queue.tail = node;
queue.hasUpdate = queue.hasUpdate || (partialState == null);
queue.hasUpdate = queue.hasUpdate || (partialState != null);
return queue;
}
@@ -86,8 +87,9 @@ exports.callCallbacks = function(queue : UpdateQueue, context : any) {
exports.mergeUpdateQueue = function(queue : UpdateQueue, instance : any, prevState : any, props : any) : any {
let node : ?UpdateQueueNode = queue;
let state = queue.isReplace ? null : Object.assign({}, prevState);
let state = Object.assign({}, prevState);
while (node) {
state = node.isReplace ? null : state;
let partialState;
if (typeof node.partialState === 'function') {
const updateFn = node.partialState;