[FIX] web: view compiler: generic tags are case insensitive

In html, tags are case-insensitive. However, owl templates aren't,
as nodes starting with a capital letter are considered as component
nodes (not html). This means that people can use capital letters in
form or kanban archs for html nodes and it should work.

Before this commit, it didn't, because the compiler kept the case
when generating the owl templates. For instance, an arch like
`<form><Div/></form/>` produced the error 'Cannot find the
definition of component "Div"'. This commit fixes the issue.

Part-of: odoo/odoo#108221
This commit is contained in:
Aaron Bohy
2022-12-19 16:49:03 +01:00
parent aa616d2880
commit 7095310672
3 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -398,7 +398,7 @@ export class ViewCompiler {
* @returns {Element}
*/
compileGenericNode(el, params) {
const compiled = createElement(el.nodeName);
const compiled = createElement(el.nodeName.toLowerCase());
const metaAttrs = ["modifiers", "attrs", "invisible", "readonly"];
for (const attr of el.attributes) {
if (metaAttrs.includes(attr.name)) {
@@ -295,6 +295,20 @@ QUnit.module("Views", (hooks) => {
assert.containsNone(target, "label.o_form_label_empty:contains(timmy)");
});
QUnit.test("generic tags are case insensitive", async function (assert) {
await makeView({
type: "form",
resModel: "partner",
serverData,
arch: `
<form>
<Div class="test">Hello</Div>
</form>`,
});
assert.containsOnce(target, "div.test");
});
QUnit.test("form view with a group that contains an invisible group", async function (assert) {
await makeView({
type: "form",
@@ -363,6 +363,22 @@ QUnit.module("Views", (hooks) => {
assert.containsOnce(target, ".o_kanban_record:contains(gnap)");
});
QUnit.test("generic tags are case insensitive", async function (assert) {
await makeView({
type: "kanban",
resModel: "partner",
serverData,
arch: `
<kanban>
<templates><t t-name="kanban-box">
<Div class="test">Hello</Div>
</t></templates>
</kanban>`,
});
assert.containsN(target, "div.test", 4);
});
QUnit.test("display full is supported on fields", async (assert) => {
await makeView({
type: "kanban",