@@ -915,7 +915,6 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
915915
916916function baseInputType ( scope , element , attr , ctrl , $sniffer , $browser ) {
917917 var validity = element . prop ( VALIDITY_STATE_PROPERTY ) ;
918- var placeholder = element [ 0 ] . placeholder , noevent = { } ;
919918 var type = lowercase ( element [ 0 ] . type ) ;
920919
921920 // In composition mode, users are still inputing intermediate text buffer,
@@ -934,17 +933,33 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
934933 } ) ;
935934 }
936935
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+ attr . $observe ( "placeholder" , function ieIgnoreNextInputPlaceholder ( newP , oldP ) {
944+ ignoreNextInput = ( newP !== oldP ) && ! element [ 0 ] . value ;
945+ } ) ;
946+
947+ // Focus in/out triggers an input if there is no value but there is a placeholder
948+ // Event orders:
949+ // focus: focusin focus input
950+ // blur: focusout input blur
951+ element . on ( "focusin focusout" , function ieIgnoreNextInputFocus ( ) {
952+ ignoreNextInput = this . placeholder && ! this . value ;
953+ } ) ;
954+ }
955+
937956 var listener = function ( ev ) {
938957 if ( composing ) return ;
939958 var value = element . val ( ) ,
940959 event = ev && ev . type ;
941960
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 ;
961+ if ( ignoreNextInput && event === 'input' ) {
962+ ignoreNextInput = false ;
948963 return ;
949964 }
950965
0 commit comments