Changeset 15163

Show
Ignore:
Timestamp:
09/07/08 19:33:21 (3 months ago)
Author:
bill
Message:

Fixes #7611: BorderContainer?: does not layout form widgets.

Refactor _setStateClass() to be resilient when classes are added to domNode after the widget has been initialized. This is safer but slower than the old version, which saved the node's original class.

For fear of performance issues it's only writing into domNode.className once; code would have been shorter but possibly slower if it made many calls to addClass() and removeClass().

!strict

Location:
dijit/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/_FormWidget.js

    r14993 r15163  
    181181                //              Hover           - if the mouse is over the widget 
    182182 
    183                 // Get original (non state related, non baseClass related) class specified in template 
    184                 if(!("staticClass" in this)){ 
    185                         this.staticClass = (this.stateNode||this.domNode).className; 
    186                 } 
    187  
    188183                // Compute new set of classes 
    189                 var classes = this.baseClass.split(" "); 
     184                var newStateClasses = this.baseClass.split(" "); 
    190185 
    191186                function multiply(modifier){ 
    192                         classes=classes.concat(dojo.map(classes, function(c){ return c+modifier; }), "dijit"+modifier); 
     187                        newStateClasses = newStateClasses.concat(dojo.map(newStateClasses, function(c){ return c+modifier; }), "dijit"+modifier); 
    193188                } 
    194189 
     
    218213                } 
    219214 
    220                 (this.stateNode || this.domNode).className = this.staticClass + " " + classes.join(" "); 
     215                // Remove old state classes and add new ones. 
     216                // For performance concerns we only write into domNode.className once. 
     217                var tn = this.stateNode || this.domNode, 
     218                        classHash = {}; // set of all classes (state and otherwise) for node 
     219 
     220                dojo.forEach(tn.className.split(" "), function(c){ classHash[c] = true; }); 
     221 
     222                if("_stateClasses" in this){ 
     223                        dojo.forEach(this._stateClasses, function(c){ delete classHash[c]; }); 
     224                } 
     225 
     226                dojo.forEach(newStateClasses, function(c){ classHash[c] = true; }); 
     227 
     228                var newClasses = []; 
     229                for(var c in classHash){ 
     230                        newClasses.push(c); 
     231                } 
     232                tn.className = newClasses.join(" "); 
     233 
     234                this._stateClasses = newStateClasses; 
    221235        }, 
    222236 
  • dijit/trunk/layout/BorderContainer.js

    r15113 r15163  
    309309                // Nodes in IE don't respond to t/l/b/r, and TEXTAREA doesn't respond in any browser 
    310310                var janky = dojo.isIE || dojo.some(this.getChildren(), function(child){ 
    311                         return child.domNode.tagName == "TEXTAREA"; 
     311                        return child.domNode.tagName == "TEXTAREA" || child.domNode.tagName == "INPUT"; 
    312312                }); 
    313313                if(janky){