File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1038,14 +1038,8 @@ var ngModelInstantDirective = ['$browser', function($browser) {
10381038 return {
10391039 require : 'ngModel' ,
10401040 link : function ( scope , element , attr , ctrl ) {
1041- element . bind ( 'keydown change input' , function ( event ) {
1042- var key = event . keyCode ;
1043-
1044- // command modifiers arrows
1045- if ( key === 91 || ( 15 < key && key < 19 ) || ( 37 <= key && key <= 40 ) ) return ;
1046-
1047- $browser . defer ( function ( ) {
1048- var touched = ctrl . touch ( ) ,
1041+ var handler = function ( ) {
1042+ var touched = ctrl . touch ( ) ,
10491043 value = trim ( element . val ( ) ) ;
10501044
10511045 if ( ctrl . viewValue !== value ) {
@@ -1055,8 +1049,24 @@ var ngModelInstantDirective = ['$browser', function($browser) {
10551049 } else if ( touched ) {
10561050 scope . $apply ( ) ;
10571051 }
1058- } ) ;
1052+ } ;
1053+
1054+ var timeout ;
1055+ element . bind ( 'keydown' , function ( event ) {
1056+ var key = event . keyCode ;
1057+
1058+ // command modifiers arrows
1059+ if ( key === 91 || ( 15 < key && key < 19 ) || ( 37 <= key && key <= 40 ) ) return ;
1060+
1061+ if ( ! timeout ) {
1062+ timeout = $browser . defer ( function ( ) {
1063+ handler ( ) ;
1064+ timeout = null ;
1065+ } ) ;
1066+ }
10591067 } ) ;
1068+
1069+ element . bind ( 'change input' , handler ) ;
10601070 }
10611071 } ;
10621072} ] ;
Original file line number Diff line number Diff line change @@ -949,14 +949,12 @@ describe('input', function() {
949949
950950 inputElm . val ( 'value2' ) ;
951951 browserTrigger ( inputElm , 'change' ) ;
952- $browser . defer . flush ( ) ;
953952 expect ( scope . value ) . toBe ( 'value2' ) ;
954953
955954 if ( msie < 9 ) return ;
956955
957956 inputElm . val ( 'value3' ) ;
958957 browserTrigger ( inputElm , 'input' ) ;
959- $browser . defer . flush ( ) ;
960958 expect ( scope . value ) . toBe ( 'value3' ) ;
961959 } ) ) ;
962960 } ) ;
You can’t perform that action at this time.
0 commit comments