@@ -7321,22 +7321,22 @@ describe('$compile', function() {
7321
7321
} ) ;
7322
7322
7323
7323
inject ( function ( $compile , $rootScope ) {
7324
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7324
+ var cacheSize = jqLiteCacheSize ( ) ;
7325
7325
7326
7326
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
7327
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7327
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7328
7328
7329
7329
$rootScope . $apply ( 'xs = [0,1]' ) ;
7330
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7330
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
7331
7331
7332
7332
$rootScope . $apply ( 'xs = [0]' ) ;
7333
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7333
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7334
7334
7335
7335
$rootScope . $apply ( 'xs = []' ) ;
7336
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7336
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7337
7337
7338
7338
element . remove ( ) ;
7339
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7339
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
7340
7340
} ) ;
7341
7341
} ) ;
7342
7342
@@ -7353,22 +7353,22 @@ describe('$compile', function() {
7353
7353
} ) ;
7354
7354
7355
7355
inject ( function ( $compile , $rootScope ) {
7356
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7356
+ var cacheSize = jqLiteCacheSize ( ) ;
7357
7357
7358
7358
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
7359
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7359
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7360
7360
7361
7361
$rootScope . $apply ( 'xs = [0,1]' ) ;
7362
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7362
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7363
7363
7364
7364
$rootScope . $apply ( 'xs = [0]' ) ;
7365
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7365
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7366
7366
7367
7367
$rootScope . $apply ( 'xs = []' ) ;
7368
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7368
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7369
7369
7370
7370
element . remove ( ) ;
7371
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7371
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7372
7372
} ) ;
7373
7373
} ) ;
7374
7374
@@ -7384,26 +7384,26 @@ describe('$compile', function() {
7384
7384
} ) ;
7385
7385
7386
7386
inject ( function ( $compile , $rootScope ) {
7387
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7387
+ var cacheSize = jqLiteCacheSize ( ) ;
7388
7388
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>' ) ( $rootScope ) ;
7389
7389
7390
7390
$rootScope . $apply ( 'xs = [0,1]' ) ;
7391
7391
// At this point we have a bunch of comment placeholders but no real transcluded elements
7392
7392
// So the cache only contains the root element's data
7393
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7393
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7394
7394
7395
7395
$rootScope . $apply ( 'val = true' ) ;
7396
7396
// Now we have two concrete transcluded elements plus some comments so two more cache items
7397
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 3 ) ;
7397
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 3 ) ;
7398
7398
7399
7399
$rootScope . $apply ( 'val = false' ) ;
7400
7400
// Once again we only have comments so no transcluded elements and the cache is back to just
7401
7401
// the root element
7402
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7402
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7403
7403
7404
7404
element . remove ( ) ;
7405
7405
// Now we've even removed the root element along with its cache
7406
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7406
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
7407
7407
} ) ;
7408
7408
} ) ;
7409
7409
@@ -7440,6 +7440,7 @@ describe('$compile', function() {
7440
7440
} ) ;
7441
7441
7442
7442
inject ( function ( $compile , $rootScope , $httpBackend , $timeout , $templateCache ) {
7443
+ var cacheSize = jqLiteCacheSize ( ) ;
7443
7444
$httpBackend . whenGET ( 'red.html' ) . respond ( '<p>red.html</p>' ) ;
7444
7445
var template = $compile (
7445
7446
'<div ng-controller="Leak">' +
@@ -7454,7 +7455,7 @@ describe('$compile', function() {
7454
7455
$timeout . flush ( ) ;
7455
7456
$httpBackend . flush ( ) ;
7456
7457
expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
7457
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7458
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
7458
7459
7459
7460
$templateCache . removeAll ( ) ;
7460
7461
var destroyedScope = $rootScope . $new ( ) ;
@@ -8237,9 +8238,7 @@ describe('$compile', function() {
8237
8238
8238
8239
it ( 'should not leak memory with nested transclusion' , function ( ) {
8239
8240
inject ( function ( $compile , $rootScope ) {
8240
- var size ;
8241
-
8242
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8241
+ var size , initialSize = jqLiteCacheSize ( ) ;
8243
8242
8244
8243
element = jqLite ( '<div><ul><li ng-repeat="n in nums">{{n}} => <i ng-if="0 === n%2">Even</i><i ng-if="1 === n%2">Odd</i></li></ul></div>' ) ;
8245
8244
$compile ( element ) ( $rootScope . $new ( ) ) ;
@@ -8253,7 +8252,7 @@ describe('$compile', function() {
8253
8252
expect ( jqLiteCacheSize ( ) ) . toEqual ( size ) ;
8254
8253
8255
8254
element . remove ( ) ;
8256
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8255
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( initialSize ) ;
8257
8256
} ) ;
8258
8257
} ) ;
8259
8258
} ) ;
0 commit comments