mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: strict check of deep argument truth value
With this commit, we make sure that the `render` method was explicitely called with the deep === true argument, instead of assuming that it is a boolean. This prevents errors when some unrelated value is given to the render method. This could happen in some cases, such as useBus(someBus, 'someevent', this.render) In that case, the `useBus` code would simply call the this.render with a customevent, which would be considered truthy before, and not anymore
This commit is contained in:
committed by
Sam Degueldre
parent
1179e84971
commit
7d14db7d31
@@ -102,6 +102,43 @@ describe("rendering semantics", () => {
|
||||
expect(childN).toBe(2);
|
||||
});
|
||||
|
||||
test("render need a boolean = true to be 'deep'", async () => {
|
||||
let childN = 0;
|
||||
let parentN = 0;
|
||||
class Child extends Component {
|
||||
static template = xml`child`;
|
||||
setup() {
|
||||
onRendered(() => childN++);
|
||||
}
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`
|
||||
<t t-esc="state.value"/>
|
||||
<Child/>
|
||||
`;
|
||||
static components = { Child };
|
||||
|
||||
state = { value: "A" };
|
||||
setup() {
|
||||
onRendered(() => parentN++);
|
||||
}
|
||||
}
|
||||
|
||||
const parent = await mount(Parent, fixture);
|
||||
|
||||
expect(fixture.innerHTML).toBe("Achild");
|
||||
expect(parentN).toBe(1);
|
||||
expect(childN).toBe(1);
|
||||
|
||||
parent.state.value = "B";
|
||||
parent.render("true" as any as boolean);
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("Bchild");
|
||||
expect(parentN).toBe(2);
|
||||
expect(childN).toBe(1);
|
||||
});
|
||||
|
||||
test("render with deep=true followed by render with deep=false work as expected", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`child<t t-esc="env.getValue()"/>`;
|
||||
|
||||
Reference in New Issue
Block a user