mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: display correct error in some case
It could happen that a component would crash. But then, the __render code tried to copy the class properties into the vnode, which does not exist, creating a new error. So, the solution is to process the classObj only in the successful part of the render call, which then will not crash, so the normal error handling will occur.
This commit is contained in:
@@ -597,6 +597,13 @@ export class Component<T extends Env, Props extends {}> {
|
||||
throw new Error(`Rendering '${this.constructor.name}' did not return anything`);
|
||||
}
|
||||
fiber.vnode = vnode;
|
||||
// we apply here the class information described on the component by the
|
||||
// template (so, something like <MyComponent class="..."/>) to the actual
|
||||
// root vnode
|
||||
if (__owl__.classObj) {
|
||||
const data = vnode.data!;
|
||||
data.class = Object.assign(data.class || {}, __owl__.classObj);
|
||||
}
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -604,13 +611,6 @@ export class Component<T extends Env, Props extends {}> {
|
||||
__owl__.observer.allowMutations = true;
|
||||
}
|
||||
|
||||
// we apply here the class information described on the component by the
|
||||
// template (so, something like <MyComponent class="..."/>) to the actual
|
||||
// root vnode
|
||||
if (__owl__.classObj) {
|
||||
const data = fiber.vnode!.data!;
|
||||
data.class = Object.assign(data.class || {}, __owl__.classObj);
|
||||
}
|
||||
fiber.root.counter--;
|
||||
fiber.isRendered = true;
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user