mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: properly supports svg
Snabbdom supports svg, but it adds the namespace at the creation of the virtual node. However, owl works slightly differently: it adds children after creating the parent virtual node. So, we need to actually call the addNS method after the children nodes have been created. As a bonus, this is slightly faster than snabbdom: we only check at template compilation time once if a node is a svg.
This commit is contained in:
@@ -1312,3 +1312,10 @@ describe("global template registration", () => {
|
||||
expect((vnode as any).children[0].text).toBe("global");
|
||||
});
|
||||
});
|
||||
|
||||
describe("properly support svg", () => {
|
||||
test("add proper namespace to svg", () => {
|
||||
qweb.addTemplate("test", `<svg width="100px" height="90px"><circle cx="50" cy="50" r="4" stroke="green" stroke-width="1" fill="yellow"/> </svg>`);
|
||||
expect(renderToString(qweb, "test")).toBe(`<svg width=\"100px\" height=\"90px\"><circle cx=\"50\" cy=\"50\" r=\"4\" stroke=\"green\" stroke-width=\"1\" fill=\"yellow\"></circle> </svg>`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user