@@ -6087,22 +6087,22 @@ describe('$compile', function() {
60876087 } ) ;
60886088
60896089 inject ( function ( $compile , $rootScope ) {
6090- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6090+ var cacheSize = jqLiteCacheSize ( ) ;
60916091
60926092 element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
6093- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6093+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
60946094
60956095 $rootScope . $apply ( 'xs = [0,1]' ) ;
6096- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
6096+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
60976097
60986098 $rootScope . $apply ( 'xs = [0]' ) ;
6099- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6099+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
61006100
61016101 $rootScope . $apply ( 'xs = []' ) ;
6102- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6102+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
61036103
61046104 element . remove ( ) ;
6105- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6105+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
61066106 } ) ;
61076107 } ) ;
61086108
@@ -6119,22 +6119,22 @@ describe('$compile', function() {
61196119 } ) ;
61206120
61216121 inject ( function ( $compile , $rootScope ) {
6122- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6122+ var cacheSize = jqLiteCacheSize ( ) ;
61236123
61246124 element = $compile ( '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>' ) ( $rootScope ) ;
6125- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6125+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
61266126
61276127 $rootScope . $apply ( 'xs = [0,1]' ) ;
6128- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6128+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
61296129
61306130 $rootScope . $apply ( 'xs = [0]' ) ;
6131- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6131+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
61326132
61336133 $rootScope . $apply ( 'xs = []' ) ;
6134- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6134+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
61356135
61366136 element . remove ( ) ;
6137- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6137+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
61386138 } ) ;
61396139 } ) ;
61406140
@@ -6150,26 +6150,26 @@ describe('$compile', function() {
61506150 } ) ;
61516151
61526152 inject ( function ( $compile , $rootScope ) {
6153- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6153+ var cacheSize = jqLiteCacheSize ( ) ;
61546154 element = $compile ( '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>' ) ( $rootScope ) ;
61556155
61566156 $rootScope . $apply ( 'xs = [0,1]' ) ;
61576157 // At this point we have a bunch of comment placeholders but no real transcluded elements
61586158 // So the cache only contains the root element's data
6159- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6159+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
61606160
61616161 $rootScope . $apply ( 'val = true' ) ;
61626162 // Now we have two concrete transcluded elements plus some comments so two more cache items
6163- expect ( jqLiteCacheSize ( ) ) . toEqual ( 3 ) ;
6163+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 3 ) ;
61646164
61656165 $rootScope . $apply ( 'val = false' ) ;
61666166 // Once again we only have comments so no transcluded elements and the cache is back to just
61676167 // the root element
6168- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6168+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
61696169
61706170 element . remove ( ) ;
61716171 // Now we've even removed the root element along with its cache
6172- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6172+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
61736173 } ) ;
61746174 } ) ;
61756175
@@ -6206,6 +6206,7 @@ describe('$compile', function() {
62066206 } ) ;
62076207
62086208 inject ( function ( $compile , $rootScope , $httpBackend , $timeout , $templateCache ) {
6209+ var cacheSize = jqLiteCacheSize ( ) ;
62096210 $httpBackend . whenGET ( 'red.html' ) . respond ( '<p>red.html</p>' ) ;
62106211 var template = $compile (
62116212 '<div ng-controller="Leak">' +
@@ -6220,7 +6221,7 @@ describe('$compile', function() {
62206221 $timeout . flush ( ) ;
62216222 $httpBackend . flush ( ) ;
62226223 expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
6223- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
6224+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
62246225
62256226 $templateCache . removeAll ( ) ;
62266227 var destroyedScope = $rootScope . $new ( ) ;
@@ -6983,9 +6984,7 @@ describe('$compile', function() {
69836984
69846985 it ( 'should not leak memory with nested transclusion' , function ( ) {
69856986 inject ( function ( $compile , $rootScope ) {
6986- var size ;
6987-
6988- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6987+ var size , initialSize = jqLiteCacheSize ( ) ;
69896988
69906989 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>' ) ;
69916990 $compile ( element ) ( $rootScope . $new ( ) ) ;
@@ -6999,7 +6998,7 @@ describe('$compile', function() {
69996998 expect ( jqLiteCacheSize ( ) ) . toEqual ( size ) ;
70006999
70017000 element . remove ( ) ;
7002- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7001+ expect ( jqLiteCacheSize ( ) ) . toEqual ( initialSize ) ;
70037002 } ) ;
70047003 } ) ;
70057004 } ) ;
0 commit comments