Skip to content

Commit c44fcb6

Browse files
committed
WIP: to be squashed
1 parent 5aa7600 commit c44fcb6

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/ng/directive/input.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,6 @@ var inputType = {
384384
};
385385

386386

387-
function isEmpty(value) {
388-
return isUndefined(value) || value === '' || value === null || value !== value;
389-
}
390-
391-
392387
function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
393388

394389
var listener = function() {
@@ -658,9 +653,8 @@ function checkboxInputType(scope, element, attr, ctrl) {
658653
};
659654

660655
// Override the standard `$isEmpty` because a value of `false` means empty in a checkbox.
661-
var _$isEmpty = ctrl.$isEmpty;
662656
ctrl.$isEmpty = function(value) {
663-
return _$isEmpty(value) || value === false;
657+
return value !== trueValue;
664658
};
665659

666660
ctrl.$formatters.push(function(value) {
@@ -1012,8 +1006,10 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
10121006
* You can override this for input directives whose concept of being empty is different to the
10131007
* default. The `checkboxInputType` directive does this because in its case a value of `false`
10141008
* implies empty.
1015-
*/
1016-
this.$isEmpty = isEmpty;
1009+
*/
1010+
this.$isEmpty = function(value) {
1011+
return isUndefined(value) || value === '' || value === null || value !== value;
1012+
};
10171013

10181014
var parentForm = $element.inheritedData('$formController') || nullFormCtrl,
10191015
invalidCount = 0, // used to easily determine if we are valid
@@ -1365,7 +1361,7 @@ var ngListDirective = function() {
13651361

13661362
var parse = function(viewValue) {
13671363
// If the viewValue is invalid (say required but empty) it will be `undefined`
1368-
if ( isUndefined(viewValue) ) return;
1364+
if (isUndefined(viewValue)) return;
13691365

13701366
var list = [];
13711367

@@ -1387,10 +1383,9 @@ var ngListDirective = function() {
13871383
return undefined;
13881384
});
13891385

1390-
// Override the standard $isEmpty because an empty array means the input is empty
1391-
var _$isEmpty = ctrl.$isEmpty;
1386+
// Override the standard $isEmpty because an empty array means the input is empty.
13921387
ctrl.$isEmpty = function(value) {
1393-
return _$isEmpty(value) || value.length === 0;
1388+
return !value || !value.length;
13941389
};
13951390
}
13961391
};

0 commit comments

Comments
 (0)