This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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 @@ -762,8 +762,8 @@ angularWidget('select', function(element){
762
762
}
763
763
}
764
764
if ( isDefined ( value ) && model . get ( ) !== value ) {
765
- onChange ( scope ) ;
766
765
model . set ( value ) ;
766
+ onChange ( scope ) ;
767
767
}
768
768
scope . $root . $apply ( ) ;
769
769
} finally {
Original file line number Diff line number Diff line change @@ -900,22 +900,28 @@ describe("widget", function(){
900
900
createSelect ( {
901
901
name :'selected' ,
902
902
'ng:options' :'value for value in values' ,
903
- 'ng:change' :'count = count + 1 '
903
+ 'ng:change' :'log = log + selected.name '
904
904
} ) ;
905
905
scope . values = [ { name :'A' } , { name :'B' } ] ;
906
906
scope . selected = scope . values [ 0 ] ;
907
- scope . count = 0 ;
907
+ scope . log = '' ;
908
908
scope . $digest ( ) ;
909
- expect ( scope . count ) . toEqual ( 0 ) ;
909
+ expect ( scope . log ) . toEqual ( '' ) ;
910
910
911
911
select . val ( '1' ) ;
912
912
browserTrigger ( select , 'change' ) ;
913
- expect ( scope . count ) . toEqual ( 1 ) ;
913
+ expect ( scope . log ) . toEqual ( 'B' ) ;
914
914
expect ( scope . selected ) . toEqual ( scope . values [ 1 ] ) ;
915
915
916
+ // ignore change event when the model doesn't change
916
917
browserTrigger ( select , 'change' ) ;
917
- expect ( scope . count ) . toEqual ( 1 ) ;
918
+ expect ( scope . log ) . toEqual ( 'B' ) ;
918
919
expect ( scope . selected ) . toEqual ( scope . values [ 1 ] ) ;
920
+
921
+ select . val ( '0' ) ;
922
+ browserTrigger ( select , 'change' ) ;
923
+ expect ( scope . log ) . toEqual ( 'BA' ) ;
924
+ expect ( scope . selected ) . toEqual ( scope . values [ 0 ] ) ;
919
925
} ) ;
920
926
921
927
it ( 'should update model on change through expression' , function ( ) {
You can’t perform that action at this time.
0 commit comments