Changeset 15416

Show
Ignore:
Timestamp:
10/07/08 06:35:00 (3 months ago)
Author:
toonetown
Message:

Refs #7788 addresses this performance issue in trunk - would like to have someone look over it before committing it to 1.2 branch.

Location:
dijit/trunk
Files:
1 added
1 modified

Legend:

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

    r15254 r15416  
    301301                isValid: function(){ 
    302302                        // summary: make sure that every widget that has a validator function returns true 
     303                        this._invalidWidgets = []; 
    303304                        return dojo.every(this.getDescendants(), function(widget){ 
    304                                 return widget.disabled || !widget.isValid || widget.isValid(); 
    305                         }); 
     305                                var isValid = widget.disabled || !widget.isValid || widget.isValid(); 
     306                                if(!isValid){ 
     307                                        this._invalidWidgets.push(widget); 
     308                                } 
     309                                return isValid; 
     310                        }, this); 
    306311                }, 
    307312                 
     
    313318                }, 
    314319                 
    315                 _widgetChange: function(){ 
     320                _widgetChange: function(widget){ 
    316321                        // summary: connected to a widgets onChange function - update our  
    317322                        //                      valid state, if needed. 
    318                         var isValid = this.isValid(); 
     323                        var isValid = this._lastValidState; 
     324                        if(widget && !widget.disabled && widget.isValid){ 
     325                                this._invalidWidgets = dojo.filter(this._invalidWidgets||[], function(w){ 
     326                                        return (w != widget); 
     327                                }, this); 
     328                                if(!widget.isValid()){ 
     329                                        this._invalidWidgets.push(widget); 
     330                                } 
     331                                isValid = (this._invalidWidgets.length === 0); 
     332                        } 
    319333                        if (isValid !== this._lastValidState){ 
    320334                                this._lastValidState = isValid; 
     
    340354                                ), 
    341355                                function(widget){ 
    342                                         return _this.connect(widget, "validate", "_widgetChange"); 
     356                                        return _this.connect(widget, "validate", dojo.hitch(_this, "_widgetChange", widget)); 
    343357                                } 
    344358                        ); 
     
    346360                        // Call the widget change function to update the valid state, in  
    347361                        // case something is different now. 
    348                         this._widgetChange(); 
     362                        this._widgetChange(null); 
    349363                }, 
    350364                 
     
    355369                        //  yet. 
    356370                        this._changeConnections = []; 
     371                        this._lastValidState = this.isValid(); 
    357372                        this.connectChildren(); 
    358                         this._lastValidState = this.isValid(); 
    359373                } 
    360374        });