mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
committed by
Peter Bacon Darwin
parent
40406e2f22
commit
8692f87a46
@@ -1342,9 +1342,11 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
|
||||
element[0].checked = ctrl.$viewValue;
|
||||
};
|
||||
|
||||
// Override the standard `$isEmpty` because a value of `false` means empty in a checkbox.
|
||||
// Override the standard `$isEmpty` because the $viewValue of an empty checkbox is always set to `false`
|
||||
// This is because of the parser below, which compares the `$modelValue` with `trueValue` to convert
|
||||
// it to a boolean.
|
||||
ctrl.$isEmpty = function(value) {
|
||||
return value !== trueValue;
|
||||
return value === false;
|
||||
};
|
||||
|
||||
ctrl.$formatters.push(function(value) {
|
||||
|
||||
@@ -2290,6 +2290,22 @@ describe('input', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should render the $viewValue when $modelValue is empty', function() {
|
||||
compileInput('<input type="text" ng-model="value" />');
|
||||
|
||||
var ctrl = inputElm.controller('ngModel');
|
||||
|
||||
ctrl.$modelValue = null;
|
||||
|
||||
expect(ctrl.$isEmpty(ctrl.$modelValue)).toBe(true);
|
||||
|
||||
ctrl.$viewValue = 'abc';
|
||||
ctrl.$render();
|
||||
|
||||
expect(inputElm.val()).toBe('abc');
|
||||
});
|
||||
|
||||
|
||||
describe('pattern', function() {
|
||||
|
||||
it('should validate in-lined pattern', function() {
|
||||
|
||||
Reference in New Issue
Block a user