Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2cdae38

Browse files
committed
fixup! fix(required): correctly validate when required on non-input element is surrounded by ngIf
1 parent 9be1198 commit 2cdae38

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ng/directive/validators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var requiredDirective = ['$parse', function($parse) {
6969
link: function(scope, elm, attr, ctrl) {
7070
if (!ctrl) return;
7171
// For boolean attributes like required, presence means true
72-
var value = 'required' in attr || $parse(attr.ngRequired)(scope);
72+
var value = attr.hasOwnProperty('required') || $parse(attr.ngRequired)(scope);
7373

7474
if (!attr.ngRequired) {
7575
// force truthy in case we are on non input element

test/ng/directive/validatorsSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,13 @@ describe('validators', function() {
696696
}));
697697

698698

699+
it('should override "required" when ng-required="false" is set', function() {
700+
var inputElm = helper.compileInput('<input type="text" ng-model="notDefined" required ng-required="false" />');
701+
702+
expect(inputElm).toBeValid();
703+
});
704+
705+
699706
it('should validate only once after compilation when inside ngRepeat', function() {
700707
helper.compileInput(
701708
'<div ng-repeat="input in [0]">' +

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy