File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -765,8 +765,8 @@ angularWidget('select', function(element){
765
765
}
766
766
}
767
767
if ( isDefined ( value ) && model . get ( ) !== value ) {
768
- onChange ( scope ) ;
769
768
model . set ( value ) ;
769
+ onChange ( scope ) ;
770
770
}
771
771
scope . $tryEval ( function ( ) {
772
772
scope . $root . $eval ( ) ;
Original file line number Diff line number Diff line change @@ -882,22 +882,28 @@ describe("widget", function(){
882
882
createSelect ( {
883
883
name :'selected' ,
884
884
'ng:options' :'value for value in values' ,
885
- 'ng:change' :'count = count + 1 '
885
+ 'ng:change' :'log = log + selected.name '
886
886
} ) ;
887
887
scope . values = [ { name :'A' } , { name :'B' } ] ;
888
888
scope . selected = scope . values [ 0 ] ;
889
- scope . count = 0 ;
889
+ scope . log = '' ;
890
890
scope . $eval ( ) ;
891
- expect ( scope . count ) . toEqual ( 0 ) ;
891
+ expect ( scope . log ) . toEqual ( '' ) ;
892
892
893
893
select . val ( '1' ) ;
894
894
browserTrigger ( select , 'change' ) ;
895
- expect ( scope . count ) . toEqual ( 1 ) ;
895
+ expect ( scope . log ) . toEqual ( 'B' ) ;
896
896
expect ( scope . selected ) . toEqual ( scope . values [ 1 ] ) ;
897
897
898
+ // ignore change event when the model doesn't change
898
899
browserTrigger ( select , 'change' ) ;
899
- expect ( scope . count ) . toEqual ( 1 ) ;
900
+ expect ( scope . log ) . toEqual ( 'B' ) ;
900
901
expect ( scope . selected ) . toEqual ( scope . values [ 1 ] ) ;
902
+
903
+ select . val ( '0' ) ;
904
+ browserTrigger ( select , 'change' ) ;
905
+ expect ( scope . log ) . toEqual ( 'BA' ) ;
906
+ expect ( scope . selected ) . toEqual ( scope . values [ 0 ] ) ;
901
907
} ) ;
902
908
903
909
it ( 'should update model on change through expression' , function ( ) {
You can’t perform that action at this time.
0 commit comments