@angular-wave/angular.ts 0.2.2 → 0.2.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 (50) 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 +1 -1
  5. package/src/animations/animate.spec.js +1 -1
  6. package/src/core/compile/attributes.js +1 -1
  7. package/src/core/compile/compile.js +10 -6
  8. package/src/core/compile/compile.spec.js +0 -6
  9. package/src/core/di/internal-injector.js +14 -14
  10. package/src/core/di/ng-module.js +2 -2
  11. package/src/core/filter/filter.md +1 -1
  12. package/src/core/location/location.spec.js +9 -9
  13. package/src/core/sanitize/sanitize-uri.spec.js +1 -1
  14. package/src/core/sce/sce.spec.js +3 -3
  15. package/src/core/scope/scope.spec.js +1 -1
  16. package/src/core/url-utils/url-utils.js +4 -4
  17. package/src/core/url-utils/url-utils.spec.js +1 -1
  18. package/src/directive/attrs/boolean.spec.js +1 -1
  19. package/src/directive/class/class.js +10 -90
  20. package/src/directive/class/class.md +90 -0
  21. package/src/directive/class/class.spec.js +1 -1
  22. package/src/directive/controller/controller.spec.js +0 -12
  23. package/src/directive/form/form.spec.js +3 -3
  24. package/src/directive/include/include.spec.js +1 -1
  25. package/src/directive/input/input.js +1 -1
  26. package/src/directive/model/model.js +50 -42
  27. package/src/directive/options/options.js +2 -2
  28. package/src/directive/repeat/repeat.spec.js +4 -4
  29. package/src/directive/select/select.js +1 -1
  30. package/src/directive/show-hide/show-hide.spec.js +1 -1
  31. package/src/directive/style/style.spec.js +1 -1
  32. package/src/directive/switch/switch.spec.js +1 -1
  33. package/src/directive/validators/validators.js +2 -2
  34. package/src/filters/filter.js +2 -3
  35. package/src/filters/limit-to.js +2 -2
  36. package/src/services/cookie-reader.js +1 -1
  37. package/src/services/http/http.js +24 -19
  38. package/src/shared/common.spec.js +1 -3
  39. package/src/shared/hof.js +1 -2
  40. package/src/shared/jqlite/jqlite.js +26 -28
  41. package/src/shared/jqlite/jqlite.spec.js +10 -10
  42. package/src/shared/utils.js +6 -11
  43. package/types/core/di/internal-injector.d.ts +6 -6
  44. package/types/core/di/ng-module.d.ts +2 -2
  45. package/types/directive/class/class.d.ts +3 -100
  46. package/types/directive/model/model.d.ts +6 -3
  47. package/types/directive/validators/validators.d.ts +2 -2
  48. package/types/shared/hof.d.ts +0 -1
  49. package/types/shared/jqlite/jqlite.d.ts +4 -4
  50. package/types/shared/utils.d.ts +5 -5
