[FIX] crash when rendering component before mounting

This commit makes sure that Owl does not crash when a component is
created, then updated (for example, with a (observed) state change), and
then, some moment later, mounted.

The initial render is not useful, because it is not linked to a mounting
action anyway.  And it caused issues such as a crash when Owl tried to
patch it to a non existing target
This commit is contained in:
Géry Debongnie
2021-01-19 10:49:21 +01:00
committed by aab-odoo
parent 71f545058b
commit dfc782599b
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -373,6 +373,9 @@ export class Component<Props extends {} = any, T extends Env = Env> {
async render(force: boolean = false): Promise<void> {
const __owl__ = this.__owl__;
const currentFiber = __owl__.currentFiber;
if (!__owl__.vnode && !currentFiber) {
return;
}
if (currentFiber && !currentFiber.isRendered && !currentFiber.isCompleted) {
return scheduler.addFiber(currentFiber.root);
}