@angular-wave/angular.ts 0.4.2 → 0.4.3

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 (54) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +7 -7
  4. package/src/angular.spec.js +1 -264
  5. package/src/animations/animate-css-driver.js +2 -2
  6. package/src/animations/animate-css.js +7 -8
  7. package/src/animations/animate-js-driver.js +1 -3
  8. package/src/animations/animate-js.js +4 -4
  9. package/src/animations/animate-queue.js +1 -2
  10. package/src/animations/animation.js +3 -3
  11. package/src/animations/shared.js +14 -12
  12. package/src/core/compile/attributes.js +2 -3
  13. package/src/core/compile/compile.js +247 -231
  14. package/src/core/compile/compile.spec.js +46 -51
  15. package/src/core/compile/compile.test.js +1 -1
  16. package/src/core/interval/interval.test.js +1 -1
  17. package/src/core/parse/parse.js +2 -2
  18. package/src/core/sce/sce.js +1 -2
  19. package/src/core/scope/scope.js +1 -2
  20. package/src/directive/attrs/attrs.test.js +11 -0
  21. package/src/directive/attrs/boolean.html +18 -0
  22. package/src/directive/attrs/boolean.test.js +11 -0
  23. package/src/directive/attrs/element-style.html +21 -0
  24. package/src/directive/attrs/element-style.test.js +11 -0
  25. package/src/directive/bind/bing-html.spec.js +1 -1
  26. package/src/directive/form/form.js +12 -19
  27. package/src/directive/if/if.spec.js +2 -3
  28. package/src/directive/if/if.test.js +1 -2
  29. package/src/directive/include/include.js +2 -2
  30. package/src/directive/input/input.js +1 -2
  31. package/src/directive/input/input.spec.js +187 -191
  32. package/src/directive/list/list.js +2 -2
  33. package/src/directive/model/model.js +12 -17
  34. package/src/directive/model-options/model-options.js +22 -26
  35. package/src/directive/options/options.js +1 -3
  36. package/src/directive/options/options.spec.js +3 -4
  37. package/src/directive/repeat/repeat.js +2 -2
  38. package/src/directive/repeat/repeat.spec.js +48 -57
  39. package/src/directive/select/select.spec.js +9 -10
  40. package/src/directive/switch/switch.js +1 -2
  41. package/src/router/directives/state-directives.js +18 -16
  42. package/src/router/directives/view-directive.js +2 -2
  43. package/src/router/state/views.js +2 -2
  44. package/src/router/url/url-service.js +2 -8
  45. package/src/router/url/url-service.spec.js +3 -4
  46. package/src/services/http/http.js +5 -6
  47. package/src/services/http-backend/http-backend.js +19 -17
  48. package/src/shared/common.js +5 -8
  49. package/src/shared/jqlite/jqlite.js +14 -12
  50. package/src/shared/jqlite/jqlite.spec.js +2 -2
  51. package/src/shared/utils.js +15 -92
  52. package/types/directive/form/form.d.ts +1 -0
  53. package/types/shared/common.d.ts +0 -1
  54. package/types/shared/utils.d.ts +0 -35
@@ -2,7 +2,6 @@ import { Angular } from "../../loader";
2
2
  import { createInjector } from "../di/injector";
3
3
  import { dealoc, JQLite, getOrSetCacheData } from "../../shared/jqlite/jqlite";
