@@ -13,7 +13,7 @@ import {
13
13
extend,
14
14
} from "../../shared/utils.js";
15
15
import { countChildScopes, countWatchers } from "../scope/scope.js";
16
- import { CACHE , EXPANDO } from "../cache/cache.js";
16
+ import { Cache , EXPANDO } from "../cache/cache.js";
17
17
import { wait } from "../../shared/test-utils";
18
18
19
19
function isUnknownElement(el) {
@@ -4903,36 +4903,36 @@ describe("$compile", () => {
4903
4903
// We compile the contents of element (i.e. not element itself)
4904
4904
// Then delete these contents and check the cache has been reset to zero
4905
4905
// Clear cache
4906
- CACHE .clear();
4906
+ Cache .clear();
4907
4907
window.angular.module("test1", ["ng"]);
4908
4908
createInjector(["test1"]).invoke(($compile) => {
4909
- expect(CACHE .size).toEqual(0);
4909
+ expect(Cache .size).toEqual(0);
4910
4910
// First with only elements at the top level
4911
4911
element = JQLite("<div><div></div></div>");
4912
4912
$compile(element[0].childNodes)($rootScope);
4913
- // expect(CACHE .size).toEqual(2);
4913
+ // expect(Cache .size).toEqual(2);
4914
4914
element.empty();
4915
- expect(CACHE .size).toEqual(0);
4915
+ expect(Cache .size).toEqual(0);
4916
4916
4917
4917
// Next with non-empty text nodes at the top level
4918
4918
// (in this case the compiler will wrap them in a <span>)
4919
4919
element = JQLite("<div>xxx</div>");
4920
4920
$compile(element[0].childNodes)($rootScope);
4921
4921
element.empty();
4922
- expect(CACHE .size).toEqual(0);
4922
+ expect(Cache .size).toEqual(0);
4923
4923
4924
4924
// Next with comment nodes at the top level
4925
4925
element = JQLite("<div><!-- comment --></div>");
4926
4926
$compile(element[0].childNodes)($rootScope);
4927
4927
element.empty();
4928
- expect(CACHE .size).toEqual(0);
4928
+ expect(Cache .size).toEqual(0);
4929
4929
4930
4930
// Finally with empty text nodes at the top level
4931
4931
element = JQLite("<div> \n<div></div> </div>");
4932
4932
$compile(element[0].childNodes)($rootScope);
4933
- //expect(CACHE .size).toEqual(2);
4933
+ //expect(Cache .size).toEqual(2);
4934
4934
element.empty();
4935
- expect(CACHE .size).toEqual(0);
4935
+ expect(Cache .size).toEqual(0);
4936
4936
});
4937
4937
});
4938
4938
@@ -13303,49 +13303,49 @@ describe("$compile", () => {
13303
13303
});
13304
13304
13305
13305
it('should not leak if two "element" transclusions are on the same element', () => {
13306
- const cacheSize = CACHE .size;
13306
+ const cacheSize = Cache .size;
13307
13307
13308
13308
element = $compile(
13309
13309
'<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>',
13310
13310
)($rootScope);
13311
- expect(CACHE .size).toEqual(cacheSize);
13311
+ expect(Cache .size).toEqual(cacheSize);
13312
13312
13313
13313
$rootScope.$apply("xs = [0,1]");
13314
- expect(CACHE .size).toEqual(cacheSize);
13314
+ expect(Cache .size).toEqual(cacheSize);
13315
13315
13316
13316
$rootScope.$apply("xs = [0]");
13317
- expect(CACHE .size).toEqual(cacheSize);
13317
+ expect(Cache .size).toEqual(cacheSize);
13318
13318
13319
13319
$rootScope.$apply("xs = []");
13320
- expect(CACHE .size).toEqual(cacheSize);
13320
+ expect(Cache .size).toEqual(cacheSize);
13321
13321
13322
13322
element.remove();
13323
- expect(CACHE .size).toEqual(cacheSize);
13323
+ expect(Cache .size).toEqual(cacheSize);
13324
13324
});
13325
13325
13326
13326
it('should not leak if two "element" transclusions are on the same element', () => {
13327
- const cacheSize = CACHE .size;
13327
+ const cacheSize = Cache .size;
13328
13328
element = $compile(
13329
13329
'<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>',
13330
13330
)($rootScope);
13331
13331
13332
13332
$rootScope.$apply("xs = [0,1]");
13333
13333
// At this point we have a bunch of comment placeholders but no real transcluded elements
13334
13334
// So the cache only contains the root element's data
13335
- expect(CACHE .size).toEqual(cacheSize);
13335
+ expect(Cache .size).toEqual(cacheSize);
13336
13336
13337
13337
$rootScope.$apply("val = true");
13338
13338
// Now we have two concrete transcluded elements plus some comments so two more cache items
13339
- expect(CACHE .size).toEqual(cacheSize);
13339
+ expect(Cache .size).toEqual(cacheSize);
13340
13340
13341
13341
$rootScope.$apply("val = false");
13342
13342
// Once again we only have comments so no transcluded elements and the cache is back to just
13343
13343
// the root element
13344
- expect(CACHE .size).toEqual(cacheSize);
13344
+ expect(Cache .size).toEqual(cacheSize);
13345
13345
13346
13346
element.remove();
13347
13347
// Now we've even removed the root element along with its cache
13348
- expect(CACHE .size).toEqual(cacheSize);
13348
+ expect(Cache .size).toEqual(cacheSize);
13349
13349
});
13350
13350
13351
13351
// it("should not leak when continuing the compilation of elements on a scope that was destroyed", () => {
@@ -13370,7 +13370,7 @@ describe("$compile", () => {
13370
13370
// link: linkFn,
13371
13371
// }));
13372
13372
// initInjector("test1");
13373
- // const cacheSize = CACHE .size;
13373
+ // const cacheSize = Cache .size;
13374
13374
// $templateCache.set("red.html", "<p>red</p>");
13375
13375
// const template = $compile(
13376
13376
// '<div ng-controller="Leak">' +
@@ -13385,7 +13385,7 @@ describe("$compile", () => {
13385
13385
// $rootScope.$digest();
13386
13386
13387
13387
// expect(linkFn).toHaveBeenCalled();
13388
- // expect(CACHE .size).toEqual(cacheSize + 2);
13388
+ // expect(Cache .size).toEqual(cacheSize + 2);
13389
13389
13390
13390
// $templateCache = new Map();
13391
13391
// const destroyedScope = $rootScope.$new();
@@ -13414,7 +13414,7 @@ describe("$compile", () => {
13414
13414
$rootScope.$apply(`xs = [${xs}]`);
13415
13415
firstRepeatedElem = element.children(".ng-scope").eq(0);
13416
13416
13417
- privateData = CACHE .get(firstRepeatedElem[0][EXPANDO]);
13417
+ privateData = Cache .get(firstRepeatedElem[0][EXPANDO]);
13418
13418
expect(privateData.events).toBeDefined();
13419
13419
13420
13420
expect(privateData.events.click).toBeDefined();
@@ -13430,7 +13430,7 @@ describe("$compile", () => {
13430
13430
13431
13431
expect(destroyCount).toBe(2);
13432
13432
expect(firstRepeatedElem.data("$scope")).not.toBeDefined();
13433
- privateData = CACHE .get(firstRepeatedElem[0][EXPANDO]);
13433
+ privateData = Cache .get(firstRepeatedElem[0][EXPANDO]);
13434
13434
expect(privateData && privateData.events).not.toBeDefined();
13435
13435
}
13436
13436
@@ -14290,7 +14290,7 @@ describe("$compile", () => {
14290
14290
14291
14291
it("should not leak memory with nested transclusion", () => {
14292
14292
let size;
14293
- const initialSize = CACHE .size;
14293
+ const initialSize = Cache .size;
14294
14294
14295
14295
element = JQLite(
14296
14296
'<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>',
@@ -14299,14 +14299,14 @@ describe("$compile", () => {
14299
14299
14300
14300
$rootScope.nums = [0, 1, 2];
14301
14301
$rootScope.$apply();
14302
- size = CACHE .size;
14302
+ size = Cache .size;
14303
14303
14304
14304
$rootScope.nums = [3, 4, 5];
14305
14305
$rootScope.$apply();
14306
- expect(CACHE .size).toEqual(size);
14306
+ expect(Cache .size).toEqual(size);
14307
14307
14308
14308
element.remove();
14309
- expect(CACHE .size).toEqual(initialSize);
14309
+ expect(Cache .size).toEqual(initialSize);
14310
14310
});
14311
14311
});
14312
14312
0 commit comments