mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] blockdom: fix VHtml patching not setting its html correctly
This commit is contained in:
committed by
Aaron Bohy
parent
753d82149e
commit
1e8576ad40
@@ -61,6 +61,7 @@ class VHtml {
|
|||||||
// remove current content
|
// remove current content
|
||||||
this.remove();
|
this.remove();
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
this.html = other.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1217,6 +1217,20 @@ exports[`t-out in components can render list of t-out 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`t-out in components can switch the contents of two t-out repeatedly 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||||
|
let { safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2 = safeOutput(ctx['state'].a);
|
||||||
|
let b3 = safeOutput(ctx['state'].b);
|
||||||
|
return multi([b2, b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`t-out in components update properly on state changes 1`] = `
|
exports[`t-out in components update properly on state changes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1006,4 +1006,31 @@ describe("t-out in components", () => {
|
|||||||
"<div><b>one</b><b>one</b><b>two</b><b>two</b><b>tree</b><b>tree</b></div>"
|
"<div><b>one</b><b>one</b><b>two</b><b>two</b><b>tree</b><b>tree</b></div>"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("can switch the contents of two t-out repeatedly", async () => {
|
||||||
|
class Test extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<t t-out="state.a"/>
|
||||||
|
<t t-out="state.b"/>
|
||||||
|
`;
|
||||||
|
state = useState({
|
||||||
|
a: markup("<div>1</div>"),
|
||||||
|
b: markup("<div>2</div>"),
|
||||||
|
});
|
||||||
|
|
||||||
|
reverse() {
|
||||||
|
const { state } = this;
|
||||||
|
[state.a, state.b] = [state.b, state.a];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const comp = await mount(Test, fixture);
|
||||||
|
expect(fixture.innerHTML).toBe("<div>1</div><div>2</div>");
|
||||||
|
comp.reverse();
|
||||||
|
await nextTick();
|
||||||
|
expect(fixture.innerHTML).toBe("<div>2</div><div>1</div>");
|
||||||
|
comp.reverse();
|
||||||
|
await nextTick();
|
||||||
|
expect(fixture.innerHTML).toBe("<div>1</div><div>2</div>");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user