[FIX] component: t-model properly works with select

The initial value was not set on the select tag.

closes #271
This commit is contained in:
Géry Debongnie
2019-09-04 22:43:17 +02:00
parent c52799de2c
commit 3c23a7b246
3 changed files with 27 additions and 1 deletions
+2 -1
View File
@@ -248,12 +248,13 @@ QWeb.utils.toNumber = function(val: string): number | string {
QWeb.addDirective({
name: "model",
priority: 42,
atNodeCreation({ ctx, nodeID, value, node, fullName }) {
atNodeCreation({ ctx, nodeID, value, node, fullName, addNodeHook }) {
const type = node.getAttribute("type");
let handler;
let event = fullName.includes(".lazy") ? "change" : "input";
if (node.tagName === "select") {
ctx.addLine(`p${nodeID}.props = {value: context.state['${value}']};`);
addNodeHook('create', `n.elm.value=context.state['${value}'];`)
event = "change";
handler = `(ev) => {context.state['${value}'] = ev.target.value}`;
} else if (type === "checkbox") {