[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:
Géry Debongnie
2022-01-11 09:39:26 +01:00
committed by Aaron Bohy
parent 4b170b9b45
commit 52d0526ddd
3 changed files with 81 additions and 9 deletions
+5 -9
View File
@@ -1,7 +1,6 @@
import type { ComponentNode } from "./component/component_node";
import { Component } from "./component/component";
import { xml } from "./app/template_set";
import { BDom, text, VNode } from "./blockdom";
import { Component } from "./component/component";
const VText: any = text("").constructor;
@@ -60,12 +59,9 @@ export class Portal extends Component {
slots: true,
};
constructor(props: any, env: any, node: ComponentNode) {
super(props, env, node);
node._render = function (fiber: any) {
const bdom = new VPortal(props.target, this.renderFn());
fiber.bdom = bdom;
fiber.root.counter--;
};
setup() {
const node = this.__owl__;
const renderFn = node.renderFn;
node.renderFn = () => new VPortal(this.props.target, renderFn());
}
}