@@ -26,12 +26,6 @@ describe('$compile', function() {
26
26
return ! ! d . toString ( ) . match ( / S V G F o r e i g n O b j e c t / ) ;
27
27
}
28
28
29
- function countScopes ( $rootScope ) {
30
- return [ $rootScope ] . concat (
31
- getChildScopes ( $rootScope )
32
- ) . length ;
33
- }
34
-
35
29
function getChildScopes ( scope ) {
36
30
var children = [ ] ;
37
31
if ( ! scope . $$childHead ) { return children ; }
@@ -5264,19 +5258,19 @@ describe('$compile', function() {
5264
5258
'</div>' ) ( $rootScope ) ;
5265
5259
5266
5260
$rootScope . $apply ( 't = false' ) ;
5267
- expect ( countScopes ( $rootScope ) ) . toBe ( 2 ) ;
5261
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 1 ) ;
5268
5262
expect ( element . text ( ) ) . toBe ( '' ) ;
5269
5263
5270
5264
$rootScope . $apply ( 't = true' ) ;
5271
- expect ( countScopes ( $rootScope ) ) . toBe ( 5 ) ;
5265
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 4 ) ;
5272
5266
expect ( element . text ( ) ) . toBe ( 'Success' ) ;
5273
5267
5274
5268
$rootScope . $apply ( 't = false' ) ;
5275
- expect ( countScopes ( $rootScope ) ) . toBe ( 2 ) ;
5269
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 1 ) ;
5276
5270
expect ( element . text ( ) ) . toBe ( '' ) ;
5277
5271
5278
5272
$rootScope . $apply ( 't = true' ) ;
5279
- expect ( countScopes ( $rootScope ) ) . toBe ( 5 ) ;
5273
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 4 ) ;
5280
5274
expect ( element . text ( ) ) . toBe ( 'Success' ) ;
5281
5275
} ) ;
5282
5276
} ) ;
@@ -5301,19 +5295,19 @@ describe('$compile', function() {
5301
5295
'</div>' ) ( $rootScope ) ;
5302
5296
5303
5297
$rootScope . $apply ( 't = false' ) ;
5304
- expect ( countScopes ( $rootScope ) ) . toBe ( 2 ) ;
5298
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 1 ) ;
5305
5299
expect ( element . text ( ) ) . toBe ( '' ) ;
5306
5300
5307
5301
$rootScope . $apply ( 't = true' ) ;
5308
- expect ( countScopes ( $rootScope ) ) . toBe ( 5 ) ;
5302
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 4 ) ;
5309
5303
expect ( element . text ( ) ) . toBe ( 'Success' ) ;
5310
5304
5311
5305
$rootScope . $apply ( 't = false' ) ;
5312
- expect ( countScopes ( $rootScope ) ) . toBe ( 2 ) ;
5306
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 1 ) ;
5313
5307
expect ( element . text ( ) ) . toBe ( '' ) ;
5314
5308
5315
5309
$rootScope . $apply ( 't = true' ) ;
5316
- expect ( countScopes ( $rootScope ) ) . toBe ( 5 ) ;
5310
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 4 ) ;
5317
5311
expect ( element . text ( ) ) . toBe ( 'Success' ) ;
5318
5312
} ) ;
5319
5313
} ) ;
@@ -5345,22 +5339,22 @@ describe('$compile', function() {
5345
5339
$rootScope . $apply ( 't = true' ) ;
5346
5340
expect ( element . text ( ) ) . toContain ( 'msg-1' ) ;
5347
5341
// Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
5348
- expect ( countScopes ( $rootScope ) ) . toEqual ( 4 ) ;
5342
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 3 ) ;
5349
5343
5350
5344
$rootScope . $apply ( 't = false' ) ;
5351
5345
expect ( element . text ( ) ) . not . toContain ( 'msg-1' ) ;
5352
5346
// Expected scopes: $rootScope
5353
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5347
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5354
5348
5355
5349
$rootScope . $apply ( 't = true' ) ;
5356
5350
expect ( element . text ( ) ) . toContain ( 'msg-1' ) ;
5357
5351
// Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
5358
- expect ( countScopes ( $rootScope ) ) . toEqual ( 4 ) ;
5352
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 3 ) ;
5359
5353
5360
5354
$rootScope . $apply ( 't = false' ) ;
5361
5355
expect ( element . text ( ) ) . not . toContain ( 'msg-1' ) ;
5362
5356
// Expected scopes: $rootScope
5363
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5357
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5364
5358
} ) ) ;
5365
5359
5366
5360
@@ -5377,22 +5371,22 @@ describe('$compile', function() {
5377
5371
$rootScope . $apply ( 't = true' ) ;
5378
5372
expect ( element . text ( ) ) . toContain ( 'msg-1msg-1' ) ;
5379
5373
// Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
5380
- expect ( countScopes ( $rootScope ) ) . toEqual ( 4 ) ;
5374
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 3 ) ;
5381
5375
5382
5376
$rootScope . $apply ( 't = false' ) ;
5383
5377
expect ( element . text ( ) ) . not . toContain ( 'msg-1msg-1' ) ;
5384
5378
// Expected scopes: $rootScope
5385
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5379
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5386
5380
5387
5381
$rootScope . $apply ( 't = true' ) ;
5388
5382
expect ( element . text ( ) ) . toContain ( 'msg-1msg-1' ) ;
5389
5383
// Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
5390
- expect ( countScopes ( $rootScope ) ) . toEqual ( 4 ) ;
5384
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 3 ) ;
5391
5385
5392
5386
$rootScope . $apply ( 't = false' ) ;
5393
5387
expect ( element . text ( ) ) . not . toContain ( 'msg-1msg-1' ) ;
5394
5388
// Expected scopes: $rootScope
5395
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5389
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5396
5390
} ) ) ;
5397
5391
5398
5392
@@ -5408,22 +5402,22 @@ describe('$compile', function() {
5408
5402
$rootScope . $apply ( 't = true' ) ;
5409
5403
expect ( element . html ( ) ) . toContain ( 'some comment' ) ;
5410
5404
// Expected scopes: $rootScope, ngIf, transclusion
5411
- expect ( countScopes ( $rootScope ) ) . toEqual ( 3 ) ;
5405
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 2 ) ;
5412
5406
5413
5407
$rootScope . $apply ( 't = false' ) ;
5414
5408
expect ( element . html ( ) ) . not . toContain ( 'some comment' ) ;
5415
5409
// Expected scopes: $rootScope
5416
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5410
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5417
5411
5418
5412
$rootScope . $apply ( 't = true' ) ;
5419
5413
expect ( element . html ( ) ) . toContain ( 'some comment' ) ;
5420
5414
// Expected scopes: $rootScope, ngIf, transclusion
5421
- expect ( countScopes ( $rootScope ) ) . toEqual ( 3 ) ;
5415
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 2 ) ;
5422
5416
5423
5417
$rootScope . $apply ( 't = false' ) ;
5424
5418
expect ( element . html ( ) ) . not . toContain ( 'some comment' ) ;
5425
5419
// Expected scopes: $rootScope
5426
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5420
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5427
5421
} ) ) ;
5428
5422
5429
5423
it ( 'should not leak the transclude scope if the transcluded contains only text nodes' ,
@@ -5438,22 +5432,22 @@ describe('$compile', function() {
5438
5432
$rootScope . $apply ( 't = true' ) ;
5439
5433
expect ( element . html ( ) ) . toContain ( 'some text' ) ;
5440
5434
// Expected scopes: $rootScope, ngIf, transclusion
5441
- expect ( countScopes ( $rootScope ) ) . toEqual ( 3 ) ;
5435
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 2 ) ;
5442
5436
5443
5437
$rootScope . $apply ( 't = false' ) ;
5444
5438
expect ( element . html ( ) ) . not . toContain ( 'some text' ) ;
5445
5439
// Expected scopes: $rootScope
5446
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5440
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5447
5441
5448
5442
$rootScope . $apply ( 't = true' ) ;
5449
5443
expect ( element . html ( ) ) . toContain ( 'some text' ) ;
5450
5444
// Expected scopes: $rootScope, ngIf, transclusion
5451
- expect ( countScopes ( $rootScope ) ) . toEqual ( 3 ) ;
5445
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 2 ) ;
5452
5446
5453
5447
$rootScope . $apply ( 't = false' ) ;
5454
5448
expect ( element . html ( ) ) . not . toContain ( 'some text' ) ;
5455
5449
// Expected scopes: $rootScope
5456
- expect ( countScopes ( $rootScope ) ) . toEqual ( 1 ) ;
5450
+ expect ( $rootScope . $countChildScopes ( ) ) . toBe ( 0 ) ;
5457
5451
} ) ) ;
5458
5452
5459
5453
it ( 'should mark as destroyed all sub scopes of the scope being destroyed' ,
0 commit comments