@@ -689,7 +689,7 @@ describe("ngInclude", () => {
689
689
  // // // we need to run animation on attached elements;
690
690
  // // function (_$rootElement_) {
691
691
  // // $rootElement = _$rootElement_;
692
- // // body = JQLite(window.document.body);
692
+ // // body = JQLite(document.body);
693
693
  // // body.append($rootElement);
694
694
  // // },
695
695
  // // ),
@@ -113,7 +113,7 @@ function textInputType(scope, element, attr, ctrl, $browser) {
113
113
  }
114
114
 
115
115
  function baseInputType(scope, element, attr, ctrl, $browser) {
116
- const type = lowercase(element[0].type);
116
+ const type = element[0].type.toLowerCase();
117
117
  let composing = false;
118
118
  // In composition mode, users are still inputting intermediate text buffer,
119
119
  // hold the listener until composition is done.
@@ -146,17 +146,23 @@ export class NgModelController {
146
146
 
147
147
  this.$$parsedNgModel = $parse($attr["ngModel"]);
148
148
  this.$$parsedNgModelAssign = this.$$parsedNgModel.assign;
149
+
149
150
  /** @type {import("../../core/parser/parse").CompiledExpression|((Scope) => any)} */
150
151
  this.$$ngModelGet = this.$$parsedNgModel;
151
152
  this.$$ngModelSet = this.$$parsedNgModelAssign;
152
153
  this.$$pendingDebounce = null;
153
154
  this.$$parserValid = undefined;
155
+
156
+ /** @type {string} */
154
157
  this.$$parserName = "parse";
155
158
 
156
159
  /** @type {number} */
157
160
  this.$$currentValidationRunId = 0;
158
161
 
162
+ /** @type {import('../../core/scope/scope.js').Scope} */
159
163
  this.$$scope = $scope;
164
+
165
+ /** @type {import('../../core/scope/scope.js').Scope} */
160
166
  this.$$rootScope = $scope.$root;
161
167
  this.$$attr = $attr;
162
168
  this.$$element = $element;
@@ -1095,54 +1101,56 @@ export function ngModelDirective($rootScope) {
1095
1101
  // so that we can set the NgModelOptions in NgModelController
1096
1102
  // before anyone else uses it.
1097
1103
  priority: 1,
1098
- compile: function ngModelCompile(element) {
1099
- // Setup initial state of the control
1100
- element[0].classList.add(PRISTINE_CLASS, UNTOUCHED_CLASS, VALID_CLASS);
1101
-
1102
- return {
1103
- pre: function (scope, _element, attr, ctrls) {
1104
- const modelCtrl = ctrls[0];
1105
- const formCtrl = ctrls[1] || modelCtrl.$$parentForm;
1106
- const optionsCtrl = ctrls[2];
1107
-
1108
- if (optionsCtrl) {
1109
- modelCtrl.$options = optionsCtrl.$options;
1110
- }
1104
+ compile:
1105
+ /** @param {import("../../shared/jqlite/jqlite.js").JQLite} element */
1106
+ (element) => {
1107
+ // Setup initial state of the control
1108
+ element[0].classList.add(PRISTINE_CLASS, UNTOUCHED_CLASS, VALID_CLASS);
1109
+
1110
+ return {
1111
+ pre: (scope, _element, attr, ctrls) => {
1112
+ const modelCtrl = ctrls[0];
1113
+ const formCtrl = ctrls[1] || modelCtrl.$$parentForm;
1114
+ const optionsCtrl = ctrls[2];
1115
+
1116
+ if (optionsCtrl) {
1117
+ modelCtrl.$options = optionsCtrl.$options;
1118
+ }
1111
1119
 
1112
- modelCtrl.$$initGetterSetters();
1120
+ modelCtrl.$$initGetterSetters();
1113
1121
 
1114
- // notify others, especially parent forms
1115
- formCtrl.$addControl(modelCtrl);
1122
+ // notify others, especially parent forms
1123
+ formCtrl.$addControl(modelCtrl);
1116
1124
 
1117
- attr.$observe("name", (newValue) => {
1118
- if (modelCtrl.$name !== newValue) {
1119
- modelCtrl.$$parentForm.$$renameControl(modelCtrl, newValue);
1120
- }
1121
- });
1125
+ attr.$observe("name", (newValue) => {
1126
+ if (modelCtrl.$name !== newValue) {
1127
+ modelCtrl.$$parentForm.$$renameControl(modelCtrl, newValue);
1128
+ }
1129
+ });
1122
1130
 
1123
- scope.$on("$destroy", () => {
1124
- modelCtrl.$$parentForm.$removeControl(modelCtrl);
1125
- });
1126
- },
1127
- post: function (scope, element, _attr, ctrls) {
1128
- const modelCtrl = ctrls[0];
1129
- modelCtrl.$$setUpdateOnEvents();
1131
+ scope.$on("$destroy", () => {
1132
+ modelCtrl.$$parentForm.$removeControl(modelCtrl);
1133
+ });
1134
+ },
1135
+ post: (scope, element, _attr, ctrls) => {
1136
+ const modelCtrl = ctrls[0];
1137
+ modelCtrl.$$setUpdateOnEvents();
1130
1138
 
1131
- function setTouched() {
1132
- modelCtrl.$setTouched();
1133
- }
1139
+ function setTouched() {
1140
+ modelCtrl.$setTouched();
1141
+ }
1134
1142
 
1135
- element.on("blur", () => {
1136
- if (modelCtrl.$touched) return;
1143
+ element.on("blur", () => {
1144
+ if (modelCtrl.$touched) return;
1137
1145
 
1138
- if ($rootScope.$$phase !== ScopePhase.NONE) {
1139
- scope.$evalAsync(setTouched);
1140
- } else {
1141
- scope.$apply(setTouched);
1142
- }
1143
- });
1144
- },
1145
- };
1146
- },
1146
+ if ($rootScope.$$phase !== ScopePhase.NONE) {
1147
+ scope.$evalAsync(setTouched);
1148
+ } else {
1149
+ scope.$apply(setTouched);
1150
+ }
1151
+ });
1152
+ },
1153
+ };
1154
+ },
1147
1155
  };
1148
1156
  }
@@ -209,8 +209,8 @@ export const ngOptionsDirective = [
209
209
  // Support: IE 9 only
210
210
  // We can't just JQLite('<option>') since JQLite is not smart enough
211
211
  // to create it in <select> and IE barfs otherwise.
212
- const optionTemplate = window.document.createElement("option");
213
- const optGroupTemplate = window.document.createElement("optgroup");
212
+ const optionTemplate = document.createElement("option");
213
+ const optGroupTemplate = document.createElement("optgroup");
214
214
 
215
215
  function ngOptionsPostLink(scope, selectElement, attr, ctrls) {
216
216
  const selectCtrl = ctrls[0];
@@ -119,7 +119,7 @@ describe("ngRepeat", () => {
119
119
  "<a class='test' name='y'>b</a>" +
120
120
  "<a class='test' name='x'>c</a>";
121
121
 
122
- const htmlCollection = window.document.getElementsByClassName("test");
122
+ const htmlCollection = document.getElementsByClassName("test");
123
123
  scope.items = htmlCollection;
124
124
  scope.$digest();
125
125
  expect(element.find("li").length).toEqual(3);
@@ -382,7 +382,7 @@ describe("ngRepeat", () => {
382
382
  "</li>" +
383
383
  "</ul>",
384
384
  )(scope);
385
- window.document.getElementById("dummy").appendChild(element[0]);
385
+ document.getElementById("dummy").appendChild(element[0]);
386
386
  scope.items = { misko: true, shyam: true, zhenbo: true };
387
387
  scope.$digest();
388
388
  expect(element.find("li").length).toEqual(3);
@@ -413,7 +413,7 @@ describe("ngRepeat", () => {
413
413
  expect(element.find("input")[1].checked).toBe(true);
414
414
  expect(element.find("input")[2].checked).toBe(true);
415
415
 
416
- window.document.getElementById("dummy").innerHTML = "";
416
+ document.getElementById("dummy").innerHTML = "";
417
417
  });
418
418
 
419
419
  it("should invoke track by with correct locals", () => {
@@ -1466,7 +1466,7 @@ describe("ngRepeat", () => {
1466
1466
  // // we need to run animation on attached elements;
1467
1467
  // function (_$rootElement_) {
1468
1468
  // $rootElement = _$rootElement_;
1469
- // body = JQLite(window.document.body);
1469
+ // body = JQLite(document.body);
1470
1470
  // body.append($rootElement);
1471
1471
  // },
1472
1472
  // ),
@@ -49,7 +49,7 @@ function SelectController($element, $scope) {
49
49
  // Support: IE 9 only
50
50
  // We can't just JQLite('<option>') since JQLite is not smart enough
51
51
  // to create it in <select> and IE barfs otherwise.
52
- self.unknownOption = JQLite(window.document.createElement("option"));
52
+ self.unknownOption = JQLite(document.createElement("option"));
53
53
 
54
54
  // The empty option is an option with the value '' that the application developer can
55
55
  // provide inside the select. It is always selectable and indicates that a "null" selection has
@@ -130,7 +130,7 @@ describe("ngShow / ngHide", () => {
130
130
 
131
131
  // beforeEach(() => {
132
132
  // // we need to run animation on attached elements;
133
- // body = JQLite(window.document.body);
133
+ // body = JQLite(document.body);
134
134
  // });
135
135
 
136
136
  // afterEach(() => {
@@ -86,7 +86,7 @@ describe("ng-style", () => {
86
86
  postCompVal = "100px";
87
87
  element = JQLite('<div ng-style="styleObj"></div>');
88
88
  element[0].style[preCompStyle] = preCompVal;
89
- JQLite(window.document.body).append(element);
89
+ JQLite(document.body).append(element);
90
90
  $compile(element)($scope);
91
91
  scope = $scope;
92
92
  scope.styleObj = { "margin-top": "44px" };
@@ -499,7 +499,7 @@ describe("ngSwitch", () => {
499
499
  // // we need to run animation on attached elements;
500
500
  // function (_$rootElement_) {
501
501
  // $rootElement = _$rootElement_;
502
- // body = JQLite(window.document.body);
502
+ // body = JQLite(document.body);
503
503
  // body.append($rootElement);
504
504
  // },
505
505
  // ),
@@ -10,7 +10,7 @@ import { startingTag } from "../../shared/jqlite/jqlite";
10
10
 
11
11
  /**
12
12
  *
13
- * @param {String} ngRequired AngularJS expression. If it evaluates to `true`, it sets the
13
+ * @param {string} ngRequired AngularJS expression. If it evaluates to `true`, it sets the
14
14
  * `required` attribute to the element and adds the `required`
15
15
  * {@link ngModel.NgModelController#$validators `validator`}.
16
16
  *
@@ -170,7 +170,7 @@ export const patternDirective = [
170
170
  ];
171
171
 
172
172
  /**
173
- * @param {String} ngMaxlength AngularJS expression that must evaluate to a `Number` or `String`
173
+ * @param {string} ngMaxlength AngularJS expression that must evaluate to a `Number` or `String`
174
174
  * parsable into a `Number`. Used as value for the `maxlength`
175
175
  * {@link ngModel.NgModelController#$validators validator}.
176
176
  *
@@ -4,7 +4,6 @@ import {
4
4
  isFunction,
5
5
  isUndefined,
6
6
  isObject,
7
- lowercase,
8
7
  hasCustomToString,
9
8
  equals,
10
9
  } from "../shared/utils";
@@ -95,8 +94,8 @@ function createPredicateFn(
95
94
  return false;
96
95
  }
97
96
 
98
- actual = lowercase(`${actual}`);
99
- expected = lowercase(`${expected}`);
97
+ actual = `${actual}`.toLowerCase();
98
+ expected = `${expected}`.toLowerCase();
100
99
  return actual.indexOf(expected) !== -1;
101
100
  };
102
101
  }
@@ -19,7 +19,7 @@ export function limitToFilter() {
19
19
  if (Math.abs(Number(limit)) === Infinity) {
20
20
  limit = Number(limit);
21
21
  } else {
22
- limit = toInt(/** @type {String} */ (limit));
22
+ limit = toInt(/** @type {string} */ (limit));
23
23
  }
24
24
  if (isNumberNaN(limit)) return input;
25
25
 
@@ -29,7 +29,7 @@ export function limitToFilter() {
29
29
  begin =
30
30
  !begin || isNaN(/** @type {any} */ (begin))
31
31
  ? 0
32
- : toInt(/** @type {String} */ (begin));
32
+ : toInt(/** @type {string} */ (begin));
33
33
  begin =
34
34
  begin < 0 ? Math.max(0, /** @type {[]} */ (input).length + begin) : begin;
35
35
 
@@ -12,7 +12,7 @@ export function getCookies() {
12
12
  let i;
13
13
  let index;
14
14
  let name;
15
- const currentCookieString = window.document.cookie;
15
+ const currentCookieString = document.cookie;
16
16
 
17
17
  if (currentCookieString !== lastCookieString) {
18
18
  lastCookieString = currentCookieString;
@@ -5,7 +5,6 @@ import {
5
5
  isObject,
6
6
  isDate,
7
7
  toJson,
8
- forEachSorted,
9
8
  isUndefined,
10
9
  isFunction,
11
10
  forEach,
@@ -60,20 +59,23 @@ export function $HttpParamSerializerProvider() {
60
59
  return function ngParamSerializer(params) {
61
60
  if (!params) return "";
62
61
  const parts = [];
63
- forEachSorted(params, (value, key) => {
64
- if (value === null || isUndefined(value) || isFunction(value)) return;
65
- if (Array.isArray(value)) {
66
- value.forEach((v) => {
62
+ Object.keys(params)
63
+ .sort()
64
+ .forEach((key) => {
65
+ const value = params[key];
66
+ if (value === null || isUndefined(value) || isFunction(value)) return;
67
+ if (Array.isArray(value)) {
68
+ value.forEach((v) => {
69
+ parts.push(
70
+ `${encodeUriQuery(key)}=${encodeUriQuery(serializeValue(v))}`,
71
+ );
72
+ });
73
+ } else {
67
74
  parts.push(
68
- `${encodeUriQuery(key)}=${encodeUriQuery(serializeValue(v))}`,
75
+ `${encodeUriQuery(key)}=${encodeUriQuery(serializeValue(value))}`,
69
76
  );
70
- });
71
- } else {
72
- parts.push(
73
- `${encodeUriQuery(key)}=${encodeUriQuery(serializeValue(value))}`,
74
- );
75
- }
76
- });
77
+ }
78
+ });
77
79
 
78
80
  return parts.join("&");
79
81
  };
@@ -134,12 +136,15 @@ export function $HttpParamSerializerJQLikeProvider() {
134
136
  serialize(value, `${prefix}[${isObject(value) ? index : ""}]`);
135
137
  });
136
138
  } else if (isObject(toSerialize) && !isDate(toSerialize)) {
137
- forEachSorted(toSerialize, (value, key) => {
138
- serialize(
139
- value,
140
- prefix + (topLevel ? "" : "[") + key + (topLevel ? "" : "]"),
141
- );
142
- });
139
+ Object.keys(toSerialize)
140
+ .sort()
141
+ .forEach((key) => {
142
+ const value = toSerialize[key];
143
+ serialize(
144
+ value,
145
+ prefix + (topLevel ? "" : "[") + key + (topLevel ? "" : "]"),
146
+ );
147
+ });
143
148
  } else {
144
149
  if (isFunction(toSerialize)) {
145
150
  toSerialize = toSerialize();
@@ -1,5 +1,5 @@
1
1
  import { defaults, filter, map, pick } from "./common";
2
- import { is, eq, pattern, val } from "./hof";
2
+ import { is, pattern, val } from "./hof";
3
3
  import { isInjectable } from "./predicates";
4
4
  import { Queue } from "../router/common/queue";
5
5
 
@@ -76,14 +76,12 @@ describe("common", function () {
76
76
  [is(Number), val("number!")],
77
77
  [is(String), val("string!")],
78
78
  [is(Boolean), val("boolean!")],
79
- [eq(null), val("null!")],
80
79
  ]);
81
80
 
82
81
  expect(typeChecker(1)).toBe("number!");
83
82
  expect(typeChecker("foo!")).toBe("string!");
84
83
  expect(typeChecker(true)).toBe("boolean!");
85
84
  expect(typeChecker(false)).toBe("boolean!");
86
- expect(typeChecker(null)).toBe("null!");
87
85
  expect(typeChecker(undefined)).toBe(undefined);
88
86
  });
89
87
  });
package/src/shared/hof.js CHANGED
@@ -115,8 +115,7 @@ export const all = (fn1) => (arr) => arr.reduce((b, x) => b && !!fn1(x), true);
115
115
  /** Given a class, returns a Predicate function that returns true if the object is of that class */
116
116
  export const is = (ctor) => (obj) =>
117
117
  (obj != null && obj.constructor === ctor) || obj instanceof ctor;
118
- /** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
119
- export const eq = (value) => (other) => value === other;
118
+
120
119
  /** Given a value, returns a function which returns the value */
121
120
  export const val = (v) => () => v;
122
121
  /**
@@ -59,8 +59,8 @@ const BOOLEAN_ELEMENTS = {};
59
59
  });
60
60
 
61
61
  /**
62
- * JQLite both a function and an array-like data structure for manipulation of DOM, linking elements to expando cache,
63
- * and execution of chain functions.
62
+ * JQLite is both a function and an array-like data structure for manipulation of DOM, linking elements to expando cache,
63
+ * and execution of chains of functions.
64
64
  *
65
65
  * @param {string|Node|Node[]|NodeList|JQLite|ArrayLike<Element>|(() => void)|Window} element
66
66
  * @returns {JQLite}
@@ -841,7 +841,7 @@ export function buildFragment(html) {
841
841
  // Create wrappers & descend into them
842
842
  i = wrap.length;
843
843
  while (--i > -1) {
844
- tmp.appendChild(window.document.createElement(wrap[i]));
844
+ tmp.appendChild(document.createElement(wrap[i]));
845
845
  tmp = /** @type {HTMLDivElement} */ (tmp.firstChild);
846
846
  }
847
847
  tmp.innerHTML = html;
@@ -953,29 +953,28 @@ export function getOrSetCacheData(element, key, value) {
953
953
  * @param {(Node|Array|NodeList|Object)} elements - The elements to add to the root. This can be a single DOM node, an array-like object (such as an Array or NodeList), or any other object.
954
954
  */
955
955
  function addNodes(root, elements) {
956
- // THIS CODE IS VERY HOT. Don't make changes without benchmarking.
957
-
958
- if (elements) {
959
- // if a Node (the most common case)
960
- if (elements.nodeType) {
961
- root[root.length++] = elements;
962
- } else {
963
- const { length } = elements;
964
-
965
- // if an Array or NodeList and not a Window
966
- if (typeof length === "number" && elements.window !== elements) {
967
- if (length) {
968
- for (let i = 0; i < length; i++) {
969
- root[root.length++] = elements[i];
970
- }
971
- }
972
- } else {
973
- root[root.length++] = elements;
974
- }
956
+ if (!elements) return;
957
+ // If a Node (the most common case)
958
+ if (elements.nodeType) {
959
+ root[root.length++] = elements;
960
+ return;
961
+ }
962
+ const length = elements.length;
963
+ // If elements is an Array or NodeList, but not a Window object
964
+ if (typeof length === "number" && elements.window !== elements) {
965
+ for (let i = 0; i < length; i++) {
966
+ root[root.length++] = elements[i];
975
967
  }
968
+ } else {
969
+ root[root.length++] = elements;
976
970
  }
977
971
  }
978
972
 
973
+ /**
974
+ * @param {Node} element
975
+ * @param {string} name
976
+ * @returns
977
+ */
979
978
  function getController(element, name) {
980
979
  return getInheritedData(element, `$${name || "ngController"}Controller`);
981
980
  }
@@ -991,7 +990,6 @@ function getInheritedData(element, name, value) {
991
990
  // if element is the document object work with the html element instead
992
991
  // this makes $(document).scope() possible
993
992
  if (element.nodeType === Node.DOCUMENT_NODE) {
994
- // TODO Fix types
995
993
  element = /** @type {Document} */ (element).documentElement;
996
994
  }
997
995
  const names = Array.isArray(name) ? name : [name];
@@ -1031,20 +1029,20 @@ export function removeElement(element, keepData = false) {
1031
1029
  }
1032
1030
 
1033
1031
  /**
1034
- * Executea a function on `DOMContentLoaded`
1032
+ * Execute a function on `DOMContentLoaded`
1035
1033
  * @param {Function} fn
1036
1034
  */
1037
1035
  function onReady(fn) {
1038
1036
  function trigger() {
1039
- window.document.removeEventListener("DOMContentLoaded", trigger);
1037
+ document.removeEventListener("DOMContentLoaded", trigger);
1040
1038
  fn();
1041
1039
  }
1042
1040
  // check if document is already loaded
1043
- if (window.document.readyState === "complete") {
1044
- window.setTimeout(fn);
1041
+ if (document.readyState === "complete") {
1042
+ setTimeout(fn);
1045
1043
  } else {
1046
1044
  // We can not use JQLite since we are not done loading.
1047
- window.document.addEventListener("DOMContentLoaded", trigger);
1045
+ document.addEventListener("DOMContentLoaded", trigger);
1048
1046
  }
1049
1047
  }
1050
1048
 
@@ -122,7 +122,7 @@ describe("jqLite", () => {
122
122
  });
123
123
 
124
124
  it("should wrap document fragment", () => {
125
- const fragment = JQLite(window.document.createDocumentFragment());
125
+ const fragment = JQLite(document.createDocumentFragment());
126
126
  expect(fragment.length).toBe(1);
127
127
  expect(fragment[0].nodeType).toBe(11);
128
128
  });
@@ -194,7 +194,7 @@ describe("jqLite", () => {
194
194
  done();
195
195
  }
196
196
  }
197
- JQLite(window.document.body).append(container);
197
+ JQLite(document.body).append(container);
198
198
  window.xss = jasmine.createSpy("xss");
199
199
 
200
200
  // Thanks to Masato Kinugawa from Cure53 for providing the following test cases.
@@ -280,7 +280,7 @@ describe("jqLite", () => {
280
280
 
281
281
  it("should pass through DocumentFragment boundaries via host", () => {
282
282
  const host = JQLite("<div></div>");
283
- const frag = window.document.createDocumentFragment();
283
+ const frag = document.createDocumentFragment();
284
284
  const $frag = JQLite(frag);
285
285
  frag.host = host[0];
286
286
  host.data("foo", 123);
@@ -848,7 +848,7 @@ describe("jqLite", () => {
848
848
  });
849
849
 
850
850
  it("should do nothing when setting or getting on attribute nodes", () => {
851
- const attrNode = JQLite(window.document.createAttribute("myattr"));
851
+ const attrNode = JQLite(document.createAttribute("myattr"));
852
852
  expect(attrNode).toBeDefined();
853
853
  expect(attrNode[0].nodeType).toEqual(2);
854
854
  expect(attrNode.attr("some-attribute", "somevalue")).toEqual(attrNode);
@@ -856,7 +856,7 @@ describe("jqLite", () => {
856
856
  });
857
857
 
858
858
  it("should do nothing when setting or getting on text nodes", () => {
859
- const textNode = JQLite(window.document.createTextNode("some text"));
859
+ const textNode = JQLite(document.createTextNode("some text"));
860
860
  expect(textNode).toBeDefined();
861
861
  expect(textNode[0].nodeType).toEqual(3);
862
862
  expect(textNode.attr("some-attribute", "somevalue")).toEqual(textNode);
@@ -864,7 +864,7 @@ describe("jqLite", () => {
864
864
  });
865
865
 
866
866
  it("should do nothing when setting or getting on comment nodes", () => {
867
- const comment = JQLite(window.document.createComment("some comment"));
867
+ const comment = JQLite(document.createComment("some comment"));
868
868
  expect(comment).toBeDefined();
869
869
  expect(comment[0].nodeType).toEqual(8);
870
870
  expect(comment.attr("some-attribute", "somevalue")).toEqual(comment);
@@ -931,7 +931,7 @@ describe("jqLite", () => {
931
931
 
932
932
  it("should return text only for element or text nodes", () => {
933
933
  expect(JQLite("<div>foo</div>").text()).toBe("foo");
934
- expect(JQLite(window.document.createComment("foo")).text()).toBe("");
934
+ expect(JQLite(document.createComment("foo")).text()).toBe("");
935
935
  });
936
936
  });
937
937
 
@@ -1202,7 +1202,7 @@ describe("jqLite", () => {
1202
1202
  function browserMoveTrigger(from, to) {
1203
1203
  const fireEvent = function (type, element, relatedTarget) {
1204
1204
  let evnt;
1205
- evnt = window.document.createEvent("MouseEvents");
1205
+ evnt = document.createEvent("MouseEvents");
1206
1206
 
1207
1207
  const originalPreventDefault = evnt.preventDefault;
1208
1208
 
@@ -1700,7 +1700,7 @@ describe("jqLite", () => {
1700
1700
  expect(root.html()).toEqual("text");
1701
1701
  });
1702
1702
  it("should append to document fragment", () => {
1703
- const root = JQLite(window.document.createDocumentFragment());
1703
+ const root = JQLite(document.createDocumentFragment());
1704
1704
  expect(root.append("<p>foo</p>")).toBe(root);
1705
1705
  expect(root.children().length).toBe(1);
1706
1706
  });
@@ -1802,7 +1802,7 @@ describe("jqLite", () => {
1802
1802
 
1803
1803
  it("should return empty JQLite object when parent is a document fragment", () => {
1804
1804
  // this is quite unfortunate but jQuery 1.5.1 behaves this way
1805
- const fragment = window.document.createDocumentFragment();
1805
+ const fragment = document.createDocumentFragment();
1806
1806
  const child = JQLite("<p>foo</p>");
1807
1807
 
1808
1808
  fragment.appendChild(child[0]);
@@ -357,12 +357,6 @@ export function forEach(obj, iterator, context) {
357
357
  return obj;
358
358
  }
359
359
 
360
- export function forEachSorted(obj, iterator, context) {
361
- const keys = Object.keys(obj).sort();
362
- keys.forEach((el) => iterator.call(context, obj[el], el));
363
- return keys;
364
- }
365
-
366
360
  /**
367
361
  * when using forEach the params are value, key, but it is often useful to have key, value.
368
362
  * @param {function(string, *):any} iteratorFn
@@ -686,8 +680,8 @@ const cspCache = {};
686
680
  export function csp() {
687
681
  if (!isDefined(cspCache.rules)) {
688
682
  const ngCspElement =
689
- window.document.querySelector("[ng-csp]") ||
690
- window.document.querySelector("[data-ng-csp]");
683
+ document.querySelector("[ng-csp]") ||
684
+ document.querySelector("[data-ng-csp]");
691
685
 
692
686
  if (ngCspElement) {
693
687
  const ngCspAttribute =
@@ -721,8 +715,8 @@ export function csp() {
721
715
 
722
716
  /**
723
717
  * throw error if the name given is hasOwnProperty
724
- * @param {String} name the name to test
725
- * @param {String} context the context in which the name is used, such as module or directive
718
+ * @param {string} name the name to test
719
+ * @param {string} context the context in which the name is used, such as module or directive
726
720
  */
727
721
  export function assertNotHasOwnProperty(name, context) {
728
722
  if (name === "hasOwnProperty") {
@@ -1250,7 +1244,8 @@ export function mergeClasses(a, b) {
1250
1244
 
1251
1245
  /**
1252
1246
  * Converts all accepted directives format into proper directive name.
1253
- * @param name Name to normalize
1247
+ * @param {string} name Name to normalize
1248
+ * @returns {string}
1254
1249
  */
1255
1250
 
1256
1251
  export function directiveNormalize(name) {