mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: solve a tricky concurrency rendering issue
When components were initially rendered more than once, in consecutive microtask ticks, the order of two actions was reversed: the assignation of the vnode to the __owl__.vnode property, and the assignation of __owl__.vnode to the final rendered vdom of the component. As a result, the widget was rendered as null (so, not present). The reason for this issue was that the renderPromise key was reassigned at some point.
This commit is contained in:
@@ -49,8 +49,13 @@ export interface Meta<T extends Env, Props> {
|
||||
cmap: { [key: number]: number };
|
||||
|
||||
renderId: number;
|
||||
|
||||
// the renderProps and renderPromise keys are only useful for the "prepare"
|
||||
// step of the lifecycle of a component. Once a component has been rendered
|
||||
// and patched, it is no longer useful.
|
||||
renderProps: Props | null;
|
||||
renderPromise: Promise<VNode> | null;
|
||||
|
||||
boundHandlers: { [key: number]: any };
|
||||
observer?: Observer;
|
||||
render?: CompiledTemplate;
|
||||
@@ -447,7 +452,6 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
|
||||
|
||||
__patch(vnode) {
|
||||
const __owl__ = this.__owl__;
|
||||
__owl__.renderPromise = null;
|
||||
const target = __owl__.vnode || document.createElement(vnode.sel!);
|
||||
if (this.__owl__.classObj) {
|
||||
(<any>vnode).data.class = Object.assign((<any>vnode).data.class || {}, this.__owl__.classObj);
|
||||
@@ -544,9 +548,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
|
||||
// parent component. With this, we make sure that the parent component will be
|
||||
// able to patch itself properly after
|
||||
vnode.key = __owl__.id;
|
||||
__owl__.renderProps = this.props;
|
||||
__owl__.renderPromise = Promise.all(promises).then(() => vnode);
|
||||
return __owl__.renderPromise;
|
||||
return Promise.all(promises).then(() => vnode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user