4
4
  import {
5
- forEach,
6
5
  isFunction,
7
6
  valueFn,
8
7
  isElement,
@@ -435,42 +434,36 @@ describe("$compile", () => {
435
434
  expect(el.data("hasCompiled")).toBe(true);
436
435
  });
437
436
 
438
- forEach(
439
- {
440
- E: { element: true, attribute: false },
441
- A: { element: false, attribute: true },
442
- EA: { element: true, attribute: true },
443
- },
444
- function (expected, restrict) {
445
- describe("restricted to " + restrict, () => {
446
- forEach(
447
- {
448
- element: "<my-directive></my-directive>",
449
- attribute: "<div my-directive></div>",
450
- },
451
- function (dom, type) {
452
- it(
453
- (expected[type] ? "matches" : "does not match") + " on " + type,
454
- () => {
455
- var hasCompiled = false;
456
- myModule.directive("myDirective", () => {
457
- return {
458
- restrict: restrict,
459
- compile: () => {
460
- hasCompiled = true;
461
- },
462
- };
463
- });
464
- reloadModules();
465
- $compile(dom);
466
- expect(hasCompiled).toBe(expected[type]);
467
- },
468
- );
437
+ Object.entries({
438
+ E: { element: true, attribute: false },
439
+ A: { element: false, attribute: true },
440
+ EA: { element: true, attribute: true },
441
+ }).forEach(([restrict, expected]) => {
442
+ describe("restricted to " + restrict, () => {
443
+ Object.entries({
444
+ element: "<my-directive></my-directive>",
445
+ attribute: "<div my-directive></div>",
446
+ }).forEach(([type, dom]) => {
447
+ it(
448
+ (expected[type] ? "matches" : "does not match") + " on " + type,
449
+ () => {
450
+ var hasCompiled = false;
451
+ myModule.directive("myDirective", () => {
452
+ return {
453
+ restrict: restrict,
454
+ compile: () => {
455
+ hasCompiled = true;
456
+ },
457
+ };
458
+ });
459
+ reloadModules();
460
+ $compile(dom);
461
+ expect(hasCompiled).toBe(expected[type]);
469
462
  },
470
463
  );
471
464
  });
472
- },
473
- );
465
+ });
466
+ });
474
467
 
475
468
  it("applies to attributes when no restrict given", () => {
476
469
  var hasCompiled = false;
@@ -5182,14 +5175,16 @@ describe("$compile", () => {
5182
5175
 
5183
5176
  describe("restrict", () => {
5184
5177
  it("should allow restriction of availability", () => {
5185
- forEach({ div: "E", attr: "A", all: "EA" }, (restrict, name) => {
5186
- myModule.directive(name, () => ({
5187
- restrict,
5188
- compile: valueFn((scope, element, attr) => {
5189
- log.push(name);
5190
- }),
5191
- }));
5192
- });
5178
+ Object.entries({ div: "E", attr: "A", all: "EA" }).forEach(
5179
+ ([name, restrict]) => {
5180
+ myModule.directive(name, () => ({
5181
+ restrict,
5182
+ compile: valueFn((scope, element, attr) => {
5183
+ log.push(name);
5184
+ }),
5185
+ }));
5186
+ },
5187
+ );
5193
5188
 
5194
5189
  reloadModules();
5195
5190
  dealoc($compile('<span div class="div"></span>')($rootScope));
@@ -11332,9 +11327,9 @@ describe("$compile", () => {
11332
11327
  },
11333
11328
  ];
11334
11329
 
11335
- forEach(controllerOptions, (controllerOption) => {
11336
- forEach(scopeOptions, (scopeOption) => {
11337
- forEach(templateOptions, (templateOption) => {
11330
+ controllerOptions.forEach((controllerOption) => {
11331
+ Object.values(scopeOptions).forEach((scopeOption) => {
11332
+ Object.values(templateOptions).forEach((templateOption) => {
11338
11333
  const description = [];
11339
11334
  const ddo = {
11340
11335
  bindToController: {
@@ -11345,8 +11340,7 @@ describe("$compile", () => {
11345
11340
  },
11346
11341
  };
11347
11342
 
11348
- forEach(
11349
- [controllerOption, scopeOption, templateOption],
11343
+ [controllerOption, scopeOption, templateOption].forEach(
11350
11344
  (option) => {
11351
11345
  description.push(option.description);
11352
11346
  delete option.description;
@@ -15924,7 +15918,7 @@ describe("$compile", () => {
15924
15918
  "http://example.com/image1.jpg?x=a2x,b 1x,http://example.com/ima,ge2.jpg 2x",
15925
15919
  };
15926
15920
 
15927
- forEach(testSet, (ref, url) => {
15921
+ Object.entries(testSet).forEach(([url, ref]) => {
15928
15922
  $rootScope.testUrl = url;
15929
15923
  $rootScope.$digest();
15930
15924
  expect(element.attr("srcset")).toEqual(ref);
@@ -17257,7 +17251,7 @@ describe("$compile", () => {
17257
17251
  const toCompile = JQLite(template);
17258
17252
 
17259
17253
  const preCompiledChildren = getAll(toCompile);
17260
- forEach(preCompiledChildren, (element, i) => {
17254
+ Object.entries(preCompiledChildren).forEach(([i, element]) => {
17261
17255
  getOrSetCacheData(element, "foo", `template#${i}`);
17262
17256
  });
17263
17257
 
@@ -17265,10 +17259,11 @@ describe("$compile", () => {
17265
17259
  $rootScope.$apply();
17266
17260
  linkedElements.remove();
17267
17261
 
17268
- forEach(preCompiledChildren, (element, i) => {
17262
+ Object.entries(preCompiledChildren).forEach(([i, element]) => {
17269
17263
  expect(CACHE.has(element[EXPANDO])).toBe(false, `template#${i}`);
17270
17264
  });
17271
- forEach(getAll(linkedElements), (element, i) => {
17265
+
17266
+ Object.entries(linkedElements).forEach(([i, element]) => {
17272
17267
  expect(CACHE.has(element[EXPANDO])).toBe(false, `linked#${i}`);
17273
17268
  });
17274
17269
  }
@@ -5,7 +5,7 @@ const TEST_URL = "src/core/compile/compile.html?random=false";
5
5
  test("unit tests contain no errors", async ({ page }) => {
6
6
  await page.goto(TEST_URL);
7
7
  await page.content();
8
- await page.waitForTimeout(5000);
8
+ await page.waitForTimeout(1000);
9
9
  await expect(page.locator(".jasmine-overall-result")).toHaveText(
10
10
  /0 failures/,
11
11
  );
@@ -5,7 +5,7 @@ const TEST_URL = "src/core/interval/interval.html";
5
5
  test("unit tests contain no errors", async ({ page }) => {
6
6
  await page.goto(TEST_URL);
7
7
  await page.content();
8
- await page.waitForTimeout(100);
8
+ await page.waitForTimeout(500);
9
9
  await expect(page.locator(".jasmine-overall-result")).toHaveText(
10
10
  /0 failures/,
11
11
  );
@@ -1,4 +1,4 @@
1
- import { forEach, isDefined, isFunction } from "../../shared/utils.js";
1
+ import { isDefined, isFunction } from "../../shared/utils.js";
2
2
  import { PURITY_RELATIVE } from "./interpreter.js";
3
3
  import { Lexer } from "./lexer/lexer.js";
4
4
  import { Parser } from "./parser/parser.js";
@@ -382,7 +382,7 @@ function expressionInputDirtyCheck(
382
382
 
383
383
  function isAllDefined(value) {
384
384
  let allDefined = true;
385
- forEach(value, (val) => {
385
+ Object.values(value).forEach((val) => {
386
386
  if (!isDefined(val)) allDefined = false;
387
387
  });
388
388
  return allDefined;
@@ -4,7 +4,6 @@ import {
4
4
  urlResolve,
5
5
  } from "./../url-utils/url-utils";
6
6
  import {
7
- forEach,
8
7
  isFunction,
9
8
  isRegExp,
10
9
  isString,
@@ -731,7 +730,7 @@ export function SceProvider() {
731
730
  const { getTrusted } = sce;
732
731
  const { trustAs } = sce;
733
732
 
734
- forEach(SCE_CONTEXTS, (enumValue, name) => {
733
+ Object.entries(SCE_CONTEXTS).forEach(([name, enumValue]) => {
735
734
  const lName = lowercase(name);
736
735
  sce[snakeToCamel(`parse_as_${lName}`)] = function (expr) {
737
736
  return parse(enumValue, expr);
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  concat,
3
- forEach,
4
3
  minErr,
5
4
  nextUid,
6
5
  isFunction,
@@ -473,7 +472,7 @@ export class Scope {
473
472
  });
474
473
  }
475
474
 
476
- forEach(watchExpressions, (expr, i) => {
475
+ Object.entries(watchExpressions).forEach(([i, expr]) => {
477
476
  const unwatchFn = self.$watch(expr, (value) => {
478
477
  newValues[i] = value;
479
478
  if (!changeReactionScheduled) {
@@ -0,0 +1,11 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const TEST_URL = "src/directive/attrs/attrs.html";
4
+
5
+ test("unit tests contain no errors", async ({ page }) => {
6
+ await page.goto(TEST_URL);
7
+ await page.content();
8
+ await expect(page.locator(".jasmine-overall-result")).toHaveText(
9
+ /0 failures/,
10
+ );
11
+ });
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>AngularTS Test Runner</title>
6
+
7
+ <link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8
+ <link rel="stylesheet" href="/jasmine/jasmine-5.1.2/jasmine.css" />
9
+ <script src="/jasmine/jasmine-5.1.2/jasmine.js"></script>
10
+ <script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
11
+ <script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
12
+ <script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
13
+ <script type="module" src="/src/directive/attrs/boolean.spec.js"></script>
14
+ </head>
15
+ <body>
16
+ <div id="dummy"></div>
17
+ </body>
18
+ </html>
@@ -0,0 +1,11 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const TEST_URL = "src/directive/attrs/boolean.html";
4
+
5
+ test("unit tests contain no errors", async ({ page }) => {
6
+ await page.goto(TEST_URL);
7
+ await page.content();
8
+ await expect(page.locator(".jasmine-overall-result")).toHaveText(
9
+ /0 failures/,
10
+ );
11
+ });
@@ -0,0 +1,21 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>AngularTS Test Runner</title>
6
+
7
+ <link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8
+ <link rel="stylesheet" href="/jasmine/jasmine-5.1.2/jasmine.css" />
9
+ <script src="/jasmine/jasmine-5.1.2/jasmine.js"></script>
10
+ <script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
11
+ <script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
12
+ <script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
13
+ <script
14
+ type="module"
15
+ src="/src/directive/attrs/element-style.spec.js"
16
+ ></script>
17
+ </head>
18
+ <body>
19
+ <div id="dummy"></div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,11 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const TEST_URL = "src/directive/attrs/element-style.html";
4
+
5
+ test("unit tests contain no errors", async ({ page }) => {
6
+ await page.goto(TEST_URL);
7
+ await page.content();
8
+ await expect(page.locator(".jasmine-overall-result")).toHaveText(
9
+ /0 failures/,
10
+ );
11
+ });
@@ -23,7 +23,7 @@ describe("ngBindHtml", () => {
23
23
  it("should reset html when value is null or undefined", () => {
24
24
  const element = $compile('<div ng-bind-html="html"></div>')($rootScope);
25
25
 
26
- forEach([null, undefined, ""], (val) => {
26
+ [null, undefined, ""].forEach((val) => {
27
27
  $rootScope.html = "some val";
28
28
  $rootScope.$digest();
29
29
  expect(element.html()).toEqual("some val");
@@ -5,7 +5,6 @@ import {
5
5
  arrayRemove,
6
6
  isBoolean,
7
7
  snakeCase,
8
- forEach,
9
8
  extend,
10
9
  isUndefined,
11
10
  } from "../../shared/utils";
@@ -215,32 +214,26 @@ FormController.prototype = {
215
214
  if (control.$name && this[control.$name] === control) {
216
215
  delete this[control.$name];
217
216
  }
218
- forEach(
219
- this.$pending,
220
- function (value, name) {
217
+ this.$pending &&
218
+ Object.keys(this.$pending).forEach((name) => {
221
219
  this.$setValidity(name, null, control);
222
- },
223
- this,
224
- );
225
- forEach(
226
- this.$error,
227
- function (value, name) {
220
+ });
221
+ this.$error &&
222
+ Object.keys(this.$error).forEach((name) => {
228
223
  this.$setValidity(name, null, control);
229
- },
230
- this,
231
- );
232
- forEach(
233
- this.$$success,
234
- function (value, name) {
224
+ });
225
+ this.$$success &&
226
+ Object.keys(this.$$success).forEach((name) => {
235
227
  this.$setValidity(name, null, control);
236
- },
237
- this,
238
- );
228
+ });
239
229
 
240
230
  arrayRemove(this.$$controls, control);
241
231
  control.$$parentForm = nullFormCtrl;
242
232
  },
243
233
 
234
+ // eslint-disable-next-line no-unused-vars
235
+ $setValidity: function (_a, _b, _c) {},
236
+
244
237
  /**
245
238
  * Sets the form to a dirty state.
246
239
  *
@@ -1,7 +1,6 @@
1
1
  import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
2
- import { forEach, valueFn } from "../../shared/utils";
2
+ import { valueFn } from "../../shared/utils";
3
3
  import { Angular } from "../../loader";
4
- import { createInjector } from "../../core/di/injector";
5
4
  import { wait } from "../../shared/test-utils";
6
5
 
7
6
  describe("ngIf", () => {
@@ -37,7 +36,7 @@ describe("ngIf", () => {
37
36
  });
38
37
 
39
38
  function makeIf() {
40
- forEach(arguments, (expr) => {
39
+ Array.from(arguments).forEach((expr) => {
41
40
  element.append(
42
41
  $compile(`<div class="my-class" ng-if="${expr}"><div>Hi</div></div>`)(
43
42
  $scope,
@@ -87,7 +87,7 @@ test.describe("animations", () => {
87
87
  await expect(animated).toHaveClass(/ng-enter-active/);
88
88
 
89
89
  // Wait for the transition to complete
90
- await page.waitForTimeout(500);
90
+ await page.waitForTimeout(100);
91
91
  await expect(animated).not.toHaveClass(/ng-enter/);
92
92
  await expect(animated).not.toHaveClass(/ng-enter-active/);
93
93
 
@@ -106,7 +106,6 @@ test.describe("animations", () => {
106
106
  await page.goto("src/directive/if/if-animate-css.html");
107
107
  await page.content();
108
108
  await page.click('button:has-text("Fade In!")');
109
- await page.waitForTimeout(600);
110
109
  let animated = await page.locator("#circle");
111
110
  await expect(animated).not.toHaveClass(/ng-enter/);
112
111
  await expect(animated).not.toHaveClass(/ng-enter-active/);
@@ -15,7 +15,7 @@ export const ngIncludeDirective = [
15
15
  * @returns
16
16
  */
17
17
  ($templateRequest, $anchorScroll, $animate) => ({
18
- restrict: "ECA",
18
+ restrict: "EA",
19
19
  priority: 400,
20
20
  terminal: true,
21
21
  transclude: "element",
@@ -129,7 +129,7 @@ export const ngIncludeDirective = [
129
129
  export const ngIncludeFillContentDirective = [
130
130
  "$compile",
131
131
  ($compile) => ({
132
- restrict: "ECA",
132
+ restrict: "EA",
133
133
  priority: -400,
134
134
  require: "ngInclude",
135
135
  link(scope, $element, _$attr, ctrl) {
@@ -8,7 +8,6 @@ import {
8
8
  isNumber,
9
9
  isNumberNaN,
10
10
  isDate,
11
- forEach,
12
11
  convertTimezoneToLocal,
13
12
  addDateMinutes,
14
13
  timezoneToOffset,
@@ -286,7 +285,7 @@ export function createDateParser(regexp, mapping) {
286
285
  map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 };
287
286
  }
288
287
 
289
- forEach(parts, (part, index) => {
288
+ Object.entries(parts).forEach(([index, part]) => {
290
289
  if (index < mapping.length) {
291
290
  map[mapping[index]] = +part;
292
291
  }