[dojo-contributors] Prototype-al simplicity

Scott J. Miles sjmiles at turbophp.com
Fri Apr 7 14:12:52 EDT 2006

Yes, there are frequently situations were 'weird cases' are there for a
specific reason, so we have to be really careful.
But in Bill's particular example, the return value stuff and error exception
seems unusual, and I agree that there is a lot of removable cruft like that.
Maybe this is too specific for this conversation, but in general we don't
have rules regarding error checking. Most of the style.js functions don't
test for bad node input. Obviously some do. I suspect we need some
>> And in some cases (when the calling code needs both width and height),
performance will probably improve.

Sure, but the converse is also true. 

Scott J. Miles
TurboAjax Group

From: dojo-contributors-bounces at dojotoolkit.org
[mailto:dojo-contributors-bounces at dojotoolkit.org] On Behalf Of Tom Trenka
Sent: Friday, April 07, 2006 10:40 AM
To: dojo dev.
Subject: Re: [dojo-contributors] Prototype-al simplicity

IIRC some of that weird case handling is there for a reason, but yeah, that
would be another good place to start.

On 4/7/06, Bill Keese < bill at dojotoolkit.org <mailto:bill at dojotoolkit.org> >

	Tom Trenka wrote:
	> For instance, instead of: 
	>     getViewportWidth
	>     getViewportHeight
	> ...we'd have this:
	> object getViewportSize
	> ...where the return object would look like:
	> { width:..., height:... } 
	That probably makes sense.  And in some cases (when the calling code
	needs both width and height), performance will probably improve.
	A few other things:
	  - lots of deprecated functions that can be removed 
	  - coordinates are handled both as an array [5,7] and an object {w:
	h: 7}.  Just an object should be sufficient.
	Just in general I would take error checking and weird case handling
	of functions.  For example, here is a current setClass() function: 
	dojo.html.setClass = function(node, classStr){
	        node = dojo.byId(node);
	        if(!node){ return false; }
	        var cs = new String(classStr);
	                if(typeof node.className == "string"){
	                        node.className = cs;
	                }else if(node.setAttribute){
	                        node.setAttribute("class", classStr);
	                         node.className = cs;
	                        return false;
	                dojo.debug("dojo.html.setClass() failed", e);
	        return true;
	I'm tempted to rewrite it as below:
	dojo.html.setClass = function(node, classStr){
	        node = dojo.byId(node);
	        if(typeof node.className == "string"){
	                node.className = cs;
	                node.setAttribute("class", classStr);

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.0/304 - Release Date: 4/7/2006

More information about the dojo-contributors mailing list