@@ -7245,22 +7245,22 @@ describe('$compile', function() {
7245
7245
} ) ;
7246
7246
7247
7247
inject ( function ( $compile , $rootScope ) {
7248
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7248
+ var cacheSize = jqLiteCacheSize ( ) ;
7249
7249
7250
7250
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
7251
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7251
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7252
7252
7253
7253
$rootScope . $apply ( 'xs = [0,1]' ) ;
7254
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7254
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
7255
7255
7256
7256
$rootScope . $apply ( 'xs = [0]' ) ;
7257
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7257
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7258
7258
7259
7259
$rootScope . $apply ( 'xs = []' ) ;
7260
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7260
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7261
7261
7262
7262
element . remove ( ) ;
7263
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7263
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
7264
7264
} ) ;
7265
7265
} ) ;
7266
7266
@@ -7277,22 +7277,22 @@ describe('$compile', function() {
7277
7277
} ) ;
7278
7278
7279
7279
inject ( function ( $compile , $rootScope ) {
7280
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7280
+ var cacheSize = jqLiteCacheSize ( ) ;
7281
7281
7282
7282
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
7283
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7283
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7284
7284
7285
7285
$rootScope . $apply ( 'xs = [0,1]' ) ;
7286
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7286
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7287
7287
7288
7288
$rootScope . $apply ( 'xs = [0]' ) ;
7289
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7289
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7290
7290
7291
7291
$rootScope . $apply ( 'xs = []' ) ;
7292
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7292
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7293
7293
7294
7294
element . remove ( ) ;
7295
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7295
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
7296
7296
} ) ;
7297
7297
} ) ;
7298
7298
@@ -7308,26 +7308,26 @@ describe('$compile', function() {
7308
7308
} ) ;
7309
7309
7310
7310
inject ( function ( $compile , $rootScope ) {
7311
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7311
+ var cacheSize = jqLiteCacheSize ( ) ;
7312
7312
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>' ) ( $rootScope ) ;
7313
7313
7314
7314
$rootScope . $apply ( 'xs = [0,1]' ) ;
7315
7315
// At this point we have a bunch of comment placeholders but no real transcluded elements
7316
7316
// So the cache only contains the root element's data
7317
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7317
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7318
7318
7319
7319
$rootScope . $apply ( 'val = true' ) ;
7320
7320
// Now we have two concrete transcluded elements plus some comments so two more cache items
7321
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 3 ) ;
7321
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 3 ) ;
7322
7322
7323
7323
$rootScope . $apply ( 'val = false' ) ;
7324
7324
// Once again we only have comments so no transcluded elements and the cache is back to just
7325
7325
// the root element
7326
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7326
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
7327
7327
7328
7328
element . remove ( ) ;
7329
7329
// Now we've even removed the root element along with its cache
7330
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7330
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
7331
7331
} ) ;
7332
7332
} ) ;
7333
7333
@@ -7364,6 +7364,7 @@ describe('$compile', function() {
7364
7364
} ) ;
7365
7365
7366
7366
inject ( function ( $compile , $rootScope , $httpBackend , $timeout , $templateCache ) {
7367
+ var cacheSize = jqLiteCacheSize ( ) ;
7367
7368
$httpBackend . whenGET ( 'red.html' ) . respond ( '<p>red.html</p>' ) ;
7368
7369
var template = $compile (
7369
7370
'<div ng-controller="Leak">' +
@@ -7378,7 +7379,7 @@ describe('$compile', function() {
7378
7379
$timeout . flush ( ) ;
7379
7380
$httpBackend . flush ( ) ;
7380
7381
expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
7381
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7382
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
7382
7383
7383
7384
$templateCache . removeAll ( ) ;
7384
7385
var destroyedScope = $rootScope . $new ( ) ;
@@ -8161,9 +8162,7 @@ describe('$compile', function() {
8161
8162
8162
8163
it ( 'should not leak memory with nested transclusion' , function ( ) {
8163
8164
inject ( function ( $compile , $rootScope ) {
8164
- var size ;
8165
-
8166
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8165
+ var size , initialSize = jqLiteCacheSize ( ) ;
8167
8166
8168
8167
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>' ) ;
8169
8168
$compile ( element ) ( $rootScope . $new ( ) ) ;
@@ -8177,7 +8176,7 @@ describe('$compile', function() {
8177
8176
expect ( jqLiteCacheSize ( ) ) . toEqual ( size ) ;
8178
8177
8179
8178
element . remove ( ) ;
8180
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8179
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( initialSize ) ;
8181
8180
} ) ;
8182
8181
} ) ;
8183
8182
} ) ;
0 commit comments