adityapooniya / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

jsb.behavior.get() doesn't handle boolean attributes correctly #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Hi again,

Just a problem I saw in the get() method when getting a boolean value: it
treats boolean values as HTML treats boolean attributes: it always return
true if the attribute is here.

However this makes this use-case impossible:
- Value is true if no attribute
- People can switch to false with attr="0" or something like this

Thus, I think the "return true" for boolean values could be advantageously
changed to:

return ( value == "0"  || value.toLowerCase()=="off" ) ? false : true;

esc0-

PS: Forgot to mention in my previous report: I work using a 48hrs old svn
trunk.

Original issue reported on code.google.com by mesco...@gmail.com on 12 Jun 2009 at 9:26

GoogleCodeExporter commented 9 years ago
If you define the default value of the attribute as a boolean then the 
attribute value 
defined on the element will be cast to boolean. If you want to use other values 
like 
on/off then you will have to override the get() method of your behavior.

Is this good enough?

Original comment by dean.edw...@gmail.com on 21 Jun 2009 at 4:02

GoogleCodeExporter commented 9 years ago
Sure, sounds good enough to me :)

Thanks

Original comment by mesco...@gmail.com on 22 Jun 2009 at 3:11

GoogleCodeExporter commented 9 years ago
Cool. Marked as "WontFix" then.

Original comment by dean.edw...@gmail.com on 23 Jun 2009 at 6:56