| CODENOTIFIER | HelpYou are not signed inSign in |
Project: dojo
Revision: 15163
Author: bill
Date: 07 Sep 2008 22:33:21
Diff at Trac: http://trac.dojotoolkit.org/changeset/15163
Changes: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
Files:| ... | ...@@ -180,16 +180,11 @@ | |
| 180 | 180 | // Focused - if the widget has focus |
| 181 | 181 | // Hover - if the mouse is over the widget |
| 182 | 182 | |
| 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 | ||
| 188 | 183 | // Compute new set of classes |
| 189 | var classes = this.baseClass.split(" "); | |
| 184 | var newStateClasses = this.baseClass.split(" "); | |
| 190 | 185 | |
| 191 | 186 | 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); | |
| 193 | 188 | } |
| 194 | 189 | |
| 195 | 190 | if(this.checked){ |
| ... | ...@@ -217,7 +212,26 @@ | |
| 217 | 212 | } |
| 218 | 213 | } |
| 219 | 214 | |
| 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; | |
| 221 | 235 | }, |
| 222 | 236 | |
| 223 | 237 | compare: function(/*anything*/val1, /*anything*/val2){ |
| ... | ...@@ -308,7 +308,7 @@ | |
| 308 | 308 | |
| 309 | 309 | // Nodes in IE don't respond to t/l/b/r, and TEXTAREA doesn't respond in any browser |
| 310 | 310 | 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"; | |
| 312 | 312 | }); |
| 313 | 313 | if(janky){ |
| 314 | 314 | // Set the size of the children the old fashioned way, by calling |