knockout / tko

🥊 Technical Knockout – The Monorepo for Knockout.js (4.0+)
http://www.tko.io
Other
274 stars 34 forks source link

If you have multiple || (ORs), you need parentheses, otherwise it fails silently #186

Closed t-oster closed 1 year ago

t-oster commented 1 year ago

See this jsfiddle:

https://jsfiddle.net/myujpn9t/

Does not work for c: <span data-bind="visible: x == 'a' || x == 'b' || x == 'c'">OK</span> Works: <span data-bind="visible: (x == 'a' || x == 'b') || x == 'c'">OK</span>

If you type a or b, it works. If you type c, the first binding does not work:

danieldickison commented 1 year ago

This has always been the behavior in knockout, but given that tko does its own parsing of bindings, maybe we can call unwrap on terminal variable references automatically without creating much of a backwards incompatibility?

t-oster commented 1 year ago

I think you misunderstood my question. However the jsfiddle had an error. So compare this one: https://jsfiddle.net/ba3s9zux/4/ (kto) with this one: https://jsfiddle.net/bzndakhx/ (knockout 3)

If the value of x is 'c', the first variant evaluates to false in kto, while it should be true.

danieldickison commented 1 year ago

This was fixed in #151 — try a newer build: https://cdn.jsdelivr.net/npm/@tko/build.reference@4.0.0-beta1.5/dist/build.reference.min.js

t-oster commented 1 year ago

Ok, sorry I used the Version Linked in the readme.