[dojo-contributors] dojo.attr() does not return a number

Mike Wilcox mwilcox at sitepen.com
Mon Oct 20 07:34:58 EDT 2008


Yep, you're right. I totally blanked on percent. That does make things  
trickier.

Mike

On Oct 19, 2008, at 9:46 PM, Adam L. Peller wrote:

> The simple thing to do, and the behavior most consistent with the  
> DOM APIs, is to just return string.  The alternative seems a bit  
> magical and may need to handle boolean or floats too (and not all  
> HTML types correspond to JS types, like %) It would seem that most  
> callers wouldn't need this extra processing, and there's some bloat  
> involved, so I'd lean towards keeping it simple.  It's a relatively  
> easy operation for the caller to do a type check and the caller may  
> wish to do the check anyways.
>
> -Adam
>
> On Sun, Oct 19, 2008 at 5:00 PM, Mike Wilcox <mwilcox at sitepen.com>  
> wrote:
> I'm working on a blog for SitePen on dojo.attr and dojo.style. I
> noticed that dojo.attr does not return a number. A number would be
> convenient for attributes like tabIndex or table.width.
>
> Through some light testing, it appears that adding something along
> these lines would work:
>
> if( parseInt(attribute) == Number(attribute) ){
>        return parseInt(attribute);
> }
>
> This seems to work in all the cases I can think of, although there are
> a ton of use cases for this, so I may be missing something that makes
> this a bad idea.
>
> The one exception I would think is if the attribute name were 'value'.
>
> Mike Wilcox
> mwilcox at sitepen.com
> http://www.sitepen.com
> work: 650.968.8787 x218
> cell:     214.697.4872
>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-contributors
>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-contributors

Mike Wilcox
mwilcox at sitepen.com
http://www.sitepen.com
work: 650.968.8787 x218
cell:	  214.697.4872

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20081020/5b6bcf7a/attachment.htm 


More information about the dojo-contributors mailing list