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
@@ -68,6 +68,43 @@ describe("Portal", () => {
|
||||
expect(fixture.innerHTML).toBe('<div id="outside"><p>2</p></div><div><span>1</span></div>');
|
||||
});
|
||||
|
||||
test("simple catchError with portal", async () => {
|
||||
class Boom extends Component {
|
||||
static components = { Portal };
|
||||
static template = xml`
|
||||
<div>
|
||||
<span>1</span>
|
||||
<Portal target="'#outside'">
|
||||
<p><t t-esc="a.b.c"/></p>
|
||||
</Portal>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`
|
||||
<div>
|
||||
<t t-if="error">Error</t>
|
||||
<t t-else="">
|
||||
<Boom />
|
||||
</t>
|
||||
</div>`;
|
||||
static components = { Boom };
|
||||
|
||||
error: any = false;
|
||||
|
||||
setup() {
|
||||
onError((err) => {
|
||||
this.error = err;
|
||||
this.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
addOutsideDiv(fixture);
|
||||
|
||||
await mount(Parent, fixture);
|
||||
expect(fixture.innerHTML).toBe('<div id="outside"></div><div>Error</div>');
|
||||
});
|
||||
|
||||
test("basic use of portal in dev mode", async () => {
|
||||
class Parent extends Component {
|
||||
static components = { Portal };
|
||||
|
||||
Reference in New Issue
Block a user