[dojo-contributors] Prototype-al simplicity

Tom Trenka ttrenka at gmail.com
Fri Apr 7 13:39:52 EDT 2006


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> wrote:
>
> 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: 5,
> h: 7}.  Just an object should be sufficient.
>
>
> Just in general I would take error checking and weird case handling out
> 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);
>         try{
>                 if(typeof node.className == "string"){
>                         node.className = cs;
>                 }else if(node.setAttribute){
>                         node.setAttribute("class", classStr);
>                         node.className = cs;
>                 }else{
>                         return false;
>                 }
>         }catch(e){
>                 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;
>         }else{
>                 node.setAttribute("class", classStr);
>         }
> }
>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20060407/df3d0b9a/attachment.htm 


More information about the dojo-contributors mailing list