@@ -914,7 +914,6 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
914
914
var validity = element . prop ( VALIDITY_STATE_PROPERTY ) ;
915
915
var placeholder = element [ 0 ] . placeholder , noevent = { } ;
916
916
var type = lowercase ( element [ 0 ] . type ) ;
917
- ctrl . $$validityState = validity ;
918
917
919
918
// In composition mode, users are still inputing intermediate text buffer,
920
919
// hold the listener until composition is done.
@@ -953,16 +952,15 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
953
952
value = trim ( value ) ;
954
953
}
955
954
956
- // If a control is suffering from bad input, browsers discard its value, so it may be
957
- // necessary to revalidate even if the control's value is the same empty value twice in
958
- // a row.
959
- var revalidate = validity && ctrl . $$hasNativeValidators ;
960
- if ( ctrl . $viewValue !== value || ( value === '' && revalidate ) ) {
955
+ // If a control is suffering from bad input (due to native validators), browsers discard its
956
+ // value, so it may be necessary to revalidate (by calling $setViewValue again) even if the
957
+ // control's value is the same empty value twice in a row.
958
+ if ( ctrl . $viewValue !== value || ( value === '' && ctrl . $$hasNativeValidators ) ) {
961
959
if ( scope . $root . $$phase ) {
962
- ctrl . $setViewValue ( value , event , revalidate ) ;
960
+ ctrl . $setViewValue ( value , event ) ;
963
961
} else {
964
962
scope . $apply ( function ( ) {
965
- ctrl . $setViewValue ( value , event , revalidate ) ;
963
+ ctrl . $setViewValue ( value , event ) ;
966
964
} ) ;
967
965
}
968
966
}
@@ -1980,11 +1978,15 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1980
1978
* event defined in `ng-model-options`. this method is rarely needed as `NgModelController`
1981
1979
* usually handles calling this in response to input events.
1982
1980
*/
1983
- this . $commitViewValue = function ( revalidate ) {
1981
+ this . $commitViewValue = function ( ) {
1984
1982
var viewValue = ctrl . $viewValue ;
1985
1983
1986
1984
$timeout . cancel ( pendingDebounce ) ;
1987
- if ( ! revalidate && ctrl . $$lastCommittedViewValue === viewValue ) {
1985
+
1986
+ // If the view value has not changed then we should just exit, except in the case where there is
1987
+ // a native validator on the element. In this case the validation state may have changed even though
1988
+ // the viewValue has stayed empty.
1989
+ if ( ctrl . $$lastCommittedViewValue === viewValue && ( viewValue !== '' || ! ctrl . $$hasNativeValidators ) ) {
1988
1990
return ;
1989
1991
}
1990
1992
ctrl . $$lastCommittedViewValue = viewValue ;
@@ -2080,14 +2082,14 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2080
2082
* @param {string } value Value from the view.
2081
2083
* @param {string } trigger Event that triggered the update.
2082
2084
*/
2083
- this . $setViewValue = function ( value , trigger , revalidate ) {
2085
+ this . $setViewValue = function ( value , trigger ) {
2084
2086
ctrl . $viewValue = value ;
2085
2087
if ( ! ctrl . $options || ctrl . $options . updateOnDefault ) {
2086
- ctrl . $$debounceViewValueCommit ( trigger , revalidate ) ;
2088
+ ctrl . $$debounceViewValueCommit ( trigger ) ;
2087
2089
}
2088
2090
} ;
2089
2091
2090
- this . $$debounceViewValueCommit = function ( trigger , revalidate ) {
2092
+ this . $$debounceViewValueCommit = function ( trigger ) {
2091
2093
var debounceDelay = 0 ,
2092
2094
options = ctrl . $options ,
2093
2095
debounce ;
@@ -2106,10 +2108,10 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2106
2108
$timeout . cancel ( pendingDebounce ) ;
2107
2109
if ( debounceDelay ) {
2108
2110
pendingDebounce = $timeout ( function ( ) {
2109
- ctrl . $commitViewValue ( revalidate ) ;
2111
+ ctrl . $commitViewValue ( ) ;
2110
2112
} , debounceDelay ) ;
2111
2113
} else {
2112
- ctrl . $commitViewValue ( revalidate ) ;
2114
+ ctrl . $commitViewValue ( ) ;
2113
2115
}
2114
2116
} ;
2115
2117
0 commit comments