@@ -915,7 +915,6 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
915
915
916
916
function baseInputType ( scope , element , attr , ctrl , $sniffer , $browser ) {
917
917
var validity = element . prop ( VALIDITY_STATE_PROPERTY ) ;
918
- var placeholder = element [ 0 ] . placeholder , noevent = { } ;
919
918
var type = lowercase ( element [ 0 ] . type ) ;
920
919
921
920
// In composition mode, users are still inputing intermediate text buffer,
@@ -934,17 +933,35 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
934
933
} ) ;
935
934
}
936
935
936
+ // IE (11 and under) seem to emit an 'input' event if the placeholder value changes or when
937
+ // an input with a placeholder gains or loses focus. These issues do not happen if the input
938
+ // has a value at the time.
939
+ if ( msie && ( 'placeholder' in element [ 0 ] ) && $sniffer . hasEvent ( 'input' ) ) {
940
+ var ignoreNextInput ;
941
+
942
+ // Changing placeholders triggers an input if there is no value
943
+ var oldPlaceholder ;
944
+ attr . $observe ( "placeholder" , function ieIgnoreNextInputPlaceholder ( newPlaceholder ) {
945
+ ignoreNextInput = ( newPlaceholder !== oldPlaceholder ) && ! element [ 0 ] . value ;
946
+ oldPlaceholder = newPlaceholder ;
947
+ } ) ;
948
+
949
+ // Focus in/out triggers an input if there is no value but there is a placeholder
950
+ // Event orders:
951
+ // focus: focusin focus input
952
+ // blur: focusout input blur
953
+ element . on ( "focusin focusout" , function ieIgnoreNextInputFocus ( ) {
954
+ ignoreNextInput = this . placeholder && ! this . value ;
955
+ } ) ;
956
+ }
957
+
937
958
var listener = function ( ev ) {
938
959
if ( composing ) return ;
939
960
var value = element . val ( ) ,
940
961
event = ev && ev . type ;
941
962
942
- // IE (11 and under) seem to emit an 'input' event if the placeholder value changes.
943
- // We don't want to dirty the value when this happens, so we abort here. Unfortunately,
944
- // IE also sends input events for other non-input-related things, (such as focusing on a
945
- // form control), so this change is not entirely enough to solve this.
946
- if ( msie && ( ev || noevent ) . type === 'input' && element [ 0 ] . placeholder !== placeholder ) {
947
- placeholder = element [ 0 ] . placeholder ;
963
+ if ( ignoreNextInput && event === 'input' ) {
964
+ ignoreNextInput = false ;
948
965
return ;
949
966
}
950
967
0 commit comments