Always override priority level when visiting children

It is not possible for a child to have a higher priority level
than we're reconciling at, unless we intentionally want to
down-prioritize it.
This commit is contained in:
Sebastian Markbage authored and Sebastian Markbåge committed 2016-10-17 16:17:30 -04:00
1 parent 43645a6586
commit a98aba4d73
2 files changed
+22 -4

No files matched your search

@@ -148,10 +148,10 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
clone.sibling = null;
return clone;
} else {
if (fiber.pendingWorkPriority === NoWork ||
fiber.pendingWorkPriority > priority) {
fiber.pendingWorkPriority = priority;
}
// We override the pending priority even if it is higher, because if
// we're reconciling at a lower priority that means that this was
// down-prioritized.
fiber.pendingWorkPriority = priority;
fiber.effectTag = NoWork;
fiber.index = 0;
fiber.sibling = null;
@@ -417,6 +417,24 @@ describe('ReactIncremental', () => {
// after them which is not correct.
ReactNoop.flush();
expect(ops).toEqual(['Bar', 'Middle', 'Bar']);
ops = [];
// Let us try this again without fully finishing the first time. This will
// create a hanging subtree that is reconciling at the normal priority.
ReactNoop.render(<Foo text="foo" />);
ReactNoop.flushDeferredPri(40);
expect(ops).toEqual(['Foo', 'Bar']);
ops = [];
// This update will create a tree that aborts that work and down-prioritizes
// it. If the priority levels aren't down-prioritized correctly this may
// abort rendering of the down-prioritized content.
ReactNoop.render(<Foo text="bar" />);
ReactNoop.flush();
expect(ops).toEqual(['Foo', 'Bar', 'Bar']);
});
it('can reuse work done after being preempted', () => {