@@ -6087,22 +6087,22 @@ describe('$compile', function() {
6087
6087
} ) ;
6088
6088
6089
6089
inject ( function ( $compile , $rootScope ) {
6090
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6090
+ var cacheSize = jqLiteCacheSize ( ) ;
6091
6091
6092
6092
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 ) ;
6094
6094
6095
6095
$rootScope . $apply ( 'xs = [0,1]' ) ;
6096
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
6096
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
6097
6097
6098
6098
$rootScope . $apply ( 'xs = [0]' ) ;
6099
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6099
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
6100
6100
6101
6101
$rootScope . $apply ( 'xs = []' ) ;
6102
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6102
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
6103
6103
6104
6104
element . remove ( ) ;
6105
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6105
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
6106
6106
} ) ;
6107
6107
} ) ;
6108
6108
@@ -6119,22 +6119,22 @@ describe('$compile', function() {
6119
6119
} ) ;
6120
6120
6121
6121
inject ( function ( $compile , $rootScope ) {
6122
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6122
+ var cacheSize = jqLiteCacheSize ( ) ;
6123
6123
6124
6124
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 ) ;
6126
6126
6127
6127
$rootScope . $apply ( 'xs = [0,1]' ) ;
6128
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6128
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
6129
6129
6130
6130
$rootScope . $apply ( 'xs = [0]' ) ;
6131
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6131
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
6132
6132
6133
6133
$rootScope . $apply ( 'xs = []' ) ;
6134
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6134
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
6135
6135
6136
6136
element . remove ( ) ;
6137
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6137
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize ) ;
6138
6138
} ) ;
6139
6139
} ) ;
6140
6140
@@ -6150,26 +6150,26 @@ describe('$compile', function() {
6150
6150
} ) ;
6151
6151
6152
6152
inject ( function ( $compile , $rootScope ) {
6153
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6153
+ var cacheSize = jqLiteCacheSize ( ) ;
6154
6154
element = $compile ( '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>' ) ( $rootScope ) ;
6155
6155
6156
6156
$rootScope . $apply ( 'xs = [0,1]' ) ;
6157
6157
// At this point we have a bunch of comment placeholders but no real transcluded elements
6158
6158
// So the cache only contains the root element's data
6159
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6159
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
6160
6160
6161
6161
$rootScope . $apply ( 'val = true' ) ;
6162
6162
// 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 ) ;
6164
6164
6165
6165
$rootScope . $apply ( 'val = false' ) ;
6166
6166
// Once again we only have comments so no transcluded elements and the cache is back to just
6167
6167
// the root element
6168
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 1 ) ;
6168
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 1 ) ;
6169
6169
6170
6170
element . remove ( ) ;
6171
6171
// Now we've even removed the root element along with its cache
6172
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6172
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 0 ) ;
6173
6173
} ) ;
6174
6174
} ) ;
6175
6175
@@ -6206,6 +6206,7 @@ describe('$compile', function() {
6206
6206
} ) ;
6207
6207
6208
6208
inject ( function ( $compile , $rootScope , $httpBackend , $timeout , $templateCache ) {
6209
+ var cacheSize = jqLiteCacheSize ( ) ;
6209
6210
$httpBackend . whenGET ( 'red.html' ) . respond ( '<p>red.html</p>' ) ;
6210
6211
var template = $compile (
6211
6212
'<div ng-controller="Leak">' +
@@ -6220,7 +6221,7 @@ describe('$compile', function() {
6220
6221
$timeout . flush ( ) ;
6221
6222
$httpBackend . flush ( ) ;
6222
6223
expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
6223
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 2 ) ;
6224
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( cacheSize + 2 ) ;
6224
6225
6225
6226
$templateCache . removeAll ( ) ;
6226
6227
var destroyedScope = $rootScope . $new ( ) ;
@@ -6983,9 +6984,7 @@ describe('$compile', function() {
6983
6984
6984
6985
it ( 'should not leak memory with nested transclusion' , function ( ) {
6985
6986
inject ( function ( $compile , $rootScope ) {
6986
- var size ;
6987
-
6988
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
6987
+ var size , initialSize = jqLiteCacheSize ( ) ;
6989
6988
6990
6989
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>' ) ;
6991
6990
$compile ( element ) ( $rootScope . $new ( ) ) ;
@@ -6999,7 +6998,7 @@ describe('$compile', function() {
6999
6998
expect ( jqLiteCacheSize ( ) ) . toEqual ( size ) ;
7000
6999
7001
7000
element . remove ( ) ;
7002
- expect ( jqLiteCacheSize ( ) ) . toEqual ( 0 ) ;
7001
+ expect ( jqLiteCacheSize ( ) ) . toEqual ( initialSize ) ;
7003
7002
} ) ;
7004
7003
} ) ;
7005
7004
} ) ;
0 commit comments