[dev] [commits] Horde branch master updated. b2212fa6f30df255024a450c8b98491d1e03049d
Michael M Slusarz
slusarz at horde.org
Wed Apr 16 20:33:51 UTC 2014
Quoting Jan Schneider <jan at horde.org>:
>> commit f708a22e6ba28f52644df950adf1961ad96050ae
>> Author: Michael M Slusarz <slusarz at horde.org>
>> Date: Tue Apr 15 12:07:45 2014 -0600
>>
>> Correct fix
>>
>> Annoying, since this is not a checkbox, so we need to do extra work to
>> make sure we are doing a 0 <-> 1 conversion (since it is stored as a
>> string, not an integer, so it is a pain to flip the value since "0" is
>> not empty-ish in javascript).
>>
>> Making the value -1 is not correct, since this is expected to be 0 or 1.
>>
>> imp/js/compose-dimp.js | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> http://github.com/horde/horde/commit/f708a22e6ba28f52644df950adf1961ad96050ae
>
> My solution worked fine with 0/1 strings, because if used in an
> arithmetic calculation, those are converted to integers (or rather
> numbers first), i.e. what your ~~ is doing. The result is again
> either 1 or 0 this time as an integer, which is converted to a
> string by writing the attribute, i.e. what your ~~(! is doing. Maybe
> you confused $F() - 1 with 1 - $F() what it actually was?
Except $F() is not guaranteed to be a number (or even a string). And
"1 - true" will return NaN on at least some browsers (at least it used
to). So the only way of guaranteeing that you are performing integer
arithmetic is to explicitly convert the unknown value to an integer
using known methods rather than relying on the browser's unknown
internal type conversions.
It would be great if "Number(true) = 1", which is what we used to use.
But this failed on at least one browser that I know of, and that is
one failure too many.
michael
___________________________________
Michael Slusarz [slusarz at horde.org]
More information about the dev
mailing list