mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: handle input value attribute as a property
Sometimes, HTML is slightly more subtle than what I initially expect. Rendering some html is simple, we have tags and attributes. However, once we add behaviour, then the situation is more complex: <input value="abc"/> is an input with an INITIAL value of "abc", but the attribute does not actually represent the CURRENT value of the input, which may be different if the user did change it. This is basically the difference between "attribute" and "property". So, when rendering html with owl, we sometimes want to actually set the property (current value), instead of the html attribute. This commit make sure that this is the case for inputs with the "value" attribute. closes #722
This commit is contained in:
+6
-3
@@ -668,7 +668,7 @@ export class QWeb extends EventBus {
|
||||
const props: string[] = [];
|
||||
const tattrs: number[] = [];
|
||||
|
||||
function handleBooleanProps(key, val) {
|
||||
function handleProperties(key, val) {
|
||||
let isProp = false;
|
||||
if (node.nodeName === "input" && key === "checked") {
|
||||
let type = (<Element>node).getAttribute("type");
|
||||
@@ -676,6 +676,9 @@ export class QWeb extends EventBus {
|
||||
isProp = true;
|
||||
}
|
||||
}
|
||||
if (node.nodeName === "input" && key === "value") {
|
||||
isProp = true;
|
||||
}
|
||||
if (node.nodeName === "option" && key === "selected") {
|
||||
isProp = true;
|
||||
}
|
||||
@@ -722,7 +725,7 @@ export class QWeb extends EventBus {
|
||||
name = '"' + name + '"';
|
||||
}
|
||||
attrs.push(`${name}: _${attID}`);
|
||||
handleBooleanProps(name, attID);
|
||||
handleProperties(name, attID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,7 +762,7 @@ export class QWeb extends EventBus {
|
||||
}
|
||||
ctx.addLine(`let _${attID} = ${formattedValue};`);
|
||||
attrs.push(`${attName}: _${attID}`);
|
||||
handleBooleanProps(attName, attID);
|
||||
handleProperties(attName, attID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user