mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: dynamic value on inputs doesn't turn 0 into empty string
In #1161, we fixed blockdom treating 0 as falsy when patching a value, which would result in an empty attribute. It turns out that there is another place where we had the same fallback, which is when we compute a dynamic attribute value, so while blockdom had the ability to set the value to 0, when using a dynamic attribute value we would never give it 0 as a value. This commit changes the fallback strategy for dynamic attribute values to be the same as the one in blockdom. closes #1358
This commit is contained in:
committed by
Géry Debongnie
parent
276c8a0295
commit
a35b9814c0
@@ -580,8 +580,8 @@ export class CodeGenerator {
|
||||
if (attrName && isProp(ast.tag, attrName)) {
|
||||
// we force a new string or new boolean to bypass the equality check in blockdom when patching same value
|
||||
if (attrName === "value") {
|
||||
// When the expression is falsy, fall back to an empty string
|
||||
expr = `new String((${expr}) || "")`;
|
||||
// When the expression is falsy (except 0), fall back to an empty string
|
||||
expr = `new String((${expr}) === 0 ? 0 : ((${expr}) || ""))`;
|
||||
} else {
|
||||
expr = `new Boolean(${expr})`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user