Skip to content

Commit

Permalink
fix(form): optimized disabled detection
Browse files Browse the repository at this point in the history
The code to detect a field is disabled could not handle fields under fieldset[disabled]
  • Loading branch information
jameschenjav authored Apr 5, 2020
1 parent 7137827 commit 09e6d28
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ $.fn.form = function(parameters) {
$elGroup = $(el).closest($group),
isCheckbox = ($el.filter(selector.checkbox).length > 0),
isRequired = $el.prop('required') || $elGroup.hasClass(className.required) || $elGroup.parent().hasClass(className.required),
isDisabled = $el.prop('disabled') || $elGroup.hasClass(className.disabled) || $elGroup.parent().hasClass(className.disabled),
isDisabled = $el.is(':disabled') || $elGroup.hasClass(className.disabled) || $elGroup.parent().hasClass(className.disabled),
validation = module.get.validation($el),
hasEmptyRule = validation
? $.grep(validation.rules, function(rule) { return rule.type == "empty" }) !== 0
Expand Down Expand Up @@ -1207,13 +1207,7 @@ $.fn.form = function(parameters) {
module.debug('Using field name as identifier', identifier);
field.identifier = identifier;
}
var isDisabled = true;
$.each($field, function(){
if(!$(this).prop('disabled')) {
isDisabled = false;
return false;
}
});
var isDisabled = !$field.filter(':not(:disabled)').length;
if(isDisabled) {
module.debug('Field is disabled. Skipping', identifier);
}
Expand Down

0 comments on commit 09e6d28

Please sign in to comment.