mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] svg: allow path as root tag
This commit is contained in:
committed by
Aaron Bohy
parent
1e8576ad40
commit
a4d9aae9a7
@@ -52,6 +52,35 @@ exports[`properly support svg namespace to svg tags added even if already in svg
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`properly support svg svg namespace added to sub templates if root tag is path 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
const callTemplate_1 = getTemplate(\`path\`);
|
||||
|
||||
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><block-child-0/></svg>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`properly support svg svg namespace added to sub templates if root tag is path 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<path block-ns=\\"http://www.w3.org/2000/svg\\"/>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`properly support svg svg namespace added to sub-blocks 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { renderToString, renderToBdom, snapshotEverything, makeTestFixture } from "../helpers";
|
||||
import { mount } from "../../src/blockdom";
|
||||
import { mount as mountComponent, Component } from "../../src/index";
|
||||
|
||||
// NB: check the snapshots to see where the SVG namespaces are added
|
||||
snapshotEverything();
|
||||
|
||||
@@ -52,4 +54,24 @@ describe("properly support svg", () => {
|
||||
expect(el.namespaceURI).toBe("http://www.w3.org/2000/svg");
|
||||
}
|
||||
});
|
||||
|
||||
test("svg namespace added to sub templates if root tag is path", async () => {
|
||||
const templates = `<t>
|
||||
<t t-name="svg"><svg><t t-call="path" /></svg></t>
|
||||
<t t-name="path"><path /></t>
|
||||
</t>
|
||||
`;
|
||||
const fixture = makeTestFixture();
|
||||
|
||||
class Svg extends Component {
|
||||
static template = "svg";
|
||||
}
|
||||
|
||||
await mountComponent(Svg, fixture, { templates });
|
||||
const elems = fixture.querySelectorAll("svg, path");
|
||||
expect(elems.length).toEqual(2);
|
||||
for (const el of elems) {
|
||||
expect(el.namespaceURI).toBe("http://www.w3.org/2000/svg");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user