mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] portal: properly handle errors
Before this commit, Portal overrode the _render function for its component node, which means it bypassed the error handling mechanism that was implemented in that method. It could have been fixed by duplicating the error handling code as well, but a better solution in my opinion is to simply override the renderFn function. This is closer to the actual intent of the portal implementation: wrap the result of the rendering in a VPortal vnode.
This commit is contained in:
committed by
Aaron Bohy
parent
4b170b9b45
commit
52d0526ddd
@@ -409,6 +409,45 @@ exports[`Portal portal's parent's env is not polluted 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`Portal simple catchError with portal 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2,b3;
|
||||
if (ctx['error']) {
|
||||
b2 = text(\`Error\`);
|
||||
} else {
|
||||
b3 = component(\`Boom\`, {}, key + \`__1\`, node, ctx);
|
||||
}
|
||||
return block1([], [b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`Portal simple catchError with portal 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
|
||||
let block2 = createBlock(\`<p><block-text-0/></p>\`);
|
||||
|
||||
function slot1(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['a'].b.c;
|
||||
return block2([txt1]);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`Portal with target in template (after portal) 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user