@angular-wave/angular.ts 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/angular.spec.js +2 -2
  5. package/src/animations/animate-children-directive.js +1 -1
  6. package/src/animations/animate-css-driver.js +2 -2
  7. package/src/animations/animate-css.js +1 -1
  8. package/src/animations/animate-js.js +1 -1
  9. package/src/animations/animate-queue.js +2 -2
  10. package/src/animations/animate.js +2 -2
  11. package/src/animations/animate.spec.js +3 -3
  12. package/src/animations/animation.js +2 -2
  13. package/src/binding.spec.js +1 -1
  14. package/src/core/cache/cache.js +1 -1
  15. package/src/core/compile/attributes.js +3 -3
  16. package/src/core/compile/compile.js +13 -140
  17. package/src/core/compile/compile.md +0 -8
  18. package/src/core/compile/compile.spec.js +35 -639
  19. package/src/core/controller/controller.js +1 -1
  20. package/src/core/di/injector.js +1 -1
  21. package/src/core/di/injector.spec.js +1 -1
  22. package/src/core/di/internal-injector.js +1 -1
  23. package/src/core/di/ng-module.js +1 -1
  24. package/src/core/filter/filter.js +1 -1
  25. package/src/core/interpolate/interpolate.js +1 -1
  26. package/src/core/interval/interval-factory.js +1 -1
  27. package/src/core/interval/interval.js +1 -1
  28. package/src/core/location/location.js +3 -3
  29. package/src/core/on.spec.js +1 -1
  30. package/src/core/parse/interpreter.js +1 -1
  31. package/src/core/prop.spec.js +2 -2
  32. package/src/core/q/q.js +1 -1
  33. package/src/core/root-element.spec.js +1 -1
  34. package/src/core/sanitize/sanitize-uri.js +1 -1
  35. package/src/core/sce/sce.js +2 -2
  36. package/src/core/sce/sce.spec.js +1 -1
  37. package/src/core/scope/scope.js +1 -1
  38. package/src/core/scope/scope.spec.js +1 -1
  39. package/src/core/timeout/timeout.js +1 -1
  40. package/src/core/url-utils/url-utils.js +1 -1
  41. package/src/directive/aria/aria.js +1 -1
  42. package/src/directive/aria/aria.spec.js +1 -1
  43. package/src/directive/attrs/attrs.js +3 -3
  44. package/src/directive/attrs/attrs.spec.js +1 -1
  45. package/src/directive/attrs/boolean.spec.js +1 -1
  46. package/src/directive/attrs/element-style.spec.js +1 -1
  47. package/src/directive/attrs/src.spec.js +1 -1
  48. package/src/directive/bind/bind.js +1 -1
  49. package/src/directive/bind/bind.spec.js +1 -1
  50. package/src/directive/bind/bing-html.spec.js +1 -1
  51. package/src/directive/change/change.spec.js +1 -1
  52. package/src/directive/class/class.js +1 -1
  53. package/src/directive/class/class.spec.js +2 -2
  54. package/src/directive/cloak/cloak.spec.js +1 -1
  55. package/src/directive/controller/controller.spec.js +2 -2
  56. package/src/directive/events/click.spec.js +1 -1
  57. package/src/directive/events/event.spec.js +1 -1
  58. package/src/directive/events/events.js +2 -2
  59. package/src/directive/form/form.js +2 -2
  60. package/src/directive/form/form.spec.js +1 -1
  61. package/src/directive/if/if.js +2 -3
  62. package/src/directive/if/if.md +0 -1
  63. package/src/directive/if/if.spec.js +2 -2
  64. package/src/directive/include/include.js +3 -3
  65. package/src/directive/include/include.spec.js +2 -2
  66. package/src/directive/init/init.spec.js +1 -1
  67. package/src/directive/input/input.js +1 -1
  68. package/src/directive/input/input.spec.js +1 -1
  69. package/src/directive/messages/messages.js +1 -1
  70. package/src/directive/messages/messages.spec.js +3 -3
  71. package/src/directive/model/model.js +6 -6
  72. package/src/directive/model/model.spec.js +2 -2
  73. package/src/directive/model-options/model-options.js +1 -1
  74. package/src/directive/model-options/model-options.spec.js +2 -2
  75. package/src/directive/non-bindable/non-bindable.spec.js +1 -1
  76. package/src/directive/observe/observe.spec.js +1 -1
  77. package/src/directive/options/options.js +6 -2
  78. package/src/directive/options/options.spec.js +2 -2
  79. package/src/directive/ref/href.spec.js +2 -2
  80. package/src/directive/ref/ref.js +1 -1
  81. package/src/directive/repeat/repeat.js +263 -255
  82. package/src/directive/repeat/repeat.md +0 -22
  83. package/src/directive/repeat/repeat.spec.js +2 -115
  84. package/src/directive/script/script.spec.js +1 -1
  85. package/src/directive/select/select.js +2 -2
  86. package/src/directive/select/select.spec.js +2 -2
  87. package/src/directive/show-hide/show-hide.js +1 -3
  88. package/src/directive/show-hide/show-hide.md +0 -2
  89. package/src/directive/show-hide/show-hide.spec.js +1 -1
  90. package/src/directive/style/style.spec.js +1 -1
  91. package/src/directive/switch/switch.js +2 -4
  92. package/src/directive/switch/switch.spec.js +1 -51
  93. package/src/directive/transclude/transclude.js +2 -2
  94. package/src/directive/validators/validators.js +2 -2
  95. package/src/directive/validators/validators.spec.js +1 -1
  96. package/src/filters/filter.js +1 -1
  97. package/src/filters/filter.spec.js +2 -2
  98. package/src/filters/filters.js +1 -1
  99. package/src/filters/filters.spec.js +1 -1
  100. package/src/filters/limit-to.js +1 -1
  101. package/src/filters/limit-to.spec.js +1 -1
  102. package/src/filters/order-by.js +1 -1
  103. package/src/index.js +3 -9
  104. package/src/loader.js +10 -5
  105. package/src/router/common/trace.js +1 -1
  106. package/src/router/directives/state-directives.js +1 -1
  107. package/src/router/directives/state-directives.spec.js +1 -1
  108. package/src/router/directives/view-directive.js +2 -2
  109. package/src/router/directives/view-directive.spec.js +1 -1
  110. package/src/router/hooks/redirect-to.js +1 -1
  111. package/src/router/params/param-type.js +1 -1
  112. package/src/router/params/param-types.js +1 -1
  113. package/src/router/params/param.js +1 -1
  114. package/src/router/resolve/resolvable.js +1 -1
  115. package/src/router/resolve/resolve-context.js +1 -1
  116. package/src/router/state/state-builder.js +1 -1
  117. package/src/router/state/state-matcher.js +1 -1
  118. package/src/router/state/state-object.js +1 -1
  119. package/src/router/state/state-queue-manager.js +1 -1
  120. package/src/router/state/state-registry.js +1 -1
  121. package/src/router/state/state-service.js +1 -1
  122. package/src/router/state/state.spec.js +2 -2
  123. package/src/router/state/target-state.js +1 -1
  124. package/src/router/state/views.js +1 -1
  125. package/src/router/state-provider.js +1 -1
  126. package/src/router/template-factory.js +1 -1
  127. package/src/router/template-factory.spec.js +1 -1
  128. package/src/router/transition/hook-registry.js +1 -1
  129. package/src/router/transition/transition-service.js +1 -1
  130. package/src/router/transition/transition.js +1 -1
  131. package/src/router/url/url-config.js +1 -1
  132. package/src/router/url/url-matcher.js +1 -1
  133. package/src/router/url/url-rule.js +1 -1
  134. package/src/router/url/url-rules.js +1 -1
  135. package/src/router/url/url-service.js +6 -1
  136. package/src/router/url/url-service.spec.js +1 -1
  137. package/src/router/view/view.spec.js +1 -1
  138. package/src/router/view-hook.spec.js +1 -1
  139. package/src/router/view-scroll.spec.js +1 -1
  140. package/src/services/anchor-scroll.js +1 -1
  141. package/src/services/browser.js +2 -2
  142. package/src/services/cookie-reader.js +1 -1
  143. package/src/services/http/http.js +2 -2
  144. package/src/services/http/http.spec.js +1 -1
  145. package/src/services/http-backend/http-backend.js +1 -1
  146. package/src/services/log.js +1 -1
  147. package/src/services/template-request.js +1 -1
  148. package/src/shared/common.js +1 -1
  149. package/src/shared/jqlite/jqlite.js +9 -9
  150. package/src/shared/jqlite/jqlite.spec.js +11 -11
  151. package/src/shared/min-err.spec.js +6 -1
  152. package/src/shared/predicates.js +1 -1
  153. package/src/shared/strings.js +1 -1
  154. package/src/shared/test-utils.js +1 -1
  155. package/src/shared/utils.js +1 -1
  156. package/src/shared/utils.spec.js +1 -1
  157. package/src/types.js +0 -2
  158. package/types/animations/animate-css-driver.d.ts +1 -1
  159. package/types/animations/animate.d.ts +1 -1
  160. package/types/core/cache/cache.d.ts +1 -1
  161. package/types/core/compile/attributes.d.ts +2 -2
  162. package/types/core/compile/compile.d.ts +1 -1
  163. package/types/core/location/location.d.ts +1 -1
  164. package/types/directive/model/model.d.ts +1 -1
  165. package/types/directive/repeat/repeat.d.ts +0 -1
  166. package/types/loader.d.ts +2 -0
  167. package/types/services/browser.d.ts +1 -1
  168. package/types/shared/jqlite/jqlite.d.ts +1 -1
  169. package/types/shared/test-utils.d.ts +1 -1
  170. package/types/types.d.ts +1 -5
