[FIX] components: cascading render after microtaskTick (makeChildFiber)

Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: François Georis <fge@odoo.com>
This commit is contained in:
Lucas Perais (lpe)
2022-01-18 16:46:36 +01:00
committed by Aaron Bohy
parent 2a5f37cf4b
commit 374dbb2fd9
6 changed files with 111 additions and 46 deletions
+5 -5
View File
@@ -121,7 +121,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
async initiateRender(fiber: Fiber | MountFiber) {
this.fiber = fiber;
if (this.mounted.length) {
fiber.root.mounted.push(fiber);
fiber.root!.mounted.push(fiber);
}
const component = this.component;
try {
@@ -137,7 +137,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
async render() {
let current = this.fiber;
if (current && current.root.locked) {
if (current && current.root!.locked) {
await Promise.resolve();
// situation may have changed after the microtask tick
current = this.fiber;
@@ -167,7 +167,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
// a root fiber to a child fiber in the previous microtick, because it was
// embedded in a rendering coming from above, so the fiber will be rendered
// in the next microtick anyway, so we should not render it again.
if (this.fiber && (current || !fiber.parent)) {
if (this.fiber === fiber && (current || !fiber.parent)) {
this._render(fiber);
}
}
@@ -175,7 +175,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
_render(fiber: Fiber | RootFiber) {
try {
fiber.bdom = this.renderFn();
fiber.root.counter--;
fiber.root!.counter--;
} catch (e) {
handleError({ node: this, error: e });
}
@@ -218,7 +218,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
}
component.props = props;
this._render(fiber);
const parentRoot = parentFiber.root;
const parentRoot = parentFiber.root!;
if (this.willPatch.length) {
parentRoot.willPatch.push(fiber);
}