@@ -49,6 +49,12 @@ describe('Scope', function() {
49
49
} ) ) ;
50
50
} ) ;
51
51
52
+ describe ( '$skipChildWatchers' , function ( ) {
53
+ it ( 'should initially be false' , inject ( function ( $rootScope ) {
54
+ expect ( $rootScope . $skipChildWatchers ) . toBeDefined ( ) ;
55
+ expect ( $rootScope . $skipChildWatchers ) . toEqual ( false ) ;
56
+ } ) ) ;
57
+ } ) ;
52
58
53
59
describe ( 'this' , function ( ) {
54
60
it ( 'should evaluate \'this\' to be the scope' , inject ( function ( $rootScope ) {
@@ -458,6 +464,59 @@ describe('Scope', function() {
458
464
expect ( log ) . toEqual ( [ ] ) ;
459
465
} ) ) ;
460
466
467
+ it ( 'should $digest scope marked $skipChildWatchers to true, but not its children.' ,
468
+ inject ( function ( $rootScope ) {
469
+ var log = '' ,
470
+ parent = $rootScope . $new ( ) ,
471
+ childA = parent . $new ( ) ,
472
+ childB = parent . $new ( ) ;
473
+
474
+ parent . $watch ( function ( ) { log += 'a' ; } ) ;
475
+ childA . $watch ( function ( ) { log += 'b' ; } ) ;
476
+ childB . $watch ( function ( ) { log += 'c' ; } ) ;
477
+ parent . $skipChildWatchers = true ;
478
+
479
+ $rootScope . $digest ( ) ;
480
+ expect ( log ) . toEqual ( 'aa' ) ;
481
+ } ) ) ;
482
+
483
+ it ( 'should $digest children after parent\'s $skipChildWatchers is set back to false' ,
484
+ inject ( function ( $rootScope ) {
485
+ var log = '' ,
486
+ parent = $rootScope . $new ( ) ,
487
+ childA = parent . $new ( ) ,
488
+ childB = parent . $new ( ) ;
489
+
490
+ parent . $watch ( function ( ) { log += 'a' } ) ;
491
+ childA . $watch ( 'a' , function ( v ) {
492
+ $rootScope . b = v ;
493
+ log += 'b'
494
+ } ) ;
495
+ childB . $watch ( 'b' , function ( v ) {
496
+ $rootScope . c = v ;
497
+ log += 'c'
498
+ } ) ;
499
+
500
+ $rootScope . $digest ( ) ;
501
+ expect ( log ) . toEqual ( 'abca' ) ;
502
+
503
+ log = '' ;
504
+ parent . a = 1 ;
505
+ parent . $skipChildWatchers = true ;
506
+
507
+ $rootScope . $digest ( ) ;
508
+ expect ( log ) . toEqual ( 'a' ) ;
509
+ expect ( $rootScope . b ) . toBeUndefined ( ) ;
510
+ expect ( $rootScope . c ) . toBeUndefined ( ) ;
511
+
512
+ log = '' ;
513
+ parent . $skipChildWatchers = false ;
514
+
515
+ $rootScope . $digest ( ) ;
516
+ expect ( log ) . toEqual ( 'abca' ) ;
517
+ expect ( $rootScope . b ) . toEqual ( 1 ) ;
518
+ expect ( $rootScope . c ) . toEqual ( 1 ) ;
519
+ } ) ) ;
461
520
462
521
describe ( '$watch deregistration' , function ( ) {
463
522
0 commit comments