mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] components: crash when using unknown suffix/modifiers
This commit is contained in:
committed by
Aaron Bohy
parent
a2e8abc243
commit
89d63ff29a
@@ -122,7 +122,7 @@ exports[`basics support prop names that aren't valid bare object property names
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return component(\`Child\`, {'some-dashed-prop': 5,'a.b': 'keyword prop'}, key + \`__1\`, node, ctx);
|
||||
return component(\`Child\`, {'some-dashed-prop': 5}, key + \`__1\`, node, ctx);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -142,17 +142,16 @@ describe("basics", () => {
|
||||
});
|
||||
|
||||
test("support prop names that aren't valid bare object property names", async () => {
|
||||
expect.assertions(4);
|
||||
expect.assertions(3);
|
||||
class Child extends Component {
|
||||
static template = xml`<button t-on-click="props.onClick"/>`;
|
||||
setup() {
|
||||
expect(this.props["some-dashed-prop"]).toBe(5);
|
||||
expect(this.props["a.b"]).toBe("keyword prop");
|
||||
}
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`<Child some-dashed-prop="5" a.b="'keyword prop'"/>`;
|
||||
static template = xml`<Child some-dashed-prop="5"/>`;
|
||||
static components = { Child };
|
||||
}
|
||||
await mount(Parent, fixture);
|
||||
@@ -225,3 +224,18 @@ test("bound functions is referentially equal after update", async () => {
|
||||
expect(fixture.innerHTML).toBe("3");
|
||||
expect(isEqual).toBe(true);
|
||||
});
|
||||
|
||||
test("throw if prop uses an unknown suffix", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`<t t-esc="props.val"/>`;
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`<Child val.somesuffix="state.val"/>`;
|
||||
static components = { Child };
|
||||
}
|
||||
|
||||
await expect(async () => {
|
||||
await mount(Parent, fixture);
|
||||
}).rejects.toThrowError("Invalid prop suffix");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user