Verify boolena bindings
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 16 May 2013 13:40:26 +0200
changeset 12166eab20a4249f
parent 1215 c5a3a05a1b2e
child 1217 9c5b5d8ee4bb
Verify boolena bindings
ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java
     1.1 --- a/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java	Wed May 15 11:45:03 2013 +0200
     1.2 +++ b/ko-bck2brwsr/src/main/java/org/apidesign/html/ko2brwsr/Knockout.java	Thu May 16 13:40:26 2013 +0200
     1.3 @@ -78,14 +78,15 @@
     1.4            "var bnd = {\n"
     1.5          + "  'read': function() {\n"
     1.6          + "    var v = model[getter]();\n"
     1.7 -        + "    if (array) v = v.koArray();\n"
     1.8 +        + "    if (array) v = v.koArray(); else if (v !== null) v = v.valueOf();\n"
     1.9          + "    return v;\n"
    1.10          + "  },\n"
    1.11          + "  'owner': bindings\n"
    1.12          + "};\n"
    1.13          + "if (setter != null) {\n"
    1.14          + "  bnd['write'] = function(val) {\n"
    1.15 -        + "    model[setter](primitive ? new Number(val) : val);\n"
    1.16 +        + "    var v = val === null ? null : val.valueOf();"
    1.17 +        + "    model[setter](v);\n"
    1.18          + "  };\n"
    1.19          + "}\n"
    1.20          + "bindings[prop] = ko['computed'](bnd);"