@@ -1,15 +1,19 @@
1
1
  import { Angular } from "../../loader";
2
2
  import { createInjector } from "../di/injector";
3
- import { dealoc, JQLite, getOrSetCacheData } from "../../shared/jqlite/jqlite";
3
+ import {
4
+ dealoc,
5
+ JQLite,
6
+ getOrSetCacheData,
7
+ } from "../../shared/jqlite/jqlite.js";
4
8
  import {
5
9
  isFunction,
6
10
  valueFn,
7
11
  isElement,
8
12
  getNodeName,
9
13
  extend,
10
- } from "../../shared/utils";
11
- import { countChildScopes, countWatchers } from "../scope/scope";
12
- import { CACHE, EXPANDO } from "../cache/cache";
14
+ } from "../../shared/utils.js";
15
+ import { countChildScopes, countWatchers } from "../scope/scope.js";
16
+ import { Cache, EXPANDO } from "../cache/cache.js";
13
17
  import { wait } from "../../shared/test-utils";
14
18
 
15
19
  function isUnknownElement(el) {
@@ -689,21 +693,6 @@ describe("$compile", () => {
689
693
  dealoc(element);
690
694
  });
691
695
 
692
- it("allows applying a directive to multiple elements", () => {
693
- var compileEl = false;
694
- registerDirectives("myDir", () => {
695
- return {
696
- multiElement: true,
697
- compile: function (element) {
698
- compileEl = element;
699
- },
700
- };
701
- });
702
- reloadModules();
703
- $compile("<div my-dir-start></div><span></span><div my-dir-end></div>");
704
- expect(compileEl.length).toBe(3);
705
- });
706
-
707
696
  it("should allow multiple directives per element", () => {
708
697
  reloadModules();
709
698
  var el = $(
@@ -1273,26 +1262,6 @@ describe("$compile", () => {
1273
1262
  expect(givenElements[1]).toBe(el2);
1274
1263
  });
1275
1264
 
1276
- it("invokes multi-element directive link functions with whole group", () => {
1277
- var givenElements;
1278
- registerDirectives("myDirective", () => {
1279
- return {
1280
- multiElement: true,
1281
- link: function (scope, element, attrs) {
1282
- givenElements = element;
1283
- },
1284
- };
1285
- });
1286
- reloadModules();
1287
- var el = $(
1288
- "<div my-directive-start></div>" +
1289
- "<p></p>" +
1290
- "<div my-directive-end></div>",
1291
- );
1292
- $compile(el)($rootScope);
1293
- expect(givenElements.length).toBe(3);
1294
- });
1295
-
1296
1265
  it("makes new scope for element when directive asks for it", () => {
1297
1266
  var givenScope;
1298
1267
  registerDirectives("myDirective", () => {
@@ -2255,26 +2224,6 @@ describe("$compile", () => {
2255
2224
  expect(gotMyController instanceof MyController).toBe(true);
2256
2225
  });
2257
2226
 
2258
- it("is passed through grouped link wrapper", () => {
2259
- function MyController() {}
2260
- var gotMyController;
2261
- myModule.directive("myDirective", () => {
2262
- return {
2263
- multiElement: true,
2264
- scope: {},
2265
- controller: MyController,
2266
- link: function (scope, element, attrs, myController) {
2267
- gotMyController = myController;
2268
- },
2269
- };
2270
- });
2271
- reloadModules();
2272
- var el = $("<div my-directive-start></div><div my-directive-end></div>");
2273
- $compile(el)($rootScope);
2274
- expect(gotMyController).toBeDefined();
2275
- expect(gotMyController instanceof MyController).toBe(true);
2276
- });
2277
-
2278
2227
  it("can be required from a parent directive", () => {
2279
2228
  function MyController() {}
2280
2229
  var gotMyController;
@@ -3386,27 +3335,6 @@ describe("$compile", () => {
3386
3335
 
3387
3336
  expect(transclude()[0].outerHTML.match(/in-transclude/)).toBeTruthy();
3388
3337
  });
3389
-
3390
- it("can be used with multi-element directives", () => {
3391
- registerDirectives({
3392
- myTranscluder: function ($compile) {
3393
- return {
3394
- transclude: true,
3395
- multiElement: true,
3396
- template: "<div in-template></div>",
3397
- link: function (scope, element, attrs, ctrl, transclude) {
3398
- element[0].append(transclude()[0]);
3399
- },
3400
- };
3401
- },
3402
- });
3403
- reloadModules();
3404
- var el = $(
3405
- "<div><div my-transcluder-start><div in-transclude></div></div><div my-transcluder-end></div></div>",
3406
- );
3407
- $compile(el)($rootScope);
3408
- expect(el[0].outerHTML.match(/in-transclude/)).toBeTruthy();
3409
- });
3410
3338
  });
3411
3339
 
3412
3340
  describe("clone attach function", () => {
@@ -4975,36 +4903,36 @@ describe("$compile", () => {
4975
4903
  // We compile the contents of element (i.e. not element itself)
4976
4904
  // Then delete these contents and check the cache has been reset to zero
4977
4905
  // Clear cache
4978
- CACHE.clear();
4906
+ Cache.clear();
4979
4907
  window.angular.module("test1", ["ng"]);
4980
4908
  createInjector(["test1"]).invoke(($compile) => {
4981
- expect(CACHE.size).toEqual(0);
4909
+ expect(Cache.size).toEqual(0);
4982
4910
  // First with only elements at the top level
4983
4911
  element = JQLite("<div><div></div></div>");
4984
4912
  $compile(element[0].childNodes)($rootScope);
4985
- // expect(CACHE.size).toEqual(2);
4913
+ // expect(Cache.size).toEqual(2);
4986
4914
  element.empty();
4987
- expect(CACHE.size).toEqual(0);
4915
+ expect(Cache.size).toEqual(0);
4988
4916
 
4989
4917
  // Next with non-empty text nodes at the top level
4990
4918
  // (in this case the compiler will wrap them in a <span>)
4991
4919
  element = JQLite("<div>xxx</div>");
4992
4920
  $compile(element[0].childNodes)($rootScope);
4993
4921
  element.empty();
4994
- expect(CACHE.size).toEqual(0);
4922
+ expect(Cache.size).toEqual(0);
4995
4923
 
4996
4924
  // Next with comment nodes at the top level
4997
4925
  element = JQLite("<div><!-- comment --></div>");
4998
4926
  $compile(element[0].childNodes)($rootScope);
4999
4927
  element.empty();
5000
- expect(CACHE.size).toEqual(0);
4928
+ expect(Cache.size).toEqual(0);
5001
4929
 
5002
4930
  // Finally with empty text nodes at the top level
5003
4931
  element = JQLite("<div> \n<div></div> </div>");
5004
4932
  $compile(element[0].childNodes)($rootScope);
5005
- //expect(CACHE.size).toEqual(2);
4933
+ //expect(Cache.size).toEqual(2);
5006
4934
  element.empty();
5007
- expect(CACHE.size).toEqual(0);
4935
+ expect(Cache.size).toEqual(0);
5008
4936
  });
5009
4937
  });
5010
4938
 
@@ -13287,52 +13215,6 @@ describe("$compile", () => {
13287
13215
  }).toThrowError(/multidir/);
13288
13216
  });
13289
13217
 
13290
- it("should correctly handle multi-element directives", () => {
13291
- module
13292
- .directive(
13293
- "foo",
13294
- valueFn({
13295
- template: "[<div ng-transclude></div>]",
13296
- transclude: true,
13297
- }),
13298
- )
13299
- .directive(
13300
- "bar",
13301
- valueFn({
13302
- template:
13303
- '[<div ng-transclude="header"></div>|<div ng-transclude="footer"></div>]',
13304
- transclude: {
13305
- header: "header",
13306
- footer: "footer",
13307
- },
13308
- }),
13309
- );
13310
- initInjector("test1");
13311
- const tmplWithFoo =
13312
- "<foo>" +
13313
- '<div ng-if-start="true">Hello, </div>' +
13314
- "<div ng-if-end>world!</div>" +
13315
- "</foo>";
13316
- const tmplWithBar =
13317
- "<bar>" +
13318
- '<header ng-if-start="true">This is a </header>' +
13319
- "<header ng-if-end>header!</header>" +
13320
- '<footer ng-if-start="true">This is a </footer>' +
13321
- "<footer ng-if-end>footer!</footer>" +
13322
- "</bar>";
13323
-
13324
- const elem1 = $compile(tmplWithFoo)($rootScope);
13325
- const elem2 = $compile(tmplWithBar)($rootScope);
13326
-
13327
- $rootScope.$digest();
13328
-
13329
- expect(elem1.text()).toBe("[Hello, world!]");
13330
- expect(elem2.text()).toBe("[This is a header!|This is a footer!]");
13331
-
13332
- dealoc(elem1);
13333
- dealoc(elem2);
13334
- });
13335
-
13336
13218
  // see issue https://github.com/angular/angular.js/issues/12936
13337
13219
  it("should use the proper scope when it is on the root element of a replaced directive template", () => {
13338
13220
  module
@@ -13421,28 +13303,28 @@ describe("$compile", () => {
13421
13303
  });
13422
13304
 
13423
13305
  it('should not leak if two "element" transclusions are on the same element', () => {
13424
- const cacheSize = CACHE.size;
13306
+ const cacheSize = Cache.size;
13425
13307
 
13426
13308
  element = $compile(
13427
13309
  '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>',
13428
13310
  )($rootScope);
13429
- expect(CACHE.size).toEqual(cacheSize);
13311
+ expect(Cache.size).toEqual(cacheSize);
13430
13312
 
13431
13313
  $rootScope.$apply("xs = [0,1]");
13432
- expect(CACHE.size).toEqual(cacheSize);
13314
+ expect(Cache.size).toEqual(cacheSize);
13433
13315
 
13434
13316
  $rootScope.$apply("xs = [0]");
13435
- expect(CACHE.size).toEqual(cacheSize);
13317
+ expect(Cache.size).toEqual(cacheSize);
13436
13318
 
13437
13319
  $rootScope.$apply("xs = []");
13438
- expect(CACHE.size).toEqual(cacheSize);
13320
+ expect(Cache.size).toEqual(cacheSize);
13439
13321
 
13440
13322
  element.remove();
13441
- expect(CACHE.size).toEqual(cacheSize);
13323
+ expect(Cache.size).toEqual(cacheSize);
13442
13324
  });
13443
13325
 
13444
13326
  it('should not leak if two "element" transclusions are on the same element', () => {
13445
- const cacheSize = CACHE.size;
13327
+ const cacheSize = Cache.size;
13446
13328
  element = $compile(
13447
13329
  '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>',
13448
13330
  )($rootScope);
@@ -13450,20 +13332,20 @@ describe("$compile", () => {
13450
13332
  $rootScope.$apply("xs = [0,1]");
13451
13333
  // At this point we have a bunch of comment placeholders but no real transcluded elements
13452
13334
  // So the cache only contains the root element's data
13453
- expect(CACHE.size).toEqual(cacheSize);
13335
+ expect(Cache.size).toEqual(cacheSize);
13454
13336
 
13455
13337
  $rootScope.$apply("val = true");
13456
13338
  // Now we have two concrete transcluded elements plus some comments so two more cache items
13457
- expect(CACHE.size).toEqual(cacheSize);
13339
+ expect(Cache.size).toEqual(cacheSize);
13458
13340
 
13459
13341
  $rootScope.$apply("val = false");
13460
13342
  // Once again we only have comments so no transcluded elements and the cache is back to just
13461
13343
  // the root element
13462
- expect(CACHE.size).toEqual(cacheSize);
13344
+ expect(Cache.size).toEqual(cacheSize);
13463
13345
 
13464
13346
  element.remove();
13465
13347
  // Now we've even removed the root element along with its cache
13466
- expect(CACHE.size).toEqual(cacheSize);
13348
+ expect(Cache.size).toEqual(cacheSize);
13467
13349
  });
13468
13350
 
13469
13351
  // it("should not leak when continuing the compilation of elements on a scope that was destroyed", () => {
@@ -13488,7 +13370,7 @@ describe("$compile", () => {
13488
13370
  // link: linkFn,
13489
13371
  // }));
13490
13372
  // initInjector("test1");
13491
- // const cacheSize = CACHE.size;
13373
+ // const cacheSize = Cache.size;
13492
13374
  // $templateCache.set("red.html", "<p>red</p>");
13493
13375
  // const template = $compile(
13494
13376
  // '<div ng-controller="Leak">' +
@@ -13503,7 +13385,7 @@ describe("$compile", () => {
13503
13385
  // $rootScope.$digest();
13504
13386
 
13505
13387
  // expect(linkFn).toHaveBeenCalled();
13506
- // expect(CACHE.size).toEqual(cacheSize + 2);
13388
+ // expect(Cache.size).toEqual(cacheSize + 2);
13507
13389
 
13508
13390
  // $templateCache = new Map();
13509
13391
  // const destroyedScope = $rootScope.$new();
@@ -13532,7 +13414,7 @@ describe("$compile", () => {
13532
13414
  $rootScope.$apply(`xs = [${xs}]`);
13533
13415
  firstRepeatedElem = element.children(".ng-scope").eq(0);
13534
13416
 
13535
- privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
13417
+ privateData = Cache.get(firstRepeatedElem[0][EXPANDO]);
13536
13418
  expect(privateData.events).toBeDefined();
13537
13419
 
13538
13420
  expect(privateData.events.click).toBeDefined();
@@ -13548,7 +13430,7 @@ describe("$compile", () => {
13548
13430
 
13549
13431
  expect(destroyCount).toBe(2);
13550
13432
  expect(firstRepeatedElem.data("$scope")).not.toBeDefined();
13551
- privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
13433
+ privateData = Cache.get(firstRepeatedElem[0][EXPANDO]);
13552
13434
  expect(privateData && privateData.events).not.toBeDefined();
13553
13435
  }
13554
13436
 
@@ -14246,35 +14128,6 @@ describe("$compile", () => {
14246
14128
  expect(countChildScopes($rootScope)).toBe(0);
14247
14129
  });
14248
14130
 
14249
- it("should not leak the transclude scope when the transcluded content is an multi-element transclusion directive", () => {
14250
- element = $compile(
14251
- "<div toggle>" +
14252
- "<div ng-repeat-start=\"msg in ['msg-1']\">{{ msg }}</div>" +
14253
- "<div ng-repeat-end>{{ msg }}</div>" +
14254
- "</div>",
14255
- )($rootScope);
14256
-
14257
- $rootScope.$apply("t = true");
14258
- expect(element.text()).toContain("msg-1msg-1");
14259
- // Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
14260
- expect(countChildScopes($rootScope)).toBe(3);
14261
-
14262
- $rootScope.$apply("t = false");
14263
- expect(element.text()).not.toContain("msg-1msg-1");
14264
- // Expected scopes: $rootScope
14265
- expect(countChildScopes($rootScope)).toBe(0);
14266
-
14267
- $rootScope.$apply("t = true");
14268
- expect(element.text()).toContain("msg-1msg-1");
14269
- // Expected scopes: $rootScope, ngIf, transclusion, ngRepeat
14270
- expect(countChildScopes($rootScope)).toBe(3);
14271
-
14272
- $rootScope.$apply("t = false");
14273
- expect(element.text()).not.toContain("msg-1msg-1");
14274
- // Expected scopes: $rootScope
14275
- expect(countChildScopes($rootScope)).toBe(0);
14276
- });
14277
-
14278
14131
  it("should not leak the transclude scope if the transcluded contains only comments", () => {
14279
14132
  element = $compile("<div toggle><!-- some comment --></div>")(
14280
14133
  $rootScope,
@@ -14437,7 +14290,7 @@ describe("$compile", () => {
14437
14290
 
14438
14291
  it("should not leak memory with nested transclusion", () => {
14439
14292
  let size;
14440
- const initialSize = CACHE.size;
14293
+ const initialSize = Cache.size;
14441
14294
 
14442
14295
  element = JQLite(
14443
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>',
@@ -14446,14 +14299,14 @@ describe("$compile", () => {
14446
14299
 
14447
14300
  $rootScope.nums = [0, 1, 2];
14448
14301
  $rootScope.$apply();
14449
- size = CACHE.size;
14302
+ size = Cache.size;
14450
14303
 
14451
14304
  $rootScope.nums = [3, 4, 5];
14452
14305
  $rootScope.$apply();
14453
- expect(CACHE.size).toEqual(size);
14306
+ expect(Cache.size).toEqual(size);
14454
14307
 
14455
14308
  element.remove();
14456
- expect(CACHE.size).toEqual(initialSize);
14309
+ expect(Cache.size).toEqual(initialSize);
14457
14310
  });
14458
14311
  });
14459
14312
 
@@ -16811,339 +16664,6 @@ describe("$compile", () => {
16811
16664
  });
16812
16665
  });
16813
16666
 
16814
- describe("multi-element directive", () => {
16815
- it("should group on link function", async () => {
16816
- $rootScope.show = false;
16817
- element = $compile(
16818
- "<div>" +
16819
- '<span ng-show-start="show"></span>' +
16820
- "<span ng-show-end='show'></span>" +
16821
- "</div>",
16822
- )($rootScope);
16823
- $rootScope.$digest();
16824
- await wait(100);
16825
- const spans = element.find("span");
16826
- expect(spans.eq(0)[0].classList.contains("ng-hide")).toBeTrue();
16827
- expect(spans.eq(1)[0].classList.contains("ng-hide")).toBeTrue();
16828
- });
16829
-
16830
- it("should group on compile function", () => {
16831
- $rootScope.show = false;
16832
- element = $compile(
16833
- "<div>" +
16834
- '<span ng-repeat-start="i in [1,2]">{{i}}A</span>' +
16835
- "<span ng-repeat-end>{{i}}B;</span>" +
16836
- "</div>",
16837
- )($rootScope);
16838
- $rootScope.$digest();
16839
- expect(element.text()).toEqual("1A1B;2A2B;");
16840
- });
16841
-
16842
- it("should support grouping over text nodes", () => {
16843
- $rootScope.show = false;
16844
- element = $compile(
16845
- "<div>" +
16846
- '<span ng-repeat-start="i in [1,2]">{{i}}A</span>' +
16847
- ":" + // Important: proves that we can iterate over non-elements
16848
- "<span ng-repeat-end>{{i}}B;</span>" +
16849
- "</div>",
16850
- )($rootScope);
16851
- $rootScope.$digest();
16852
- expect(element.text()).toEqual("1A:1B;2A:2B;");
16853
- });
16854
-
16855
- it("should group on $root compile function", () => {
16856
- $rootScope.show = false;
16857
- element = $compile(
16858
- "<div></div>" +
16859
- '<span ng-repeat-start="i in [1,2]">{{i}}A</span>' +
16860
- "<span ng-repeat-end>{{i}}B;</span>" +
16861
- "<div></div>",
16862
- )($rootScope);
16863
- $rootScope.$digest();
16864
- element = JQLite(element[0].parentNode.childNodes); // reset because repeater is top level.
16865
- expect(element.text()).toEqual("1A1B;2A2B;");
16866
- });
16867
-
16868
- it("should group on nested groups", () => {
16869
- module.directive(
16870
- "ngMultiBind",
16871
- valueFn({
16872
- multiElement: true,
16873
- link(scope, element, attr) {
16874
- element.text(scope.$eval(attr.ngMultiBind));
16875
- },
16876
- }),
16877
- );
16878
- initInjector("test1");
16879
-
16880
- $rootScope.show = false;
16881
- element = $compile(
16882
- "<div></div>" +
16883
- '<div ng-repeat-start="i in [1,2]">{{i}}A</div>' +
16884
- "<span ng-multi-bind-start=\"'.'\"></span>" +
16885
- "<span ng-multi-bind-end></span>" +
16886
- "<div ng-repeat-end>{{i}}B;</div>" +
16887
- "<div></div>",
16888
- )($rootScope);
16889
- $rootScope.$digest();
16890
- element = JQLite(element[0].parentNode.childNodes); // reset because repeater is top level.
16891
- expect(element.text()).toEqual("1A..1B;2A..2B;");
16892
- });
16893
-
16894
- it("should group on nested groups of same directive", () => {
16895
- $rootScope.show = false;
16896
- element = $compile(
16897
- "<div></div>" +
16898
- '<div ng-repeat-start="i in [1,2]">{{i}}(</div>' +
16899
- '<span ng-repeat-start="j in [2,3]">{{j}}-</span>' +
16900
- "<span ng-repeat-end>{{j}}</span>" +
16901
- "<div ng-repeat-end>){{i}};</div>" +
16902
- "<div></div>",
16903
- )($rootScope);
16904
- $rootScope.$digest();
16905
- element = JQLite(element[0].parentNode.childNodes); // reset because repeater is top level.
16906
- expect(element.text()).toEqual("1(2-23-3)1;2(2-23-3)2;");
16907
- });
16908
-
16909
- it("should set up and destroy the transclusion scopes correctly", () => {
16910
- element = $compile(
16911
- "<div>" +
16912
- '<div ng-if-start="val0"><span ng-if="val1"></span></div>' +
16913
- '<div ng-if-end><span ng-if="val2"></span></div>' +
16914
- "</div>",
16915
- )($rootScope);
16916
- $rootScope.$apply("val0 = true; val1 = true; val2 = true");
16917
- expect($rootScope.$$childHead).toBeTruthy();
16918
- expect($rootScope.$$childHead.$$childHead).toBeTruthy();
16919
- // At this point we should have something like:
16920
- //
16921
- // <div>
16922
- //
16923
- // <!---->
16924
- // <div ng-if-start="val0">
16925
- // <!---->
16926
- // <span ng-if="val1"></span>
16927
- // <!---->
16928
- // </div>
16929
- //
16930
- // <div ng-if-end="">
16931
- // <!---->
16932
- // <span ng-if="val2"></span>
16933
- // <!---->
16934
- // </div>
16935
- //
16936
- // <!---->
16937
- // </div>
16938
- // const ngIfStartScope = element.find("div").eq(0).scope();
16939
- // const ngIfEndScope = element.find("div").eq(1).scope();
16940
-
16941
- // expect(ngIfStartScope.$id).toEqual(ngIfEndScope.$id);
16942
-
16943
- // const ngIf1Scope = element.find("span").eq(0).scope();
16944
- // const ngIf2Scope = element.find("span").eq(1).scope();
16945
-
16946
- // expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
16947
- // expect(ngIf1Scope.$parent.$id).toEqual(ngIf2Scope.$parent.$id);
16948
-
16949
- $rootScope.$apply("val1 = false");
16950
- // Now we should have something like:
16951
- //
16952
- // <div>
16953
- // <!-- ngIf: val0 -->
16954
- // <div ng-if-start="val0">
16955
- // <!-- ngIf: val1 -->
16956
- // </div>
16957
- // <div ng-if-end="">
16958
- // <!-- ngIf: val2 -->
16959
- // <span ng-if="val2"></span>
16960
- // <!-- end ngIf: val2 -->
16961
- // </div>
16962
- // <!-- end ngIf: val0 -->
16963
- // </div>
16964
-
16965
- // expect(ngIfStartScope.$$destroyed).not.toEqual(true);
16966
- // expect(ngIf1Scope.$$destroyed).toEqual(true);
16967
- // expect(ngIf2Scope.$$destroyed).not.toEqual(true);
16968
-
16969
- $rootScope.$apply("val0 = false");
16970
-
16971
- // Now we should have something like:
16972
- //
16973
- // <div>
16974
- // <!-- ngIf: val0 -->
16975
- // </div>
16976
- // TODO: Until we figure out a better way of testing this
16977
- expect($rootScope.$$childHead).toBeNull();
16978
- // expect(ngIfStartScope.$$destroyed).toEqual(true);
16979
- // expect(ngIf1Scope.$$destroyed).toEqual(true);
16980
- // expect(ngIf2Scope.$$destroyed).toEqual(true);
16981
- });
16982
-
16983
- it("should set up and destroy the transclusion scopes correctly", () => {
16984
- element = $compile(
16985
- "<div>" +
16986
- '<div ng-repeat-start="val in val0" ng-if="val1"></div>' +
16987
- '<div ng-repeat-end ng-if="val2"></div>' +
16988
- "</div>",
16989
- )($rootScope);
16990
-
16991
- // To begin with there is (almost) nothing:
16992
- // <div>
16993
- // <!-- ngRepeat: val in val0 -->
16994
- // </div>
16995
-
16996
- //expect(element.scope().$id).toEqual($rootScope.$id);
16997
-
16998
- // Now we create all the elements
16999
- $rootScope.$apply("val0 = [1]; val1 = true; val2 = true");
17000
-
17001
- // At this point we have:
17002
- //
17003
- // <div>
17004
- //
17005
- // <!-- ngRepeat: val in val0 -->
17006
- // <!-- ngIf: val1 -->
17007
- // <div ng-repeat-start="val in val0">
17008
- // </div>
17009
- // <!-- end ngIf: val1 -->
17010
- //
17011
- // <!-- ngIf: val2 -->
17012
- // <div ng-repeat-end="">
17013
- // </div>
17014
- // <!-- end ngIf: val2 -->
17015
- // <!-- end ngRepeat: val in val0 -->
17016
- // </div>
17017
- // const ngIf1Scope = element.find("div").eq(0).scope();
17018
- // const ngIf2Scope = element.find("div").eq(1).scope();
17019
- // const ngRepeatScope = ngIf1Scope.$parent;
17020
-
17021
- // expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
17022
- // expect(ngIf1Scope.$parent.$id).toEqual(ngRepeatScope.$id);
17023
- // expect(ngIf2Scope.$parent.$id).toEqual(ngRepeatScope.$id);
17024
-
17025
- // // What is happening here??
17026
- // // We seem to have a repeater scope which doesn't actually match to any element
17027
- // expect(ngRepeatScope.$parent.$id).toEqual($rootScope.$id);
17028
-
17029
- // Now remove the first ngIf element from the first item in the repeater
17030
- $rootScope.$apply("val1 = false");
17031
-
17032
- // At this point we should have:
17033
- //
17034
- // <div>
17035
- // <!-- ngRepeat: val in val0 -->
17036
- //
17037
- // <!-- ngIf: val1 -->
17038
- //
17039
- // <!-- ngIf: val2 -->
17040
- // <div ng-repeat-end="" ng-if="val2"></div>
17041
- // <!-- end ngIf: val2 -->
17042
- //
17043
- // <!-- end ngRepeat: val in val0 -->
17044
- // </div>
17045
- //
17046
- // expect(ngRepeatScope.$$destroyed).toEqual(false);
17047
- // expect(ngIf1Scope.$$destroyed).toEqual(true);
17048
- // expect(ngIf2Scope.$$destroyed).toEqual(false);
17049
-
17050
- // Now remove the second ngIf element from the first item in the repeater
17051
- $rootScope.$apply("val2 = false");
17052
-
17053
- // We are mostly back to where we started
17054
- //
17055
- // <div>
17056
- // <!-- ngRepeat: val in val0 -->
17057
- // <!-- ngIf: val1 -->
17058
- // <!-- ngIf: val2 -->
17059
- // <!-- end ngRepeat: val in val0 -->
17060
- // </div>
17061
-
17062
- // expect(ngRepeatScope.$$destroyed).toEqual(false);
17063
- // expect(ngIf1Scope.$$destroyed).toEqual(true);
17064
- // expect(ngIf2Scope.$$destroyed).toEqual(true);
17065
-
17066
- // Finally remove the repeat items
17067
- $rootScope.$apply("val0 = []");
17068
-
17069
- // Somehow this ngRepeat scope knows how to destroy itself...
17070
- expect($rootScope.$$childHead).toBeNull();
17071
- // expect(ngRepeatScope.$$destroyed).toEqual(true);
17072
- // expect(ngIf1Scope.$$destroyed).toEqual(true);
17073
- // expect(ngIf2Scope.$$destroyed).toEqual(true);
17074
- });
17075
-
17076
- it("should throw error if unterminated", () => {
17077
- module.directive("foo", () => ({
17078
- multiElement: true,
17079
- }));
17080
- initInjector("test1");
17081
- expect(() => {
17082
- element = $compile("<div><span foo-start></span></div>");
17083
- }).toThrowError(/uterdir/);
17084
- });
17085
-
17086
- it("should correctly collect ranges on multiple directives on a single element", () => {
17087
- module
17088
- .directive("emptyDirective", () => ({
17089
- multiElement: true,
17090
- link(scope, element) {
17091
- element.data("x", "abc");
17092
- },
17093
- }))
17094
- .directive("rangeDirective", () => ({
17095
- multiElement: true,
17096
- link(scope) {
17097
- scope.x = "X";
17098
- scope.y = "Y";
17099
- },
17100
- }));
17101
- initInjector("test1");
17102
- element = $compile(
17103
- "<div>" +
17104
- "<div range-directive-start empty-directive>{{x}}</div>" +
17105
- "<div range-directive-end>{{y}}</div>" +
17106
- "</div>",
17107
- )($rootScope);
17108
-
17109
- $rootScope.$digest();
17110
-
17111
- expect(element.text()).toBe("XY");
17112
- ///expect(angular.element(element[0].firstChild).data("x")).toBe("abc");
17113
- });
17114
-
17115
- it("should throw error if unterminated (containing termination as a child)", () => {
17116
- module.directive("foo", () => ({
17117
- multiElement: true,
17118
- }));
17119
- initInjector("test1");
17120
- expect(() => {
17121
- element = $compile(
17122
- "<div><span foo-start><span foo-end></span></span></div>",
17123
- );
17124
- }).toThrowError(/uterdir/);
17125
- });
17126
-
17127
- it("should support data- prefix", async () => {
17128
- $rootScope.show = false;
17129
- element = $compile(
17130
- "<div>" +
17131
- '<span data-ng-show-start="show"></span>' +
17132
- "<span data-ng-show-end></span>" +
17133
- '<span ng-show-start="show"></span>' +
17134
- "<span ng-show-end></span>" +
17135
- "</div>",
17136
- )($rootScope);
17137
- $rootScope.$digest();
17138
- await wait(100);
17139
- const spans = element.find("span");
17140
- expect(spans.eq(0)[0].classList.contains("ng-hide")).toBeTrue();
17141
- //expect(spans.eq(1)[0].classList.contains("ng-hide")).toBeTrue();
17142
- expect(spans.eq(2)[0].classList.contains("ng-hide")).toBeTrue();
17143
- // expect(spans.eq(3)[0].classList.contains("ng-hide")).toBeTrue();
17144
- });
17145
- });
17146
-
17147
16667
  // TODO ANIMATIONS
17148
16668
  // describe("$animate animation hooks", () => {
17149
16669
  // beforeEach(module("ngAnimateMock"));
@@ -17198,130 +16718,6 @@ describe("$compile", () => {
17198
16718
  // });
17199
16719
  // });
17200
16720
 
17201
- describe("element replacement", () => {
17202
- it("should broadcast $destroy only on removed elements, not replaced", () => {
17203
- const linkCalls = [];
17204
- const destroyCalls = [];
17205
-
17206
- module
17207
- .directive("replace", () => ({
17208
- multiElement: true,
17209
- replace: true,
17210
- templateUrl: "template123",
17211
- }))
17212
- .directive("foo", () => ({
17213
- priority: 1, // before the replace directive
17214
- link($scope, $element, $attrs) {
17215
- linkCalls.push($attrs.foo);
17216
- $element.on("$destroy", () => {
17217
- destroyCalls.push($attrs.foo);
17218
- });
17219
- },
17220
- }));
17221
- initInjector("test1");
17222
- $templateCache.set("template123", "<p></p>");
17223
-
17224
- $compile(
17225
- '<div replace-start foo="1"><span foo="1.1"></span></div>' +
17226
- '<div foo="2"><span foo="2.1"></span></div>' +
17227
- '<div replace-end foo="3"><span foo="3.1"></span></div>',
17228
- )($rootScope);
17229
-
17230
- expect(linkCalls).toEqual(["2", "3"]);
17231
- expect(destroyCalls).toEqual([]);
17232
- $rootScope.$apply();
17233
- expect(linkCalls).toEqual(["2", "3", "1"]);
17234
- expect(destroyCalls).toEqual(["2", "3"]);
17235
- });
17236
-
17237
- function sliceArgs(args, startIndex) {
17238
- return [].slice.call(args, startIndex || 0);
17239
- }
17240
-
17241
- function getAll($root) {
17242
- // check for .querySelectorAll to support comment nodes
17243
- return [$root[0]].concat(
17244
- $root[0].querySelectorAll
17245
- ? sliceArgs($root[0].querySelectorAll("*"))
17246
- : [],
17247
- );
17248
- }
17249
-
17250
- function testCompileLinkDataCleanup(template) {
17251
- const toCompile = JQLite(template);
17252
-
17253
- const preCompiledChildren = getAll(toCompile);
17254
- Object.entries(preCompiledChildren).forEach(([i, element]) => {
17255
- getOrSetCacheData(element, "foo", `template#${i}`);
17256
- });
17257
-
17258
- const linkedElements = $compile(toCompile)($rootScope);
17259
- $rootScope.$apply();
17260
- linkedElements.remove();
17261
-
17262
- Object.entries(preCompiledChildren).forEach(([i, element]) => {
17263
- expect(CACHE.has(element[EXPANDO])).toBe(false, `template#${i}`);
17264
- });
17265
-
17266
- Object.entries(linkedElements).forEach(([i, element]) => {
17267
- expect(CACHE.has(element[EXPANDO])).toBe(false, `linked#${i}`);
17268
- });
17269
- }
17270
-
17271
- it("should clean data of element-transcluded link-cloned elements", () => {
17272
- testCompileLinkDataCleanup(
17273
- '<div><div ng-repeat-start="i in [1,2]"><span></span></div><div ng-repeat-end></div></div>',
17274
- );
17275
- });
17276
-
17277
- it("should clean data of element-transcluded elements", () => {
17278
- testCompileLinkDataCleanup(
17279
- '<div ng-if-start="false"><span><span/></div><span></span><div ng-if-end><span></span></div>',
17280
- );
17281
- });
17282
-
17283
- function testReplaceElementCleanup(dirOptions) {
17284
- const template = "<div></div>";
17285
- module.directive("theDir", () => ({
17286
- multiElement: true,
17287
- replace: dirOptions.replace,
17288
- transclude: dirOptions.transclude,
17289
- template: dirOptions.asyncTemplate ? undefined : template,
17290
- templateUrl: dirOptions.asyncTemplate
17291
- ? "the-dir-template-url"
17292
- : undefined,
17293
- }));
17294
- initInjector("test1");
17295
- $templateCache.set("the-dir-template-url", template);
17296
-
17297
- testCompileLinkDataCleanup(
17298
- "<div>" +
17299
- "<div the-dir-start><span></span></div>" +
17300
- "<div><span></span><span></span></div>" +
17301
- "<div the-dir-end><span></span></div>" +
17302
- "</div>",
17303
- );
17304
- }
17305
- it("should clean data of elements removed for directive template", () => {
17306
- testReplaceElementCleanup({});
17307
- });
17308
- it("should clean data of elements removed for directive templateUrl", () => {
17309
- testReplaceElementCleanup({ asyncTemplate: true });
17310
- });
17311
- it("should clean data of elements transcluded into directive template", () => {
17312
- testReplaceElementCleanup({ transclude: true });
17313
- });
17314
- it("should clean data of elements transcluded into directive templateUrl", () => {
17315
- testReplaceElementCleanup({ transclude: true, asyncTemplate: true });
17316
- });
17317
- it("should clean data of elements replaced with directive template", () => {
17318
- testReplaceElementCleanup({ replace: true });
17319
- });
17320
- it("should clean data of elements replaced with directive templateUrl", () => {
17321
- testReplaceElementCleanup({ replace: true, asyncTemplate: true });
17322
- });
17323
- });
17324
-
17325
16721
  describe("component helper", () => {
17326
16722
  it("should return the module", () => {
17327
16723
  const myModule = module;