Skip to content

Commit

Permalink
Fix a sit. where defaults would be destroyed if overridden.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjaques committed Jul 13, 2012
1 parent 4a0e28b commit 1c3b9cb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jquery.validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ $.extend($.validator, {
// hide error label and remove error class on focus if enabled
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
if ( this.settings.unhighlight ) {
this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass, defaults.unhighlight );
this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass, this._defaults.unhighlight );
}
this.addWrapper(this.errorsFor(element)).hide();
}
Expand Down Expand Up @@ -265,6 +265,8 @@ $.extend($.validator, {
}
}
},

_defaults: this.defaults, // keep a copy just in case.

// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
setDefaults: function(settings) {
Expand Down Expand Up @@ -644,7 +646,7 @@ $.extend($.validator, {
for ( i = 0; this.errorList[i]; i++ ) {
var error = this.errorList[i];
if ( this.settings.highlight ) {
this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass, defaults.highlight );
this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass, this._defaults.highlight );
}
this.showLabel( error.element, error.message );
}
Expand All @@ -658,7 +660,7 @@ $.extend($.validator, {
}
if (this.settings.unhighlight) {
for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass, defaults.unhighlight );
this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass, this._defaults.unhighlight );
}
}
this.toHide = this.toHide.not( this.toShow );
Expand Down

0 comments on commit 1c3b9cb

Please sign in to comment.