@@ -412,7 +412,8 @@ describe('ngMessages', function() {
412
412
} ) ) ;
413
413
414
414
415
- it ( 'should not crash when the messages are transcluded, the first message is visible, and ngMessages is removed by ngIf' , function ( ) {
415
+ it ( 'should not crash or leak memory when the messages are transcluded, the first message is' +
416
+ 'visible, and ngMessages is removed by ngIf' , function ( ) {
416
417
417
418
module ( function ( $compileProvider ) {
418
419
$compileProvider . directive ( 'messageWrap' , function ( ) {
@@ -444,14 +445,6 @@ describe('ngMessages', function() {
444
445
expect ( messageChildren ( element ) . length ) . toBe ( 1 ) ;
445
446
expect ( trim ( element . text ( ) ) ) . toEqual ( 'Fill in the text field.' ) ;
446
447
447
- $rootScope . $apply ( function ( ) {
448
- $rootScope . col . required = true ;
449
- $rootScope . col . extra = false ;
450
- } ) ;
451
-
452
- expect ( messageChildren ( element ) . length ) . toBe ( 1 ) ;
453
- expect ( trim ( element . text ( ) ) ) . toEqual ( 'Fill in the text field.' ) ;
454
-
455
448
$rootScope . $apply ( 'show = false' ) ;
456
449
457
450
expect ( messageChildren ( element ) . length ) . toBe ( 0 ) ;
@@ -864,4 +857,43 @@ describe('ngMessages', function() {
864
857
expect ( s ( element . text ( ) ) ) . toEqual ( "YYYZZZX" ) ;
865
858
} ) ) ;
866
859
} ) ;
860
+
861
+ it ( 'should sustain the order when messages are included by a template with an async template' , function ( ) {
862
+ module ( function ( $compileProvider ) {
863
+ $compileProvider . directive ( 'inclusor' , function ( ) {
864
+ return {
865
+ templateUrl : 'include.html'
866
+ } ;
867
+ } ) ;
868
+ } ) ;
869
+
870
+ inject ( function ( $compile , $rootScope , $templateCache ) {
871
+ var html ;
872
+ $templateCache . put ( 'include.html' , '<div ng-message="a">A</div>' +
873
+ '<div ng-message="b">B</div>' ) ;
874
+
875
+ html = '<div ng-messages-multiple ng-messages="items"><div inclusor>' +
876
+ '</div><div ng-message="c">C</div><div ng-message="d">D</div></div>' ;
877
+ $rootScope . items = { } ;
878
+
879
+ $rootScope . $apply ( function ( ) {
880
+ $rootScope . items . b = true ;
881
+ $rootScope . items . d = true ;
882
+ } ) ;
883
+
884
+ element = $compile ( html ) ( $rootScope ) ;
885
+ $rootScope . $digest ( ) ;
886
+
887
+ expect ( element . text ( ) . trim ( ) ) . toBe ( 'BD' ) ;
888
+
889
+ $rootScope . $apply ( function ( ) {
890
+ $rootScope . items . a = true ;
891
+ $rootScope . items . c = true ;
892
+ } ) ;
893
+
894
+ expect ( element . text ( ) . trim ( ) ) . toBe ( 'ABCD' ) ;
895
+ } ) ;
896
+
897
+ } ) ;
898
+
867
899
} ) ;
0 commit comments