@@ -468,10 +468,59 @@ describe('ngMessages', function() {
468
468
469
469
inject ( function ( $rootScope , $compile ) {
470
470
471
- element = $compile ( '<div ng-messages="col"><div class="wrapper">' +
472
- ' <div remove-me ng-message="required">Fill in the text field.</div>' +
473
- ' <div ng-message="extra">Extra error message.</div>' +
474
- '</div></div>' ) ( $rootScope ) ;
471
+ element = $compile (
472
+ '<div ng-messages="col">' +
473
+ '<div class="wrapper">' +
474
+ '<div remove-me ng-message="required">Fill in the text field.</div>' +
475
+ '<div ng-message="extra">Extra error message.</div>' +
476
+ '</div>' +
477
+ '</div>'
478
+ ) ( $rootScope ) ;
479
+
480
+ $rootScope . $apply ( function ( ) {
481
+ $rootScope . col = {
482
+ required : true ,
483
+ extra : false
484
+ } ;
485
+ } ) ;
486
+
487
+ expect ( messageChildren ( element ) . length ) . toBe ( 1 ) ;
488
+ expect ( trim ( element . text ( ) ) ) . toEqual ( 'Fill in the text field.' ) ;
489
+
490
+ $rootScope . $apply ( 'hide = true' ) ;
491
+
492
+ expect ( messageChildren ( element ) . length ) . toBe ( 0 ) ;
493
+ } ) ;
494
+ } ) ;
495
+
496
+
497
+ xit ( 'should not crash when a deeply nested messages is removed' , function ( ) {
498
+
499
+ module ( function ( $compileProvider ) {
500
+ $compileProvider . directive ( 'removeMe' , function ( ) {
501
+ return {
502
+ link : function ( scope , element ) {
503
+ scope . $watch ( 'hide' , function ( newVal ) {
504
+ if ( newVal === true ) element . remove ( ) ;
505
+ } ) ;
506
+ }
507
+ } ;
508
+ } ) ;
509
+ } ) ;
510
+
511
+ inject ( function ( $rootScope , $compile ) {
512
+
513
+ element = $compile (
514
+ '<div ng-messages="col">' +
515
+ '<div class="another-wrapper">' +
516
+ '<div class="wrapper">' +
517
+ '<div remove-me ng-message="required">Fill in the text field.</div>' +
518
+ '<div ng-message="extra">Extra error message.</div>' +
519
+ '</div>' +
520
+ '<div ng-message="different">Different error message.</div>' +
521
+ '</div>' +
522
+ '</div>'
523
+ ) ( $rootScope ) ;
475
524
476
525
$rootScope . $apply ( function ( ) {
477
526
$rootScope . col = {
0 commit comments