@angular-wave/angular.ts 0.4.1 → 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 (90) 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 +6 -6
  10. package/src/animations/animation.js +3 -3
  11. package/src/animations/shared.js +16 -14
  12. package/src/core/compile/attributes.js +2 -3
  13. package/src/core/compile/compile.js +248 -232
  14. package/src/core/compile/compile.spec.js +46 -51
  15. package/src/core/compile/compile.test.js +1 -1
  16. package/src/core/interpolate/interpolate.js +2 -2
  17. package/src/core/interval/interval.test.js +1 -1
  18. package/src/core/{parser/lexer.html → parse/ast/ast.html} +1 -1
  19. package/src/core/{parser → parse/ast}/ast.js +43 -29
  20. package/src/core/parse/ast/ast.spec.js +1462 -0
  21. package/src/core/parse/ast/ast.test.js +10 -0
  22. package/src/core/{parser → parse}/interpreter.js +10 -10
  23. package/src/core/parse/lexer/lexer.html +18 -0
  24. package/src/core/{parser → parse/lexer}/lexer.js +1 -1
  25. package/src/core/{parser → parse/lexer}/lexer.spec.js +2 -2
  26. package/src/core/parse/lexer/lexer.test.js +10 -0
  27. package/src/core/{parser → parse}/parse.html +1 -1
  28. package/src/core/{parser → parse}/parse.js +6 -6
  29. package/src/core/{parser → parse}/parse.spec.js +6 -1725
  30. package/src/core/parse/parse.test.js +10 -0
  31. package/src/core/parse/parser/parser.html +18 -0
  32. package/src/core/{parser → parse/parser}/parser.js +6 -6
  33. package/src/core/parse/parser/parser.spec.js +8 -0
  34. package/src/core/parse/parser/parser.test.js +10 -0
  35. package/src/core/sce/sce.js +1 -2
  36. package/src/core/scope/scope.js +4 -5
  37. package/src/directive/attrs/attrs.test.js +11 -0
  38. package/src/directive/attrs/boolean.html +18 -0
  39. package/src/directive/attrs/boolean.test.js +11 -0
  40. package/src/directive/attrs/element-style.html +21 -0
  41. package/src/directive/attrs/element-style.test.js +11 -0
  42. package/src/directive/bind/bing-html.spec.js +1 -1
  43. package/src/directive/class/class.js +1 -1
  44. package/src/directive/form/form.js +12 -19
  45. package/src/directive/if/if.spec.js +2 -3
  46. package/src/directive/if/if.test.js +1 -2
  47. package/src/directive/include/include.js +2 -2
  48. package/src/directive/input/input.js +1 -2
  49. package/src/directive/input/input.spec.js +187 -191
  50. package/src/directive/list/list.js +2 -2
  51. package/src/directive/model/model.js +14 -19
  52. package/src/directive/model-options/model-options.js +22 -26
  53. package/src/directive/options/options.js +1 -3
  54. package/src/directive/options/options.spec.js +3 -4
  55. package/src/directive/repeat/repeat.js +2 -2
  56. package/src/directive/repeat/repeat.spec.js +48 -57
  57. package/src/directive/select/select.spec.js +9 -10
  58. package/src/directive/switch/switch.js +1 -2
  59. package/src/directive/validators/validators.js +3 -3
  60. package/src/public.js +1 -1
  61. package/src/router/directives/state-directives.js +18 -16
  62. package/src/router/directives/view-directive.js +2 -2
  63. package/src/router/state/views.js +2 -2
  64. package/src/router/url/url-service.js +2 -8
  65. package/src/router/url/url-service.spec.js +3 -4
  66. package/src/services/http/http.js +5 -6
  67. package/src/services/http-backend/http-backend.js +19 -17
  68. package/src/shared/common.js +5 -8
  69. package/src/shared/jqlite/jqlite.js +14 -12
  70. package/src/shared/jqlite/jqlite.spec.js +2 -2
  71. package/src/shared/utils.js +15 -92
  72. package/types/animations/shared.d.ts +1 -1
  73. package/types/core/compile/compile.d.ts +1 -1
  74. package/types/core/interpolate/interpolate.d.ts +1 -1
  75. package/types/core/{parser → parse/ast}/ast.d.ts +17 -17
  76. package/types/core/{parser → parse}/interpreter.d.ts +7 -7
  77. package/types/core/{parser → parse/parser}/parser.d.ts +8 -8
  78. package/types/core/scope/scope.d.ts +3 -3
  79. package/types/directive/class/class.d.ts +3 -3
  80. package/types/directive/form/form.d.ts +1 -0
  81. package/types/directive/model/model.d.ts +6 -6
  82. package/types/directive/validators/validators.d.ts +3 -3
  83. package/types/shared/common.d.ts +0 -1
  84. package/types/shared/utils.d.ts +0 -35
  85. package/src/core/parser/parser.test.js +0 -19
  86. /package/src/core/{parser → parse}/ast-type.js +0 -0
  87. /package/src/core/{parser → parse}/parse.md +0 -0
  88. /package/types/core/{parser → parse}/ast-type.d.ts +0 -0
  89. /package/types/core/{parser → parse/lexer}/lexer.d.ts +0 -0
  90. /package/types/core/{parser → parse}/parse.d.ts +0 -0
