Changeset 12376

Show
Ignore:
Timestamp:
02/11/08 15:24:57 (11 months ago)
Author:
peller
Message:

Reduce toPixelValue with a regexp, remove redundant return statements. Refs #3961 !strict

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/_base/html.js

    r12365 r12376  
    380380                width: true, height: true, left: true, top: true 
    381381        }; 
     382        var _pixelRegExp = /^(?:margin*|padding*|width|height|max*|min*|offset*)/ /*|border*/; 
    382383        var _toStyleValue = function(node, type, value){ 
    383384                type = type.toLowerCase(); 
    384                 if(_pixelNamesCache[type] === true){ 
    385                         return dojo._toPixelValue(node, value) 
    386                 }else if(_pixelNamesCache[type] === false){ 
    387                         return value; 
    388                 }else{ 
    389                         if(dojo.isOpera && type == "cssText"){ 
    390                                 // FIXME: add workaround for #2855 here 
    391                         } 
    392                         if( 
    393                                 type.indexOf("margin") >= 0 || 
    394                                 // type.indexOf("border") >= 0 || 
    395                                 type.indexOf("padding") >= 0 || 
    396                                 type.indexOf("width") >= 0 || 
    397                                 type.indexOf("height") >= 0 || 
    398                                 type.indexOf("max") >= 0 || 
    399                                 type.indexOf("min") >= 0 || 
    400                                 type.indexOf("offset") >= 0 
    401                         ){ 
    402                                 _pixelNamesCache[type] = true; 
    403                                 return dojo._toPixelValue(node, value) 
    404                         }else{ 
    405                                 _pixelNamesCache[type] = false; 
    406                                 return value; 
    407                         } 
    408                 } 
     385                if(!(type in _pixelNamesCache)){ 
     386//                      if(dojo.isOpera && type == "cssText"){ 
     387// FIXME: add workaround for #2855 here 
     388//                      } 
     389                        _pixelNamesCache[type] = _pixelRegExp.test(type); 
     390                } 
     391                return _pixelNamesCache[type] ? dojo._toPixelValue(node, value) : value; 
     392 
    409393        } 
    410394 
     
    552536                        r=px(n, s.marginRight), 
    553537                        b=px(n, s.marginBottom); 
    554                 if (dojo.isSafari && (s.position != "absolute")){ 
     538                if(dojo.isSafari && (s.position != "absolute")){ 
    555539                        // FIXME: Safari's version of the computed right margin 
    556540                        // is the space between our right edge and the right edge  
     
    794778         
    795779        var _sumAncestorProperties = function(node, prop){ 
    796                 if(!(node = (node||0).parentNode)){return 0}; //FIXME: 0.parentNode? 
     780                if(!(node = (node||0).parentNode)){return 0}; 
    797781                var val, retVal = 0, _b = dojo.body(); 
    798782                while(node && node.style){