@samitouri / QOS-React-2 / commits / 685d65bfb6

No duck typing on the root

The root is always a host container.

Sebastian Markbage committed Oct 11, 2016 at 11:13 UTC 685d65bfb646ceb9a7eb8921b72ad22e09de0033
1 file changed +11 -7
src/renderers/shared/fiber/ReactFiberScheduler.js
+11 -7
@@ -38,6 +38,10 @@ var {
38 Deletion,
39 } = require('ReactTypeOfSideEffect');
40
41 +var {
42 + HostContainer,
43 +} = require('ReactTypeOfWork');
44 +
45 var timeHeuristicForUnitOfWork = 1;
46
47 module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
@@ -399,14 +403,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
403 fiber.alternate.pendingWorkPriority = priorityLevel;
404 }
405 }
402 - // Duck type root
403 - if (fiber.stateNode && fiber.stateNode.containerInfo) {
404 - const root : FiberRoot = (fiber.stateNode : any);
405 - scheduleDeferredWork(root, priorityLevel);
406 - return;
407 - }
406 if (!fiber.return) {
409 - throw new Error('No root!');
407 + if (fiber.tag === HostContainer) {
408 + const root : FiberRoot = (fiber.stateNode : any);
409 + scheduleDeferredWork(root, priorityLevel);
410 + return;
411 + } else {
412 + throw new Error('Invalid root');
413 + }
414 }
415 fiber = fiber.return;
416 }