@angular-wave/angular.ts 0.0.6 → 0.0.7

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.
package/src/loader.js CHANGED
@@ -28,20 +28,6 @@ import { jqLite, startingTag } from "./jqLite";
28
28
  import { createInjector } from "./injector";
29
29
  import { CACHE } from "./core/cache";
30
30
 
31
- /**
32
- * @ngdoc module
33
- * @name ng
34
-
35
- * @installation
36
- * @description
37
- *
38
- * The ng module is loaded by default when an AngularJS application is started. The module itself
39
- * contains the essential components for an AngularJS application to function. The table below
40
- * lists a high level breakdown of each of the services/factories, filters, directives and testing
41
- * components available within this core module.
42
- *
43
- */
44
-
45
31
  const ngMinErr = minErr("ng");
46
32
 
47
33
  /** @type {Object.<string, angular.IModule>} */
@@ -131,7 +117,7 @@ export class Angular {
131
117
  * </html>
132
118
  * ```
133
119
  *
134
- * @param {string | Element | JQuery | Document} element DOM element which is the root of AngularJS application.
120
+ * @param {string | Element | Document} element DOM element which is the root of AngularJS application.
135
121
  * @param {Array<string | Function | any[]>=} modules an array of modules to load into the application.
136
122
  * Each item in the array should be the name of a predefined module or a (DI annotated)
137
123
  * function that will be invoked by the injector as a `config` block.
package/src/loader.md ADDED
@@ -0,0 +1,13 @@
1
+ /\*\*
2
+
3
+ - @ngdoc module
4
+ - @name ng
5
+
6
+ - @installation
7
+ - @description
8
+ -
9
+ - The ng module is loaded by default when an AngularJS application is started. The module itself
10
+ - contains the essential components for an AngularJS application to function. The table below
11
+ - lists a high level breakdown of each of the services/factories, filters, directives and testing
12
+ - components available within this core module.
13
+ - \*/
@@ -548,13 +548,13 @@ describe("jqLite", () => {
548
548
  });
549
549
 
550
550
  it("should not add to the cache if the node is a comment or text node", () => {
551
- const initial = Object.keys(jqLite.cache).length;
551
+ const initial = CACHE.size;
552
552
  const nodes = jqLite("<!-- some comment --> and some text");
553
- expect(Object.keys(jqLite.cache).length).toEqual(initial);
553
+ expect(CACHE.size).toEqual(initial);
554
554
  nodes.data("someKey");
555
- expect(Object.keys(jqLite.cache).length).toEqual(initial);
555
+ expect(CACHE.size).toEqual(initial);
556
556
  nodes.data("someKey", "someValue");
557
- expect(Object.keys(jqLite.cache).length).toEqual(initial);
557
+ expect(CACHE.size).toEqual(initial);
558
558
  });
559
559
 
560
560
  it("should provide the non-wrapped data calls", () => {
@@ -5081,36 +5081,36 @@ describe("$compile", () => {
5081
5081
  // We compile the contents of element (i.e. not element itself)
5082
5082
  // Then delete these contents and check the cache has been reset to zero
5083
5083
  // Clear cache
5084
- JQLite.cache.clear();
5084
+ CACHE.clear();
5085
5085
  window.angular.module("test1", ["ng"]);
5086
5086
  createInjector(["test1"]).invoke(($compile) => {
5087
- expect(JQLite.cache.size).toEqual(1);
5087
+ expect(CACHE.size).toEqual(1);
5088
5088
  // First with only elements at the top level
5089
5089
  element = JQLite("<div><div></div></div>");
5090
5090
  $compile(element[0].childNodes)($rootScope);
5091
- expect(JQLite.cache.size).toEqual(2);
5091
+ expect(CACHE.size).toEqual(2);
5092
5092
  element.empty();
5093
- expect(JQLite.cache.size).toEqual(1);
5093
+ expect(CACHE.size).toEqual(1);
5094
5094
 
5095
5095
  // Next with non-empty text nodes at the top level
5096
5096
  // (in this case the compiler will wrap them in a <span>)
5097
5097
  element = JQLite("<div>xxx</div>");
5098
5098
  $compile(element[0].childNodes)($rootScope);
5099
5099
  element.empty();
5100
- expect(JQLite.cache.size).toEqual(1);
5100
+ expect(CACHE.size).toEqual(1);
5101
5101
 
5102
5102
  // Next with comment nodes at the top level
5103
5103
  element = JQLite("<div><!-- comment --></div>");
5104
5104
  $compile(element[0].childNodes)($rootScope);
5105
5105
  element.empty();
5106
- expect(JQLite.cache.size).toEqual(1);
5106
+ expect(CACHE.size).toEqual(1);
5107
5107
 
5108
5108
  // Finally with empty text nodes at the top level
5109
5109
  element = JQLite("<div> \n<div></div> </div>");
5110
5110
  $compile(element[0].childNodes)($rootScope);
5111
- expect(JQLite.cache.size).toEqual(2);
5111
+ expect(CACHE.size).toEqual(2);
5112
5112
  element.empty();
5113
- expect(JQLite.cache.size).toEqual(1);
5113
+ expect(CACHE.size).toEqual(1);
5114
5114
  });
5115
5115
  });
5116
5116
 
@@ -13790,28 +13790,28 @@ describe("$compile", () => {
13790
13790
  });
13791
13791
 
13792
13792
  it('should not leak if two "element" transclusions are on the same element', () => {
13793
- const cacheSize = JQLite.cache.size;
13793
+ const cacheSize = CACHE.size;
13794
13794
 
13795
13795
  element = $compile(
13796
13796
  '<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>',
13797
13797
  )($rootScope);
13798
- expect(JQLite.cache.size).toEqual(cacheSize + 1);
13798
+ expect(CACHE.size).toEqual(cacheSize + 1);
13799
13799
 
13800
13800
  $rootScope.$apply("xs = [0,1]");
13801
- expect(JQLite.cache.size).toEqual(cacheSize + 2);
13801
+ expect(CACHE.size).toEqual(cacheSize + 2);
13802
13802
 
13803
13803
  $rootScope.$apply("xs = [0]");
13804
- expect(JQLite.cache.size).toEqual(cacheSize + 1);
13804
+ expect(CACHE.size).toEqual(cacheSize + 1);
13805
13805
 
13806
13806
  $rootScope.$apply("xs = []");
13807
- expect(JQLite.cache.size).toEqual(cacheSize + 1);
13807
+ expect(CACHE.size).toEqual(cacheSize + 1);
13808
13808
 
13809
13809
  element.remove();
13810
- expect(JQLite.cache.size).toEqual(cacheSize + 0);
13810
+ expect(CACHE.size).toEqual(cacheSize + 0);
13811
13811
  });
13812
13812
 
13813
13813
  it('should not leak if two "element" transclusions are on the same element', () => {
13814
- const cacheSize = JQLite.cache.size;
13814
+ const cacheSize = CACHE.size;
13815
13815
  element = $compile(
13816
13816
  '<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>',
13817
13817
  )($rootScope);
@@ -13819,20 +13819,20 @@ describe("$compile", () => {
13819
13819
  $rootScope.$apply("xs = [0,1]");
13820
13820
  // At this point we have a bunch of comment placeholders but no real transcluded elements
13821
13821
  // So the cache only contains the root element's data
13822
- expect(JQLite.cache.size).toEqual(cacheSize + 1);
13822
+ expect(CACHE.size).toEqual(cacheSize + 1);
13823
13823
 
13824
13824
  $rootScope.$apply("val = true");
13825
13825
  // Now we have two concrete transcluded elements plus some comments so two more cache items
13826
- expect(JQLite.cache.size).toEqual(cacheSize + 3);
13826
+ expect(CACHE.size).toEqual(cacheSize + 3);
13827
13827
 
13828
13828
  $rootScope.$apply("val = false");
13829
13829
  // Once again we only have comments so no transcluded elements and the cache is back to just
13830
13830
  // the root element
13831
- expect(JQLite.cache.size).toEqual(cacheSize + 1);
13831
+ expect(CACHE.size).toEqual(cacheSize + 1);
13832
13832
 
13833
13833
  element.remove();
13834
13834
  // Now we've even removed the root element along with its cache
13835
- expect(JQLite.cache.size).toEqual(cacheSize + 0);
13835
+ expect(CACHE.size).toEqual(cacheSize + 0);
13836
13836
  });
13837
13837
 
13838
13838
  // it("should not leak when continuing the compilation of elements on a scope that was destroyed", () => {
@@ -13857,7 +13857,7 @@ describe("$compile", () => {
13857
13857
  // link: linkFn,
13858
13858
  // }));
13859
13859
  // initInjector("test1");
13860
- // const cacheSize = JQLite.cache.size;
13860
+ // const cacheSize = CACHE.size;
13861
13861
  // $templateCache.put("red.html", "<p>red</p>");
13862
13862
  // const template = $compile(
13863
13863
  // '<div ng-controller="Leak">' +
@@ -13872,7 +13872,7 @@ describe("$compile", () => {
13872
13872
  // $rootScope.$digest();
13873
13873
 
13874
13874
  // expect(linkFn).toHaveBeenCalled();
13875
- // expect(JQLite.cache.size).toEqual(cacheSize + 2);
13875
+ // expect(CACHE.size).toEqual(cacheSize + 2);
13876
13876
 
13877
13877
  // $templateCache.removeAll();
13878
13878
  // const destroyedScope = $rootScope.$new();
@@ -13903,7 +13903,7 @@ describe("$compile", () => {
13903
13903
  firstRepeatedElem = element.children(".ng-scope").eq(0);
13904
13904
 
13905
13905
  expect(firstRepeatedElem.data("$scope")).toBeDefined();
13906
- privateData = CACHE.get(firstRepeatedElem[0]);
13906
+ privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
13907
13907
  expect(privateData.events).toBeDefined();
13908
13908
 
13909
13909
  expect(privateData.events.click).toBeDefined();
@@ -13919,7 +13919,7 @@ describe("$compile", () => {
13919
13919
 
13920
13920
  expect(destroyCount).toBe(2);
13921
13921
  expect(firstRepeatedElem.data("$scope")).not.toBeDefined();
13922
- privateData = CACHE.get(firstRepeatedElem[0]);
13922
+ privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
13923
13923
  expect(privateData && privateData.events).not.toBeDefined();
13924
13924
  }
13925
13925
 
@@ -14808,7 +14808,7 @@ describe("$compile", () => {
14808
14808
 
14809
14809
  it("should not leak memory with nested transclusion", () => {
14810
14810
  let size;
14811
- const initialSize = JQLite.cache.size;
14811
+ const initialSize = CACHE.size;
14812
14812
 
14813
14813
  element = JQLite(
14814
14814
  '<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>',
@@ -14817,14 +14817,14 @@ describe("$compile", () => {
14817
14817
 
14818
14818
  $rootScope.nums = [0, 1, 2];
14819
14819
  $rootScope.$apply();
14820
- size = JQLite.cache.size;
14820
+ size = CACHE.size;
14821
14821
 
14822
14822
  $rootScope.nums = [3, 4, 5];
14823
14823
  $rootScope.$apply();
14824
- expect(JQLite.cache.size).toEqual(size);
14824
+ expect(CACHE.size).toEqual(size);
14825
14825
 
14826
14826
  element.remove();
14827
- expect(JQLite.cache.size).toEqual(initialSize);
14827
+ expect(CACHE.size).toEqual(initialSize);
14828
14828
  });
14829
14829
  });
14830
14830
 
@@ -1,41 +0,0 @@
1
- /**
2
- * @param {string} path - The path to parse. (It is assumed to have query and hash stripped off.)
3
- * @param {Object} opts - Options.
4
- * @return {Object} - An object containing an array of path parameter names (`keys`) and a regular
5
- * expression (`regexp`) that can be used to identify a matching URL and extract the path
6
- * parameter values.
7
- *
8
- * @description
9
- * Parses the given path, extracting path parameter names and a regular expression to match URLs.
10
- *
11
- * Originally inspired by `pathRexp` in `visionmedia/express/lib/utils.js`.
12
- */
13
- export function routeToRegExp(path, opts) {
14
- const keys = [];
15
-
16
- let pattern = path
17
- .replace(/([().])/g, "\\$1")
18
- .replace(/(\/)?:(\w+)(\*\?|[?*])?/g, (_, slash, key, option) => {
19
- const optional = option === "?" || option === "*?";
20
- const star = option === "*" || option === "*?";
21
- keys.push({ name: key, optional });
22
- return (
23
- (optional ? `(?:${slash || ""}` : `${slash || ""}(?:`) +
24
- (star ? "(.+?)" : "([^/]+)") +
25
- (optional ? "?)?" : ")")
26
- );
27
- })
28
- .replace(/([/$*])/g, "\\$1");
29
-
30
- if (opts.ignoreTrailingSlashes) {
31
- pattern = `${pattern.replace(/\/+$/, "")}/*`;
32
- }
33
-
34
- return {
35
- keys,
36
- regexp: new RegExp(
37
- `^${pattern}(?:[?#]|$)`,
38
- opts.caseInsensitiveMatch ? "i" : "",
39
- ),
40
- };
41
- }