[FIX] component: properly set currentFiber to null in all cases

Whenever a rendering is completed, we need to reset the currentFiber
to null to make sure all subsequent renderings will not be
confused.

However, the way it was done before this commit was wrong in a
specific situation: we resetted the currentFiber to null in the
patch method.  The idea was that this method was called every time
the component completes a rendering. But this is not true: it
can happen that a component is unmounted and remounted without
changes.  Then the component will be patched, but if there is no
change, it will not call recursively the patched methods of its
children.

So, we need to choose a better place to reset it to null.

closes #454
This commit is contained in:
Géry Debongnie
2019-11-13 17:11:42 +01:00
committed by aab-odoo
parent 55bb09ba1a
commit f2b3ebd1ec
3 changed files with 33 additions and 1 deletions
+1 -1
View File
@@ -451,6 +451,7 @@ export class Component<T extends Env, Props extends {}> {
}
}
__owl__.isMounted = true;
__owl__.currentFiber = null;
try {
this.mounted();
if (__owl__.mountedCB) {
@@ -526,7 +527,6 @@ export class Component<T extends Env, Props extends {}> {
const __owl__ = this.__owl__;
const target = __owl__.vnode || document.createElement(vnode.sel!);
__owl__.vnode = patch(target, vnode);
__owl__.currentFiber = null;
}
/**
+1
View File
@@ -163,6 +163,7 @@ export class Fiber {
const fiber = patchQueue[i];
component = fiber.component;
component.__patch(fiber.vnode);
component.__owl__.currentFiber = null;
}
try {
for (let i = patchLen - 1; i >= 0; i--) {