[dojo-contributors] Question about dojo.attr

Bill Keese bill at dojotoolkit.org
Thu May 12 18:48:36 EDT 2011


BTW, one other possibility is that it was a hack to make the doc parser
work.  I remember talk about how the doc parser could (or would be able to?)
analyze multiple call signatures for a function where each one returns a
different value, and document them, ex:

    foo(String) returns String
    foo(Number) returns Date

It's hard to believe the doc parser actually does that though.

2011/5/13 Richard Backhouse <backhous at us.ibm.com>

> I opened http://trac.dojotoolkit.org/ticket/12923
>
> Richard
>
> [image: Inactive hide details for Richard Backhouse---05/12/2011 03:18:59
> PM---Ok, I'll open a ticket. Uglifyjs has fixed the problem.]Richard
> Backhouse---05/12/2011 03:18:59 PM---Ok, I'll open a ticket. Uglifyjs has
> fixed the problem. https://github.com/mishoo/UglifyJS/issues/150
>
>
> From:
> Richard Backhouse/Durham/IBM at IBMUS
> To:
> "dojo dev." <dojo-contributors at mail.dojotoolkit.org>
> Cc:
> "dojo dev." <dojo-contributors at mail.dojotoolkit.org>,
> dojo-contributors-bounces at mail.dojotoolkit.org
> Date:
> 05/12/2011 03:18 PM
> Subject:
> Re: [dojo-contributors] Question about dojo.attr
> ------------------------------
>
>
>
> Ok, I'll open a ticket. Uglifyjs has fixed the problem. *
> https://github.com/mishoo/UglifyJS/issues/150*<https://github.com/mishoo/UglifyJS/issues/150>
>
> Thanks
> Richard
>
> [image: Inactive hide details for Eugene Lazutkin ---05/12/2011 03:11:10
> PM--------BEGIN PGP SIGNED MESSAGE-----]Eugene Lazutkin ---05/12/2011
> 03:11:10 PM--------BEGIN PGP SIGNED MESSAGE-----
>
> From:
> Eugene Lazutkin <eugene at lazutkin.com>
> To:
> "dojo dev." <dojo-contributors at mail.dojotoolkit.org>
> Date:
> 05/12/2011 03:11 PM
> Subject:
> Re: [dojo-contributors] Question about dojo.attr
> ------------------------------
>
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I think do{}while(false) in this particular case is the remnants of some
> ancient civilization. Please file a ticket to track it, and I'll change it.
>
> Yet, it is troublesome that uglyfyjs chokes on do{}while() loop.
>
> Cheers,
>
> Eugene Lazutkin*
> **http://lazutkin.com/* <http://lazutkin.com/>
>
>
> On 05/12/2011 07:32 AM, Richard Backhouse wrote:
> > I have been tracking down an uglifyjs compression issue and have finally
> > found it to be the way it is optimizing dojo.attr in dojo/_base/html.js.
> >
> > The code in question is
> >
> >     if(args == 3){
> >        // setter
> >        do{
> >            if(propName == "style" && typeof value != "string"){ //
> > inline'd type check
> >                // special case: setting a style
> >                d.style(node, value);
> >                break;
> >            }
> >            if(propName == "innerHTML"){
> >                // special case: assigning HTML
> >                //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
> >                if(d.isIE && node.tagName.toLowerCase() in _roInnerHtml){
> >                    d.empty(node);
> >                    node.appendChild(d._toDom(value, node.ownerDocument));
> >                }else{
> >                //>>excludeEnd("webkitMobile");
> >                    node[propName] = value;
> >                //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
> >                }
> >                //>>excludeEnd("webkitMobile");
> >                break;
> >            }
> >            if(d.isFunction(value)){
> >                // special case: assigning an event handler
> >                // clobber if we can
> >                var attrId = d.attr(node, _attrId);
> >                if(!attrId){
> >                    attrId = _ctr++;
> >                    d.attr(node, _attrId, attrId);
> >                }
> >                if(!_evtHdlrMap[attrId]){
> >                    _evtHdlrMap[attrId] = {};
> >                }
> >                var h = _evtHdlrMap[attrId][propName];
> >                if(h){
> >                    d.disconnect(h);
> >                }else{
> >                    try{
> >                        delete node[propName];
> >                    }catch(e){}
> >                }
> >                // ensure that event objects are normalized, etc.
> >                _evtHdlrMap[attrId][propName] = d.connect(node, propName,
> > value);
> >                break;
> >            }
> >            if(forceProp || typeof value == "boolean"){
> >                // special case: forcing assignment to the property
> >                // special case: setting boolean to a property instead of
> > attribute
> >                node[propName] = value;
> >                break;
> >            }
> >            // node's attribute
> >            node.setAttribute(attrName, value);
> >        }while(false);
> >        return node; // DomNode
> >    }
> >
> > with uglifyjs optimizing it to
> >
> > if (e == 3) return a;
> >
> > My question is why is there a do/while(false) loop in there ? Couldn't
> > it just be
> >
> > if(args == 3){
> > // setter
> > if(propName == "style"&& typeofvalue != "string"){ // inline'd type check
> > // special case: setting a style
> > d.style(node, value);
> > returnnode;
> > }
> > if(propName == "innerHTML"){
> > // special case: assigning HTML
> > //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
> > if(d.isIE && node.tagName.toLowerCase() in_roInnerHtml){
> > d.empty(node);
> > node.appendChild(d._toDom(value, node.ownerDocument));
> > }else{
> > //>>excludeEnd("webkitMobile");
> > node[propName] = value;
> > //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
> > }
> > //>>excludeEnd("webkitMobile");
> > returnnode;
> > }
> > if(d.isFunction(value)){
> > // special case: assigning an event handler
> > // clobber if we can
> > varattrId = d.attr(node, _attrId);
> > if(!attrId){
> > attrId = _ctr++;
> > d.attr(node, _attrId, attrId);
> > }
> > if(!_evtHdlrMap[attrId]){
> > _evtHdlrMap[attrId] = {};
> > }
> > varh = _evtHdlrMap[attrId][propName];
> > if(h){
> > d.disconnect(h);
> > }else{
> > try{
> > deletenode[propName];
> > }catch(e){}
> > }
> > // ensure that event objects are normalized, etc.
> > _evtHdlrMap[attrId][propName] = d.connect(node, propName, value);
> > returnnode;
> > }
> > if(forceProp || typeofvalue == "boolean"){
> > // special case: forcing assignment to the property
> > // special case: setting boolean to a property instead of attribute
> > node[propName] = value;
> > returnnode;
> > }
> > // node's attribute
> > node.setAttribute(attrName, value);
> > returnnode; // DomNode
> > }
> >
> > or is there another reason for having the do/while loop ?
> >
> > Richard
> >
> >
> >
> > _______________________________________________
> > dojo-contributors mailing list
> > dojo-contributors at mail.dojotoolkit.org
> > *http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors*<http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - *http://enigmail.mozdev.org/*<http://enigmail.mozdev.org/>
>
> iEYEARECAAYFAk3MMJYACgkQY214tZwSfCvdLwCePvJcm9llEEdJjbKHaFUBaJSb
> NEYAmwdY2sfnrPS9ZStnsNpcZX3UD2o+
> =+5rQ
> -----END PGP SIGNATURE-----
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org*
> **http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors*<http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors>
>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
>
>
>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110513/da8f2c34/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110513/da8f2c34/attachment-0002.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110513/da8f2c34/attachment-0003.gif 


More information about the dojo-contributors mailing list