File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -1038,14 +1038,8 @@ var ngModelInstantDirective = ['$browser', function($browser) {
1038
1038
return {
1039
1039
require : 'ngModel' ,
1040
1040
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 ( ) ,
1049
1043
value = trim ( element . val ( ) ) ;
1050
1044
1051
1045
if ( ctrl . viewValue !== value ) {
@@ -1055,8 +1049,24 @@ var ngModelInstantDirective = ['$browser', function($browser) {
1055
1049
} else if ( touched ) {
1056
1050
scope . $apply ( ) ;
1057
1051
}
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
+ }
1059
1067
} ) ;
1068
+
1069
+ element . bind ( 'change input' , handler ) ;
1060
1070
}
1061
1071
} ;
1062
1072
} ] ;
Original file line number Diff line number Diff line change @@ -949,14 +949,12 @@ describe('input', function() {
949
949
950
950
inputElm . val ( 'value2' ) ;
951
951
browserTrigger ( inputElm , 'change' ) ;
952
- $browser . defer . flush ( ) ;
953
952
expect ( scope . value ) . toBe ( 'value2' ) ;
954
953
955
954
if ( msie < 9 ) return ;
956
955
957
956
inputElm . val ( 'value3' ) ;
958
957
browserTrigger ( inputElm , 'input' ) ;
959
- $browser . defer . flush ( ) ;
960
958
expect ( scope . value ) . toBe ( 'value3' ) ;
961
959
} ) ) ;
962
960
} ) ;
You can’t perform that action at this time.
0 commit comments