@@ -7245,22 +7245,22 @@ describe('$compile', function() {
72457245 } ) ;
72467246
72477247 inject ( function ( $compile , $rootScope ) {
7248- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7248+ var cacheSize = jqLiteCacheSize ( ) ;
72497249
72507250 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 ) ;
72527252
72537253 $rootScope . $apply ( 'xs = [0,1]' ) ;
7254- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7254+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
72557255
72567256 $rootScope . $apply ( 'xs = [0]' ) ;
7257- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7257+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
72587258
72597259 $rootScope . $apply ( 'xs = []' ) ;
7260- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7260+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
72617261
72627262 element . remove ( ) ;
7263- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7263+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
72647264 } ) ;
72657265 } ) ;
72667266
@@ -7277,22 +7277,22 @@ describe('$compile', function() {
72777277 } ) ;
72787278
72797279 inject ( function ( $compile , $rootScope ) {
7280- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7280+ var cacheSize = jqLiteCacheSize ( ) ;
72817281
72827282 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 ) ;
72847284
72857285 $rootScope . $apply ( 'xs = [0,1]' ) ;
7286- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7286+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
72877287
72887288 $rootScope . $apply ( 'xs = [0]' ) ;
7289- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7289+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
72907290
72917291 $rootScope . $apply ( 'xs = []' ) ;
7292- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7292+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
72937293
72947294 element . remove ( ) ;
7295- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7295+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
72967296 } ) ;
72977297 } ) ;
72987298
@@ -7308,26 +7308,26 @@ describe('$compile', function() {
73087308 } ) ;
73097309
73107310 inject ( function ( $compile , $rootScope ) {
7311- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7311+ var cacheSize = jqLiteCacheSize ( ) ;
73127312 element = $compile ( '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>' ) ( $rootScope ) ;
73137313
73147314 $rootScope . $apply ( 'xs = [0,1]' ) ;
73157315 // At this point we have a bunch of comment placeholders but no real transcluded elements
73167316 // So the cache only contains the root element's data
7317- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7317+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
73187318
73197319 $rootScope . $apply ( 'val = true' ) ;
73207320 // 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 ) ;
73227322
73237323 $rootScope . $apply ( 'val = false' ) ;
73247324 // Once again we only have comments so no transcluded elements and the cache is back to just
73257325 // the root element
7326- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
7326+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
73277327
73287328 element . remove ( ) ;
73297329 // Now we've even removed the root element along with its cache
7330- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7330+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
73317331 } ) ;
73327332 } ) ;
73337333
@@ -7364,6 +7364,7 @@ describe('$compile', function() {
73647364 } ) ;
73657365
73667366 inject ( function ( $compile , $rootScope , $httpBackend , $timeout , $templateCache ) {
7367+ var cacheSize = jqLiteCacheSize ( ) ;
73677368 $httpBackend . whenGET ( 'red.html' ) . respond ( '<p>red.html</p>' ) ;
73687369 var template = $compile (
73697370 '<div ng-controller="Leak">' +
@@ -7378,7 +7379,7 @@ describe('$compile', function() {
73787379 $timeout . flush ( ) ;
73797380 $httpBackend . flush ( ) ;
73807381 expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
7381- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
7382+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
73827383
73837384 $templateCache . removeAll ( ) ;
73847385 var destroyedScope = $rootScope . $new ( ) ;
@@ -8161,9 +8162,7 @@ describe('$compile', function() {
81618162
81628163 it ( 'should not leak memory with nested transclusion' , function ( ) {
81638164 inject ( function ( $compile , $rootScope ) {
8164- var size ;
8165-
8166- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8165+ var size , initialSize = jqLiteCacheSize ( ) ;
81678166
81688167 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>' ) ;
81698168 $compile ( element ) ( $rootScope . $new ( ) ) ;
@@ -8177,7 +8176,7 @@ describe('$compile', function() {
81778176 expect ( jqLiteCacheSize ( ) ) . toEqual ( size ) ;
81788177
81798178 element . remove ( ) ;
8180- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
8179+ expect ( jqLiteCacheSize ( ) ) . toEqual ( initialSize ) ;
81818180 } ) ;
81828181 } ) ;
81838182 } ) ;
0 commit comments