[FIX] blockdom: fix event_catcher traceback

When a parent component has an empty child with a t-on
and an event is triggered inside the parent, blockdom
checks if there is an event_catcher to call.
Doing so, an empty child would cause an error.

This commit fixes that.
This commit is contained in:
Bruno Boi
2022-10-21 09:47:39 +02:00
committed by Géry Debongnie
parent 6f23b18cab
commit bd199971bd
3 changed files with 67 additions and 1 deletions
+24
View File
@@ -41,6 +41,30 @@ describe("t-on", () => {
expect(steps).toEqual(["click"]);
});
test("t-on when first component child is an empty component", async () => {
class Child extends Component {
static template = xml`
<span t-foreach="props.list" t-as="c" t-key="c_index" t-esc="c"/>
`;
}
class Parent extends Component {
static template = xml`
<div t-on-click="push"><Child list="list" t-on-click="() => {}"/></div>
`;
static components = { Child };
list = useState([] as string[]);
push() {
this.list.push("foo");
}
}
const parent = await mount(Parent, fixture);
const el = elem(parent);
expect(el.innerHTML).toBe("");
el.click();
await nextTick();
expect(el.innerHTML).toBe("<span>foo</span>");
});
test("t-on expression in t-foreach", async () => {
class Comp extends Component {
static template = xml`