mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] components: wrap onWillRender/onRendered hooks instead of renderFn
Previously, we were wrapping the entire renderFn in a try/catch, causing errors during template execution to be caught and wrapped by onWillRender/onRendered which is undesirable. Now we only wrap the hook that's being registered.
This commit is contained in:
committed by
Géry Debongnie
parent
14d2328c88
commit
67f86a4ab8
@@ -77,21 +77,23 @@ export function onWillRender(fn: () => void | any) {
|
||||
const node = getCurrent();
|
||||
const renderFn = node.renderFn;
|
||||
const decorate = node.app.dev ? wrapError : (fn: any) => fn;
|
||||
node.renderFn = decorate(() => {
|
||||
fn.call(node.component);
|
||||
fn = decorate(fn.bind(node.component), "onWillRender");
|
||||
node.renderFn = () => {
|
||||
fn();
|
||||
return renderFn();
|
||||
}, "onWillRender");
|
||||
};
|
||||
}
|
||||
|
||||
export function onRendered(fn: () => void | any) {
|
||||
const node = getCurrent();
|
||||
const renderFn = node.renderFn;
|
||||
const decorate = node.app.dev ? wrapError : (fn: any) => fn;
|
||||
node.renderFn = decorate(() => {
|
||||
fn = decorate(fn.bind(node.component), "onRendered");
|
||||
node.renderFn = () => {
|
||||
const result = renderFn();
|
||||
fn.call(node.component);
|
||||
fn();
|
||||
return result;
|
||||
}, "onRendered");
|
||||
};
|
||||
}
|
||||
|
||||
type OnErrorCallback = (error: any) => void | any;
|
||||
|
||||
Reference in New Issue
Block a user