[FIX] qweb: add support for t-att-value on textareas

The code did not treat textareas in the same way as inputs. As a result,
using t-att-value on a textarea did not work.

closes #872
This commit is contained in:
Géry Debongnie
2021-07-03 08:08:30 +02:00
committed by aab-odoo
parent f4994a20d8
commit 52a200878a
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -705,7 +705,7 @@ export class QWeb extends EventBus {
isProp = key === "selected" || key === "disabled";
break;
case "textarea":
isProp = key === "readonly" || key === "disabled";
isProp = key === "readonly" || key === "disabled" || key === "value";
break;
case "button":
case "select":
+19
View File
@@ -1931,6 +1931,25 @@ describe("special cases for some specific html attributes/properties", () => {
let elm = vnode2.elm as HTMLInputElement;
expect(elm.indeterminate).toBe(true);
});
test("textarea with t-att-value", () => {
// render input with initial value
qweb.addTemplate("test", `<textarea t-att-value="v"/>`);
const vnode1 = qweb.render("test", { v: "zucchini" });
const vnode2 = patch(document.createElement("textarea"), vnode1);
let elm = vnode2.elm as HTMLInputElement;
expect(elm.value).toBe("zucchini");
// change value manually in textarea, to simulate user textarea
elm.value = "tomato";
expect(elm.value).toBe("tomato");
// rerender with a different value, and patch actual dom, to check that
// textarea value was properly reset by owl
const vnode3 = qweb.render("test", { v: "potato" });
patch(vnode2, vnode3);
expect(elm.value).toBe("potato");
});
});
describe("whitespace handling", () => {