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

Mike Wilcox mwilcox at sitepen.com
Sun Oct 19 17:00:56 EDT 2008

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
work: 650.968.8787 x218
cell:	  214.697.4872

More information about the dojo-contributors mailing list