@@ -1,7 +1,6 @@
1
1
  import { Angular } from "../../loader";
2
- import { createInjector } from "../../core/di/injector";
3
2
  import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
4
- import { forEach, valueFn } from "../../shared/utils";
3
+ import { valueFn } from "../../shared/utils";
5
4
 
6
5
  describe("ngRepeat", () => {
7
6
  let element;
@@ -263,10 +262,10 @@ describe("ngRepeat", () => {
263
262
  it("should track using provided function when a filter is present", () => {
264
263
  scope.newArray = function (items) {
265
264
  const newArray = [];
266
- forEach(items, (item) => {
265
+ Object.entries(items).forEach(([id, name]) => {
267
266
  newArray.push({
268
- id: item.id,
269
- name: item.name,
267
+ id: id,
268
+ name: name,
270
269
  });
271
270
  });
272
271
  return newArray;
@@ -519,22 +518,17 @@ describe("ngRepeat", () => {
519
518
  { name: "orange" },
520
519
  { name: "blonde" },
521
520
  ];
522
- forEach(
523
- ["null2", "qthis", "qthisq", "fundefined", "$$parent"],
524
- (name) => {
525
- const expr = `item in items | filter:x as ${name} track by $index`;
526
- element = $compile(`<div><div ng-repeat="${expr}"></div></div>`)(
527
- scope,
528
- );
529
- scope.$digest();
530
- expect(scope[name]).toEqual([
531
- { name: "blue" },
532
- { name: "black" },
533
- { name: "blonde" },
534
- ]);
535
- dealoc(element);
536
- },
537
- );
521
+ ["null2", "qthis", "qthisq", "fundefined", "$$parent"].forEach((name) => {
522
+ const expr = `item in items | filter:x as ${name} track by $index`;
523
+ element = $compile(`<div><div ng-repeat="${expr}"></div></div>`)(scope);
524
+ scope.$digest();
525
+ expect(scope[name]).toEqual([
526
+ { name: "blue" },
527
+ { name: "black" },
528
+ { name: "blonde" },
529
+ ]);
530
+ dealoc(element);
531
+ });
538
532
  });
539
533
 
540
534
  it("should throw if alias identifier is not a simple identifier", () => {
@@ -548,42 +542,39 @@ describe("ngRepeat", () => {
548
542
  { name: "blonde" },
549
543
  ];
550
544
 
551
- forEach(
552
- [
553
- "null",
554
- "this",
555
- "undefined",
556
- "$parent",
557
- "$root",
558
- "$id",
559
- "$index",
560
- "$first",
561
- "$middle",
562
- "$last",
563
- "$even",
564
- "$odd",
565
- "obj[key]",
566
- 'obj["key"]',
567
- "obj['key']",
568
- "obj.property",
569
- "foo=6",
570
- ],
571
- (expr) => {
572
- const expression =
573
- `item in items | filter:x as ${expr} track by $index`.replace(
574
- /"/g,
575
- "&quot;",
576
- );
577
- element = $compile(
578
- `<div>` +
579
- ` <div ng-repeat="${expression}">{{item}}</div>` +
580
- `</div>`,
581
- )(scope);
582
- expect(logs.shift().message).toMatch(/must be a valid JS identifier/);
583
-
584
- dealoc(element);
585
- },
586
- );
545
+ [
546
+ "null",
547
+ "this",
548
+ "undefined",
549
+ "$parent",
550
+ "$root",
551
+ "$id",
552
+ "$index",
553
+ "$first",
554
+ "$middle",
555
+ "$last",
556
+ "$even",
557
+ "$odd",
558
+ "obj[key]",
559
+ 'obj["key"]',
560
+ "obj['key']",
561
+ "obj.property",
562
+ "foo=6",
563
+ ].forEach((expr) => {
564
+ const expression =
565
+ `item in items | filter:x as ${expr} track by $index`.replace(
566
+ /"/g,
567
+ "&quot;",
568
+ );
569
+ element = $compile(
570
+ `<div>` +
571
+ ` <div ng-repeat="${expression}">{{item}}</div>` +
572
+ `</div>`,
573
+ )(scope);
574
+ expect(logs.shift().message).toMatch(/must be a valid JS identifier/);
575
+
576
+ dealoc(element);
577
+ });
587
578
  });
588
579
 
589
580
  it("should allow expressions over multiple lines", () => {
@@ -1,7 +1,6 @@
1
1
  import { Angular } from "../../loader";
2
- import { createInjector } from "../../core/di/injector";
3
2
  import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
4
- import { forEach, hashKey, equals, isNumberNaN } from "../../shared/utils";
3
+ import { hashKey, equals, isNumberNaN } from "../../shared/utils";
5
4
  import { browserTrigger } from "../../shared/test-utils";
6
5
 
7
6
  describe("select", () => {
@@ -118,8 +117,9 @@ describe("select", () => {
118
117
  const actualValues = {};
119
118
  let optionGroup;
120
119
  let optionValue;
121
-
122
- forEach(actual.find("option"), (option) => {
120
+ let options = actual.find("option");
121
+ for (let i = 0; i < options.length; i++) {
122
+ let option = options[i];
123
123
  optionGroup = option.parentNode.label || "";
124
124
  actualValues[optionGroup] = actualValues[optionGroup] || [];
125
125
  // IE9 doesn't populate the label property from the text property like other browsers
@@ -127,7 +127,7 @@ describe("select", () => {
127
127
  actualValues[optionGroup].push(
128
128
  option.selected ? [optionValue] : optionValue,
129
129
  );
130
- });
130
+ }
131
131
 
132
132
  const message = function () {
133
133
  return `Expected ${toJson(actualValues)} to equal ${toJson(expected)}.`;
@@ -1781,12 +1781,11 @@ describe("select", () => {
1781
1781
  // reset
1782
1782
  scope.selected = [];
1783
1783
  scope.$digest();
1784
+ let elems = element.find("option");
1784
1785
 
1785
- forEach(element.find("option"), (option) => {
1786
- // browserTrigger can't produce click + ctrl, so set selection manually
1787
- JQLite(option)[0].selected = true;
1788
- });
1789
-
1786
+ for (var i = 0; i < elems.length; i++) {
1787
+ JQLite(elems[i])[0].selected = true;
1788
+ }
1790
1789
  browserTrigger(element, "change");
1791
1790
 
1792
1791
  const arrayVal = ["a"];
@@ -1,4 +1,3 @@
1
- import { forEach } from "../../shared/utils";
2
1
  import { getBlockNodes } from "../../shared/jqlite/jqlite";
3
2
 
4
3
  export const ngSwitchDirective = [
@@ -53,7 +52,7 @@ export const ngSwitchDirective = [
53
52
  ngSwitchController.cases[`!${value}`] ||
54
53
  ngSwitchController.cases["?"])
55
54
  ) {
56
- forEach(selectedTranscludes, (selectedTransclude) => {
55
+ Object.values(selectedTranscludes).forEach((selectedTransclude) => {
57
56
  selectedTransclude.transclude((caseElement, selectedScope) => {
58
57
  selectedScopes.push(selectedScope);
59
58
  const anchor = selectedTransclude.element;
@@ -34,7 +34,7 @@ import { startingTag } from "../../shared/jqlite/jqlite";
34
34
  export const requiredDirective = [
35
35
  "$parse",
36
36
  /**
37
- * @param {import("../../core/parser/parse.js").ParseService} $parse
37
+ * @param {import("../../core/parse/parse.js").ParseService} $parse
38
38
  * @returns {import("../../types.js").Directive}
39
39
  */
40
40
  ($parse) => ({
@@ -117,7 +117,7 @@ export const requiredDirective = [
117
117
  export const patternDirective = [
118
118
  "$parse",
119
119
  /**
120
- * @param {import("../../core/parser/parse.js").ParseService} $parse
120
+ * @param {import("../../core/parse/parse.js").ParseService} $parse
121
121
  * @returns {import("../../types.js").Directive}
122
122
  */
123
123
  ($parse) => {
@@ -218,7 +218,7 @@ export const patternDirective = [
218
218
  export const maxlengthDirective = [
219
219
  "$parse",
220
220
  /**
221
- * @param {import("../../core/parser/parse.js").ParseService} $parse
221
+ * @param {import("../../core/parse/parse.js").ParseService} $parse
222
222
  * @returns {import("../../types.js").Directive}
223
223
  */
224
224
  ($parse) => ({
package/src/public.js CHANGED
@@ -73,7 +73,7 @@ import {
73
73
  import { HttpBackendProvider } from "./services/http-backend/http-backend";
74
74
  import { LocationProvider } from "./core/location/location";
75
75
  import { LogProvider } from "./services/log";
76
- import { ParseProvider } from "./core/parser/parse";
76
+ import { ParseProvider } from "./core/parse/parse.js";
77
77
  import { RootScopeProvider } from "./core/scope/scope";
78
78
  import { $QProvider } from "./core/q/q";
79
79
  import { SceProvider, SceDelegateProvider } from "./core/sce/sce";
@@ -1,4 +1,4 @@
1
- import { forEach, tail, unnestR, uniqR, removeFrom } from "../../shared/common";
1
+ import { tail, unnestR, uniqR, removeFrom } from "../../shared/common";
2
2
  import { isString, isObject } from "../../shared/utils";
3
3
 
4
4
  import { parse } from "../../shared/hof";
@@ -303,22 +303,24 @@ export function $StateRefActiveDirective(
303
303
  function setStatesFromDefinitionObject(statesDefinition) {
304
304
  if (isObject(statesDefinition)) {
305
305
  states = [];
306
- forEach(statesDefinition, function (stateOrName, activeClass) {
307
- // Helper function to abstract adding state.
308
- const addStateForClass = function (stateOrName, activeClass) {
309
- const ref = parseStateRef(stateOrName);
310
- addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
311
- };
312
- if (isString(stateOrName)) {
313
- // If state is string, just add it.
314
- addStateForClass(stateOrName, activeClass);
315
- } else if (Array.isArray(stateOrName)) {
316
- // If state is an array, iterate over it and add each array item individually.
317
- forEach(stateOrName, function (stateOrName) {
306
+ Object.entries(statesDefinition).forEach(
307
+ ([activeClass, stateOrName]) => {
308
+ // Helper function to abstract adding state.
309
+ const addStateForClass = function (stateOrName, activeClass) {
310
+ const ref = parseStateRef(stateOrName);
311
+ addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
312
+ };
313
+ if (isString(stateOrName)) {
314
+ // If state is string, just add it.
318
315
  addStateForClass(stateOrName, activeClass);
319
- });
320
- }
321
- });
316
+ } else if (Array.isArray(stateOrName)) {
317
+ // If state is an array, iterate over it and add each array item individually.
318
+ stateOrName.forEach((stateOrName) => {
319
+ addStateForClass(stateOrName, activeClass);
320
+ });
321
+ }
322
+ },
323
+ );
322
324
  }
323
325
  }
324
326
  function addState(stateName, stateParams, activeClass) {
@@ -158,7 +158,7 @@ export let ngView = [
158
158
  };
159
159
  const directive = {
160
160
  count: 0,
161
- restrict: "ECA",
161
+ restrict: "EA",
162
162
  terminal: true,
163
163
  priority: 400,
164
164
  transclude: "element",
@@ -304,7 +304,7 @@ export function $ViewDirectiveFill(
304
304
  const getControllerAs = parse("viewDecl.controllerAs");
305
305
  const getResolveAs = parse("viewDecl.resolveAs");
306
306
  return {
307
- restrict: "ECA",
307
+ restrict: "EA",
308
308
  priority: -400,
309
309
  compile: function (tElement) {
310
310
  const initial = tElement.html();
@@ -1,4 +1,4 @@
1
- import { pick, forEach, tail } from "../../shared/common";
1
+ import { pick, tail } from "../../shared/common";
2
2
  import { isDefined, isString } from "../../shared/utils";
3
3
  import { isInjectable } from "../../shared/predicates";
4
4
  import { services } from "../common/coreservices";
@@ -60,7 +60,7 @@ export function ng1ViewsBuilder(state) {
60
60
  }
61
61
  const views = {},
62
62
  viewsObject = state.views || { $default: pick(state, allViewKeys) };
63
- forEach(viewsObject, function (config, name) {
63
+ Object.entries(viewsObject).forEach(([name, config]) => {
64
64
  // Account for views: { "": { template... } }
65
65
  name = name || "$default";
66
66
  // Account for views: { header: "headerComponent" }
@@ -1,10 +1,4 @@
1
- import {
2
- forEach,
3
- isFunction,
4
- isDefined,
5
- isObject,
6
- isString,
7
- } from "../../shared/utils";
1
+ import { isFunction, isDefined, isObject, isString } from "../../shared/utils";
8
2
  import { is, pattern } from "../../shared/hof";
9
3
  import { UrlRules } from "./url-rules";
10
4
  import { TargetState } from "../state/target-state";
@@ -454,7 +448,7 @@ export class UrlService {
454
448
  // TODO: typeof?
455
449
  if (!isObject(object)) return false;
456
450
  let result = true;
457
- forEach(UrlMatcher.prototype, (val, name) => {
451
+ Object.entries(UrlMatcher.prototype).forEach(([name, val]) => {
458
452
  if (isFunction(val))
459
453
  result = result && isDefined(object[name]) && isFunction(object[name]);
460
454
  });
@@ -1,7 +1,6 @@
1
1
  import { dealoc } from "../../shared/jqlite/jqlite";
2
2
  import { Angular } from "../../loader";
3
3
  import { map, find } from "../../shared/common";
4
- import { forEach } from "../../shared/utils";
5
4
 
6
5
  describe("UrlMatcher", () => {
7
6
  let $url;
@@ -244,7 +243,7 @@ describe("UrlMatcher", () => {
244
243
  "/url/someword/child/childParam",
245
244
  };
246
245
 
247
- forEach(shouldPass, function (url, route) {
246
+ Object.entries(shouldPass).forEach(function ([route, url]) {
248
247
  expect($url.compile(route).exec(url, {})).toEqual({
249
248
  childParam: "childParam",
250
249
  matchedParam: "someword",
@@ -260,7 +259,7 @@ describe("UrlMatcher", () => {
260
259
  "/url/someword/child/childParam",
261
260
  };
262
261
 
263
- forEach(shouldThrow, function (url, route) {
262
+ Object.entries(shouldThrow).forEach(function ([route, url]) {
264
263
  expect(() => {
265
264
  $url.compile(route).exec(url, {});
266
265
  }).toThrowError("Unbalanced capture group in route '" + route + "'");
@@ -273,7 +272,7 @@ describe("UrlMatcher", () => {
273
272
  "/url/someword/child/childParam",
274
273
  };
275
274
 
276
- forEach(shouldPass, function (url, route) {
275
+ Object.entries(shouldPass).forEach(function ([route, url]) {
277
276
  expect(() => {
278
277
  $url.compile(route).exec(url, {});
279
278
  }).not.toThrow();
@@ -7,7 +7,6 @@ import {
7
7
  toJson,
8
8
  isUndefined,
9
9
  isFunction,
10
- forEach,
11
10
  encodeUriQuery,
12
11
  isString,
13
12
  fromJson,
@@ -147,7 +146,7 @@ function parseHeaders(headers) {
147
146
  },
148
147
  );
149
148
  } else if (isObject(headers)) {
150
- forEach(headers, (headerVal, headerKey) => {
149
+ Object.entries(headers).forEach(([headerKey, headerVal]) => {
151
150
  fillInParsed(lowercase(headerKey), trim(headerVal));
152
151
  });
153
152
  }
@@ -472,7 +471,7 @@ export function HttpProvider() {
472
471
  let promise = $q.resolve(config);
473
472
 
474
473
  // apply interceptors
475
- forEach(reversedInterceptors, (interceptor) => {
474
+ reversedInterceptors.forEach((interceptor) => {
476
475
  if (interceptor.request || interceptor.requestError) {
477
476
  requestInterceptors.unshift(
478
477
  interceptor.request,
@@ -515,7 +514,7 @@ export function HttpProvider() {
515
514
  let headerContent;
516
515
  const processedHeaders = {};
517
516
 
518
- forEach(headers, (headerFn, header) => {
517
+ Object.entries(headers).forEach(([header, headerFn]) => {
519
518
  if (isFunction(headerFn)) {
520
519
  headerContent = headerFn(config);
521
520
  if (headerContent != null) {
@@ -560,7 +559,7 @@ export function HttpProvider() {
560
559
 
561
560
  // strip content-type if data is undefined
562
561
  if (isUndefined(reqData)) {
563
- forEach(headers, (value, header) => {
562
+ Object.keys(headers).forEach((header) => {
564
563
  if (lowercase(header) === "content-type") {
565
564
  delete headers[header];
566
565
  }
@@ -821,7 +820,7 @@ export function HttpProvider() {
821
820
  function createApplyHandlers(eventHandlers) {
822
821
  if (eventHandlers) {
823
822
  const applyHandlers = {};
824
- forEach(eventHandlers, (eventHandler, key) => {
823
+ Object.entries(eventHandlers).forEach(([key, eventHandler]) => {
825
824
  applyHandlers[key] = function (event) {
826
825
  if (useApplyAsync) {
827
826
  $rootScope.$applyAsync(callEventHandler);
@@ -1,10 +1,5 @@
1
1
  import { urlResolve } from "../../core/url-utils/url-utils";
2
- import {
3
- forEach,
4
- isDefined,
5
- isPromiseLike,
6
- isUndefined,
7
- } from "../../shared/utils";
2
+ import { isDefined, isPromiseLike, isUndefined } from "../../shared/utils";
8
3
 
9
4
  /**
10
5
  * HTTP backend used by the {@link ng.$http service} that delegates to
@@ -51,11 +46,13 @@ export function createHttpBackend($browser) {
51
46
  let abortedByTimeout = false;
52
47
 
53
48
  xhr.open(method, url, true);
54
- forEach(headers, (value, key) => {
55
- if (isDefined(value)) {
56
- xhr.setRequestHeader(key, value);
57
- }
58
- });
49
+ if (headers) {
50
+ Object.entries(headers).forEach(([key, value]) => {
51
+ if (isDefined(value)) {
52
+ xhr.setRequestHeader(key, value);
53
+ }
54
+ });
55
+ }
59
56
 
60
57
  xhr.onload = function () {
61
58
  const statusText = xhr.statusText || "";
@@ -105,13 +102,18 @@ export function createHttpBackend($browser) {
105
102
  );
106
103
  };
107
104
 
108
- forEach(eventHandlers, (value, key) => {
109
- xhr.addEventListener(key, value);
110
- });
105
+ if (eventHandlers) {
106
+ eventHandlers &&
107
+ Object.entries(eventHandlers).forEach(([key, value]) => {
108
+ xhr.addEventListener(key, value);
109
+ });
110
+ }
111
111
 
112
- forEach(uploadEventHandlers, (value, key) => {
113
- xhr.upload.addEventListener(key, value);
114
- });
112
+ if (uploadEventHandlers) {
113
+ Object.entries(uploadEventHandlers).forEach(([key, value]) => {
114
+ xhr.upload.addEventListener(key, value);
115
+ });
116
+ }
115
117
 
116
118
  if (withCredentials) {
117
119
  xhr.withCredentials = true;
@@ -2,11 +2,6 @@ import { isDate, isFunction, isRegExp, isString } from "./utils";
2
2
  import { all, curry } from "./hof";
3
3
  import { services } from "../router/common/coreservices";
4
4
 
5
- export function forEach(obj, cb, thisArg) {
6
- if (Array.isArray(obj)) return obj.forEach(cb, thisArg);
7
- Object.keys(obj).forEach((key) => cb(obj[key], key));
8
- }
9
-
10
5
  export function equals(o1, o2) {
11
6
  if (o1 === o2) return true;
12
7
  if (o1 === null || o2 === null) return false;
@@ -219,7 +214,7 @@ export function filter(collection, callback) {
219
214
  const arr = Array.isArray(collection),
220
215
  result = arr ? [] : {};
221
216
  const accept = arr ? (x) => result.push(x) : (x, key) => (result[key] = x);
222
- forEach(collection, function (item, i) {
217
+ Object.entries(collection).forEach(([i, item]) => {
223
218
  if (callback(item, i)) accept(item, i);
224
219
  });
225
220
  return result;
@@ -228,7 +223,7 @@ export function filter(collection, callback) {
228
223
  /** Finds an object from an array, or a property of an object, that matches a predicate */
229
224
  export function find(collection, callback) {
230
225
  let result;
231
- forEach(collection, function (item, i) {
226
+ Object.entries(collection).forEach(([i, item]) => {
232
227
  if (result) return;
233
228
  if (callback(item, i)) result = item;
234
229
  });
@@ -238,7 +233,9 @@ export function find(collection, callback) {
238
233
  /** Maps an array or object properties using a callback function */
239
234
  export function map(collection, callback, target) {
240
235
  target = target || (Array.isArray(collection) ? [] : {});
241
- forEach(collection, (item, i) => (target[i] = callback(item, i)));
236
+ Object.entries(collection).forEach(
237
+ ([i, item]) => (target[i] = callback(item, i)),
238
+ );
242
239
  return target;
243
240
  }
244
241
 
@@ -3,7 +3,6 @@ import {
3
3
  arrayRemove,
4
4
  concat,
5
5
  extend,
6
- forEach,
7
6
  isDefined,
8
7
  isFunction,
9
8
  isObject,
@@ -103,9 +102,9 @@ export function JQLite(element) {
103
102
  JQLite.prototype = {
104
103
  toString() {
105
104
  const value = [];
106
- forEach(this, (e) => {
107
- value.push(`${e}`);
108
- });
105
+ for (var i = 0; i < this.length; i++) {
106
+ value.push(`${this[i]}`);
107
+ }
109
108
  return `[${value.join(", ")}]`;
110
109
  },
111
110
 
@@ -276,7 +275,7 @@ JQLite.prototype.off = function (type, fn) {
276
275
  }
277
276
  };
278
277
 
279
- forEach(type.split(" "), (type) => {
278
+ type.split(" ").forEach((type) => {
280
279
  removeHandler(type);
281
280
  if (MOUSE_EVENT_MAP[type]) {
282
281
  removeHandler(MOUSE_EVENT_MAP[type]);
@@ -379,7 +378,7 @@ JQLite.prototype.val = function (value) {
379
378
  // read
380
379
  if (element.multiple && getNodeName(element) === "select") {
381
380
  const result = [];
382
- forEach(element.options, (option) => {
381
+ Array.from(element.options).forEach((option) => {
383
382
  if (option.selected) {
384
383
  result.push(option.value || option.text);
385
384
  }
@@ -482,14 +481,16 @@ JQLite.prototype.replaceWith = function (arg1) {
482
481
  let index;
483
482
  const parent = element.parentNode;
484
483
  dealoc(element);
485
- forEach(new JQLite(replaceNode), (node) => {
484
+ const nodes = new JQLite(replaceNode);
485
+ for (let i = 0; i < nodes.length; i++) {
486
+ const node = nodes[i];
486
487
  if (index) {
487
488
  parent.insertBefore(node, index.nextSibling);
488
489
  } else {
489
490
  parent.replaceChild(node, element);
490
491
  }
491
492
  index = node;
492
- });
493
+ }
493
494
  };
494
495
  for (let i = 0; i < this.length; i++) {
495
496
  addNodes(value, fn(this[i], arg1));
@@ -542,9 +543,10 @@ JQLite.prototype.prepend = function (node) {
542
543
  const element = this[i];
543
544
  if (element.nodeType === Node.ELEMENT_NODE) {
544
545
  const index = element.firstChild;
545
- forEach(new JQLite(node), (child) => {
546
- element.insertBefore(child, index);
547
- });
546
+ const el = new JQLite(node);
547
+ for (let i = 0; i < el.length; i++) {
548
+ element.insertBefore(el[i], index);
549
+ }
548
550
  }
549
551
  }
550
552
  return this;
@@ -683,7 +685,7 @@ JQLite.prototype.triggerHandler = function (event, extraParameters) {
683
685
  ? [dummyEvent].concat(extraParameters)
684
686
  : [dummyEvent];
685
687
 
686
- forEach(eventFnsCopy, (fn) => {
688
+ eventFnsCopy.forEach((fn) => {
687
689
  if (!dummyEvent.isImmediatePropagationStopped()) {
688
690
  fn.apply(element, handlerArgs);
689
691
  }
@@ -8,7 +8,7 @@ import {
8
8
  } from "./jqlite";
9
9
  import { Angular } from "../../loader";
10
10
  import { createInjector } from "../../core/di/injector";
11
- import { equals, forEach } from "../utils";
11
+ import { equals } from "../utils";
12
12
  import { browserTrigger } from "../test-utils";
13
13
  import { CACHE, EXPANDO } from "../../core/cache/cache";
14
14
 
@@ -902,7 +902,7 @@ describe("jqLite", () => {
902
902
  });
903
903
 
904
904
  it("should not fail on elements without the getAttribute method", () => {
905
- forEach([window, document], (node) => {
905
+ [window, document].forEach((node) => {
906
906
  expect(() => {
907
907
  const elem = JQLite(node);
908
908
  elem.attr("foo");