mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
Core: Remove unused removeAttrs method
jQuery Core supports removing space-separated attributes since 1.7, and its not used in the plugin anyway. Fixes #1124
This commit is contained in:
11
src/core.js
11
src/core.js
@@ -107,16 +107,7 @@ $.extend($.fn, {
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
// attributes: space separated list of attributes to retrieve and remove
|
||||
removeAttrs: function( attributes ) {
|
||||
var result = {},
|
||||
$element = this;
|
||||
$.each( attributes.split( /\s/ ), function( index, value ) {
|
||||
result[ value ] = $element.attr( value );
|
||||
$element.removeAttr( value );
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
// http://jqueryvalidation.org/rules/
|
||||
rules: function( command, argument ) {
|
||||
var element = this[ 0 ],
|
||||
|
||||
@@ -217,16 +217,19 @@ test("rules(), add and remove", function() {
|
||||
return false;
|
||||
}, "");
|
||||
$("#v2").validate();
|
||||
var removedAttrs = $("#v2-i5").removeClass("required").removeAttrs("minlength maxlength");
|
||||
$("#v2-i5").removeClass("required").removeAttr("minlength maxlength");
|
||||
deepEqual( $("#v2-i5").rules(), { customMethod1: "123" });
|
||||
|
||||
$("#v2-i5").addClass("required").attr(removedAttrs);
|
||||
$("#v2-i5").addClass("required").attr({
|
||||
minlength: 2,
|
||||
maxlength: 5
|
||||
});
|
||||
deepEqual( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
|
||||
|
||||
$("#v2-i5").addClass("email").attr({ min: 5 });
|
||||
deepEqual( $("#v2-i5").rules(), { required: true, email: true, minlength: 2, maxlength: 5, min: 5, customMethod1: "123" });
|
||||
|
||||
$("#v2-i5").removeClass("required email").removeAttrs("minlength maxlength customMethod1 min");
|
||||
$("#v2-i5").removeClass("required email").removeAttr("minlength maxlength customMethod1 min");
|
||||
deepEqual( $("#v2-i5").rules(), {});
|
||||
|
||||
delete $.validator.methods.customMethod1;
|
||||
|
||||
Reference in New Issue
Block a user