Permalink
Browse files

Tests and fix for focusCleanup with wrapper

  • Loading branch information...
1 parent c466947 commit 1b464f32b379b0e0ecc1685d1f0779ffdd63dc91 @jzaefferer jzaefferer committed Jul 14, 2010
Showing with 16 additions and 4 deletions.
  1. +1 −1 jquery.validate.js
  2. +15 −3 test/test.js
View
2 jquery.validate.js
@@ -219,7 +219,7 @@ $.extend($.validator, {
// hide error label and remove error class on focus if enabled
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
- this.errorsFor(element).hide();
+ this.addWrapper(this.errorsFor(element)).hide();
}
},
onfocusout: function(element) {
View
18 test/test.js
@@ -388,9 +388,21 @@ test("option: focusCleanup true", function() {
focusCleanup: true
});
form.valid();
- ok( form.is(":has(label.error[for=username]):visible"));
- $("#username").focus();
- ok( !form.is(":has(label.error[for=username]:visible)"));
+ ok( form.is(":has(label.error[for=username]:visible)") );
+ $("#username").focus().trigger("focusin");
+ ok( !form.is(":has(label.error[for=username]:visible)") );
+});
+
+test("option: focusCleanup with wrapper", function() {
+ var form = $("#userForm")
+ form.validate({
+ focusCleanup: true,
+ wrapper: "span"
+ });
+ form.valid();
+ ok( form.is(":has(span:visible:has(label.error[for=username]))") );
+ $("#username").focus().trigger("focusin");
+ ok( !form.is(":has(span:visible:has(label.error[for=username]))") );
});
test("elements() order", function() {

0 comments on commit 1b464f3

Please sign in to comment.