mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] components: cascading render after microtaskTick (makeChildFiber)
Co-authored-by: Samuel Degueldre <sad@odoo.com> Co-authored-by: François Georis <fge@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
parent
2a5f37cf4b
commit
374dbb2fd9
@@ -3082,6 +3082,53 @@ test("t-foreach with dynamic async component", async () => {
|
||||
"Child (3):mounted",
|
||||
]).toBeLogged();
|
||||
});
|
||||
|
||||
test("Cascading renders after microtaskTick", async () => {
|
||||
const state = [{ id: 0 }, { id: 1 }];
|
||||
let child: any;
|
||||
let parent: any;
|
||||
|
||||
class Element extends Component {
|
||||
static template = xml`<t t-esc="props.id" />`;
|
||||
}
|
||||
|
||||
class Child extends Component {
|
||||
static components = { Element };
|
||||
static template = xml`
|
||||
<t t-foreach="state" t-as="elem" t-key="elem.id">
|
||||
<Element id="elem.id"/>
|
||||
</t>`;
|
||||
state = state;
|
||||
setup() {
|
||||
child = this;
|
||||
}
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static components = { Child };
|
||||
static template = xml`<Child /> _ <t t-foreach="state" t-as="elem" t-key="elem.id" t-esc="elem.id"/>`;
|
||||
state = state;
|
||||
setup() {
|
||||
parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
await mount(Parent, fixture);
|
||||
expect(fixture.innerHTML).toBe("01 _ 01");
|
||||
|
||||
state.push({ id: 2 });
|
||||
parent.render();
|
||||
child.render();
|
||||
|
||||
await Promise.resolve();
|
||||
expect(fixture.innerHTML).toBe("01 _ 01");
|
||||
state.push({ id: 3 });
|
||||
parent.render();
|
||||
child.render();
|
||||
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("0123 _ 0123");
|
||||
});
|
||||
// test.skip("components with shouldUpdate=false", async () => {
|
||||
// const state = { p: 1, cc: 10 };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user