@angular-wave/angular.ts 0.2.1 → 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 (60) 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/controller/controller.js +85 -131
  10. package/src/core/di/internal-injector.js +14 -14
  11. package/src/core/di/ng-module.js +2 -2
  12. package/src/core/filter/filter.md +1 -1
  13. package/src/core/location/location.spec.js +9 -9
  14. package/src/core/sanitize/sanitize-uri.spec.js +1 -1
  15. package/src/core/sce/sce.spec.js +3 -3
  16. package/src/core/scope/scope.spec.js +1 -1
  17. package/src/core/url-utils/url-utils.js +4 -4
  18. package/src/core/url-utils/url-utils.spec.js +1 -1
  19. package/src/directive/attrs/boolean.spec.js +1 -1
  20. package/src/directive/class/class.js +10 -90
  21. package/src/directive/class/class.md +90 -0
  22. package/src/directive/class/class.spec.js +1 -1
  23. package/src/directive/controller/controller.spec.js +0 -12
  24. package/src/directive/form/form.spec.js +3 -3
  25. package/src/directive/include/include.spec.js +1 -1
  26. package/src/directive/input/input.js +1 -1
  27. package/src/directive/model/model.js +50 -42
  28. package/src/directive/options/options.js +2 -2
  29. package/src/directive/repeat/repeat.spec.js +4 -4
  30. package/src/directive/select/select.js +1 -1
  31. package/src/directive/show-hide/show-hide.spec.js +1 -1
  32. package/src/directive/style/style.spec.js +1 -1
  33. package/src/directive/switch/switch.spec.js +1 -1
  34. package/src/directive/validators/validators.js +2 -2
  35. package/src/filters/filter.js +2 -3
  36. package/src/filters/limit-to.js +2 -2
  37. package/src/router/resolve/resolvable.js +4 -0
  38. package/src/router/resolve/resolve-context.js +12 -6
  39. package/src/router/state/state-builder.js +31 -23
  40. package/src/router/transition/hook-registry.js +2 -2
  41. package/src/router/transition/transition-hook.js +3 -3
  42. package/src/services/cookie-reader.js +1 -1
  43. package/src/services/http/http.js +24 -19
  44. package/src/shared/common.js +2 -2
  45. package/src/shared/common.spec.js +5 -7
  46. package/src/shared/hof.js +1 -2
  47. package/src/shared/jqlite/jqlite.js +26 -28
  48. package/src/shared/jqlite/jqlite.spec.js +10 -10
  49. package/src/shared/utils.js +6 -38
  50. package/types/core/controller/controller.d.ts +29 -5
  51. package/types/core/di/internal-injector.d.ts +6 -6
  52. package/types/core/di/ng-module.d.ts +2 -2
  53. package/types/directive/class/class.d.ts +3 -100
  54. package/types/directive/model/model.d.ts +6 -3
  55. package/types/directive/validators/validators.d.ts +2 -2
  56. package/types/router/resolve/resolve-context.d.ts +9 -6
  57. package/types/shared/common.d.ts +0 -2
  58. package/types/shared/hof.d.ts +0 -1
  59. package/types/shared/jqlite/jqlite.d.ts +4 -4
  60. package/types/shared/utils.d.ts +5 -13
@@ -56,11 +56,13 @@ export class ResolveContext {
56
56
  .filter((r) => r.token === token);
57
57
  return tail(matching);
58
58
  }
59
+
59
60
  /** Returns the [[ResolvePolicy]] for the given [[Resolvable]] */
60
61
  getPolicy(resolvable) {
61
62
  const node = this.findNode(resolvable);
62
63
  return resolvable.getPolicy(node);
63
64
  }
65
+
64
66
  /**
65
67
  * Returns a ResolveContext that includes a portion of this one
66
68
  *
@@ -101,7 +103,7 @@ export class ResolveContext {
101
103
  *
102
104
  * Note: each resolvable's [[ResolvePolicy]] is merged with the state's policy, and the global default.
103
105
  *
104
- * @param newResolvables the new Resolvables
106
+ * @param {Resolvable[]} newResolvables the new Resolvables
105
107
  * @param state Used to find the node to put the resolvable on
106
108
  */
107
109
  addResolvables(newResolvables, state) {
@@ -115,9 +117,9 @@ export class ResolveContext {
115
117
  /**
116
118
  * Returns a promise for an array of resolved path Element promises
117
119
  *
118
- * @param when
120
+ * @param {string} when
119
121
  * @param trans
120
- * @returns {Promise<any>|any}
122
+ * @returns {import("../../core/q/q").QPromise<any>|any}
121
123
  */
122
124
  resolvePath(when = "LAZY", trans) {
123
125
  // This option determines which 'when' policy Resolvables we are about to fetch.
@@ -153,16 +155,21 @@ export class ResolveContext {
153
155
  // Wait for all the "WAIT" resolvables
154
156
  return services.$q.all(promises);
155
157
  }
158
+
156
159
  injector() {
157
160
  return this._injector || (this._injector = new UIInjectorImpl());
158
161
  }
162
+
159
163
  findNode(resolvable) {
160
164
  return find(this._path, (node) => node.resolvables.includes(resolvable));
161
165
  }
166
+
162
167
  /**
163
168
  * Gets the async dependencies of a Resolvable
164
169
  *
165
170
  * Given a Resolvable, returns its dependencies as a Resolvable[]
171
+ * @param {Resolvable} resolvable
172
+ * @returns {Resolvable[]}
166
173
  */
167
174
  getDependencies(resolvable) {
168
175
  const node = this.findNode(resolvable);
@@ -173,7 +180,7 @@ export class ResolveContext {
173
180
  const availableResolvables = subPath
174
181
  .reduce((acc, _node) => acc.concat(_node.resolvables), []) // all of subpath's resolvables
175
182
  .filter((res) => res !== resolvable); // filter out the `resolvable` argument
176
- const getDependency = (token) => {
183
+ return resolvable.deps.map((token) => {
177
184
  const matching = availableResolvables.filter((r) => r.token === token);
178
185
  if (matching.length) return tail(matching);
179
186
  const fromInjector = services.$injector.get(token);
@@ -183,8 +190,7 @@ export class ResolveContext {
183
190
  );
184
191
  }
185
192
  return new Resolvable(token, () => fromInjector, [], fromInjector);
186
- };
187
- return resolvable.deps.map(getDependency);
193
+ });
188
194
  }
189
195
  }
190
196
 
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  applyPairs,
3
3
  inherit,
4
- mapObj,
5
4
  omit,
6
5
  tail,
7
6
  copy,
7
+ map,
8
8
  } from "../../shared/common";
9
9
  import { isDefined, isFunction, isString } from "../../shared/utils";
10
10
  import { stringify } from "../../shared/strings";
@@ -12,24 +12,27 @@ import { is, pattern, pipe, prop, val } from "../../shared/hof";
12
12
  import { Resolvable } from "../resolve/resolvable";
13
13
  import { services } from "../common/coreservices";
14
14
  import { annotate } from "../../core/di/injector";
15
- const parseUrl = (url) => {
15
+
16
+ function parseUrl(url) {
16
17
  if (!isString(url)) return false;
17
18
  const root = url.charAt(0) === "^";
18
19
  return { val: root ? url.substring(1) : url, root };
19
- };
20
+ }
20
21
 
21
22
  function selfBuilder(state) {
22
23
  state.self.$$state = () => state;
23
24
  return state.self;
24
25
  }
26
+
25
27
  function dataBuilder(state) {
26
28
  if (state.parent && state.parent.data) {
27
29
  state.data = state.self.data = inherit(state.parent.data, state.data);
28
30
  }
29
31
  return state.data;
30
32
  }
31
- const getUrlBuilder = ($urlService, root) =>
32
- function urlBuilder(stateObject) {
33
+
34
+ function getUrlBuilder($urlService, root) {
35
+ return function (stateObject) {
33
36
  let stateDec = stateObject.self;
34
37
  // For future states, i.e., states whose name ends with `.**`,
35
38
  // match anything that starts with the url prefix
@@ -56,31 +59,34 @@ const getUrlBuilder = ($urlService, root) =>
56
59
  ? url
57
60
  : ((parent && parent.navigable) || root()).url.append(url);
58
61
  };
59
- const getNavigableBuilder = (isRoot) =>
60
- function navigableBuilder(state) {
62
+ }
63
+
64
+ function getNavigableBuilder(isRoot) {
65
+ return function (state) {
61
66
  return !isRoot(state) && state.url
62
67
  ? state
63
68
  : state.parent
64
69
  ? state.parent.navigable
65
70
  : null;
66
71
  };
67
- const getParamsBuilder = (paramFactory) =>
68
- function paramsBuilder(state) {
72
+ }
73
+
74
+ function getParamsBuilder(paramFactory) {
75
+ return function (state) {
69
76
  const makeConfigParam = (config, id) =>
70
77
  paramFactory.fromConfig(id, null, state.self);
71
78
  const urlParams =
72
79
  (state.url && state.url.parameters({ inherit: false })) || [];
73
80
  const nonUrlParams = Object.values(
74
- mapObj(
75
- omit(state.params || {}, urlParams.map(prop("id"))),
76
- makeConfigParam,
77
- ),
81
+ map(omit(state.params || {}, urlParams.map(prop("id"))), makeConfigParam),
78
82
  );
79
83
  return urlParams
80
84
  .concat(nonUrlParams)
81
85
  .map((p) => [p.id, p])
82
86
  .reduce(applyPairs, {});
83
87
  };
88
+ }
89
+
84
90
  function pathBuilder(state) {
85
91
  if (state.parent && !state.abstract) {
86
92
  return state.parent.path.concat(state);
@@ -88,11 +94,13 @@ function pathBuilder(state) {
88
94
  return [state];
89
95
  }
90
96
  }
97
+
91
98
  function includesBuilder(state) {
92
99
  const includes = state.parent ? Object.assign({}, state.parent.includes) : {};
93
100
  includes[state.name] = true;
94
101
  return includes;
95
102
  }
103
+
96
104
  /**
97
105
  * This is a [[StateBuilder.builder]] function for the `resolve:` block on a [[StateDeclaration]].
98
106
  *
@@ -157,12 +165,6 @@ export function resolvablesBuilder(state) {
157
165
  };
158
166
  /** true if the object has both `token` and `resolveFn`, and is probably a [[ResolveLiteral]] */
159
167
  const isResolveLiteral = (obj) => !!(obj.token && obj.resolveFn);
160
- /** true if the object looks like a provide literal, or a ng2 Provider */
161
- const isLikeNg2Provider = (obj) =>
162
- !!(
163
- (obj.provide || obj.token) &&
164
- (obj.useValue || obj.useFactory || obj.useExisting || obj.useClass)
165
- );
166
168
  /** true if the object looks like a tuple from obj2Tuples */
167
169
  const isTupleFromObj = (obj) =>
168
170
  !!(
@@ -170,8 +172,7 @@ export function resolvablesBuilder(state) {
170
172
  obj.val &&
171
173
  (isString(obj.val) || Array.isArray(obj.val) || isFunction(obj.val))
172
174
  );
173
- /** extracts the token from a Provider or provide literal */
174
- const getToken = (p) => p.provide || p.token;
175
+
175
176
  // Given a literal resolve or provider object, returns a Resolvable
176
177
  const literal2Resolvable = pattern([
177
178
  [
@@ -232,7 +233,6 @@ export function resolvablesBuilder(state) {
232
233
  const item2Resolvable = pattern([
233
234
  [is(Resolvable), (r) => r],
234
235
  [isResolveLiteral, literal2Resolvable],
235
- [isLikeNg2Provider, literal2Resolvable],
236
236
  [isTupleFromObj, tuple2Resolvable],
237
237
  [
238
238
  val(true),
@@ -267,7 +267,6 @@ export class StateBuilder {
267
267
  this.$injector = undefined;
268
268
  const self = this;
269
269
  const root = () => matcher.find("");
270
- const isRoot = (state) => state.name === "";
271
270
  function parentBuilder(state) {
272
271
  if (isRoot(state)) return null;
273
272
  return matcher.find(self.parentName(state)) || root();
@@ -358,3 +357,12 @@ export class StateBuilder {
358
357
  return parentName ? parentName + "." + name : name;
359
358
  }
360
359
  }
360
+
361
+ function isRoot(state) {
362
+ return state.name === "";
363
+ }
364
+
365
+ /** extracts the token from a Provider or provide literal */
366
+ function getToken(p) {
367
+ return p.provide || p.token;
368
+ }
@@ -1,4 +1,4 @@
1
- import { removeFrom, tail, mapObj } from "../../shared/common";
1
+ import { removeFrom, tail, map } from "../../shared/common";
2
2
  import { isString, isFunction } from "../../shared/utils";
3
3
  import { Glob } from "../common/glob";
4
4
  import { TransitionHookScope } from "./interface";
@@ -93,7 +93,7 @@ export class RegisteredHook {
93
93
  * }
94
94
  */
95
95
  _getDefaultMatchCriteria() {
96
- return mapObj(this.tranSvc._pluginapi._getPathTypes(), () => true);
96
+ return map(this.tranSvc._pluginapi._getPathTypes(), () => true);
97
97
  }
98
98
  /**
99
99
  * Gets matching nodes as [[IMatchingNodes]]
@@ -2,7 +2,7 @@ import { TransitionHookPhase } from "./interface";
2
2
  import { defaults, silentRejection } from "../../shared/common";
3
3
  import { fnToString, maxLength } from "../../shared/strings";
4
4
  import { isPromise } from "../../shared/predicates";
5
- import { is, parse } from "../../shared/hof";
5
+ import { parse } from "../../shared/hof";
6
6
  import { trace } from "../common/trace";
7
7
  import { services } from "../common/coreservices";
8
8
  import { Rejection } from "./reject-factory";
@@ -134,9 +134,9 @@ export class TransitionHook {
134
134
  // Abort this Transition
135
135
  return Rejection.aborted("Hook aborted transition").toPromise();
136
136
  }
137
- const isTargetState = is(TargetState);
137
+
138
138
  // hook returned a TargetState
139
- if (isTargetState(result)) {
139
+ if (result instanceof TargetState) {
140
140
  // Halt the current Transition and redirect (a new Transition) to the TargetState.
141
141
  return Rejection.redirected(result).toPromise();
142
142
  }
@@ -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();
@@ -230,6 +230,7 @@ export function filter(collection, callback) {
230
230
  });
231
231
  return result;
232
232
  }
233
+
233
234
  /** Finds an object from an array, or a property of an object, that matches a predicate */
234
235
  export function find(collection, callback) {
235
236
  let result;
@@ -239,8 +240,7 @@ export function find(collection, callback) {
239
240
  });
240
241
  return result;
241
242
  }
242
- /** Given an object, returns a new object, where each property is transformed by the callback function */
243
- export let mapObj = map;
243
+
244
244
  /** Maps an array or object properties using a callback function */
245
245
  export function map(collection, callback, target) {
246
246
  target = target || (Array.isArray(collection) ? [] : {});
@@ -1,5 +1,5 @@
1
- import { defaults, filter, map, mapObj, pick } from "./common";
2
- import { is, eq, pattern, val } from "./hof";
1
+ import { defaults, filter, map, pick } from "./common";
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
  });
@@ -142,10 +140,10 @@ describe("common", function () {
142
140
  });
143
141
  });
144
142
 
145
- describe("mapObj", () => {
143
+ describe("map", () => {
146
144
  it("should map objects", () => {
147
145
  const src = { foo: 1, bar: 2, baz: 3 };
148
- const dest = mapObj(src, (x) => x * 2);
146
+ const dest = map(src, (x) => x * 2);
149
147
 
150
148
  expect(src).toEqual({ foo: 1, bar: 2, baz: 3 });
151
149
  expect(dest).toEqual({ foo: 2, bar: 4, baz: 6 });
@@ -153,7 +151,7 @@ describe("common", function () {
153
151
 
154
152
  it("should map objects in place when target === src", () => {
155
153
  const src = { foo: 1, bar: 2, baz: 3 };
156
- const dest = mapObj(src, (x) => x * 2, src);
154
+ const dest = map(src, (x) => x * 2, src);
157
155
 
158
156
  expect(src).toEqual({ foo: 2, bar: 4, baz: 6 });
159
157
  expect(dest).toEqual({ foo: 2, bar: 4, baz: 6 });
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") {
@@ -734,33 +728,6 @@ export function assertNotHasOwnProperty(name, context) {
734
728
  }
735
729
  }
736
730
 
737
- /**
738
- * Return the value accessible from the object by path. Any undefined traversals are ignored
739
- * @param {Object} obj starting object
740
- * @param {String} path path to traverse
741
- * @param {boolean} [bindFnToScope=true]
742
- * @returns {Object} value as accessible by path
743
- */
744
- // TODO(misko): this function needs to be removed
745
- export function getter(obj, path, bindFnToScope) {
746
- if (!path) return obj;
747
- const keys = path.split(".");
748
- let key;
749
- let lastInstance = obj;
750
- const len = keys.length;
751
-
752
- for (let i = 0; i < len; i++) {
753
- key = keys[i];
754
- if (obj) {
755
- obj = (lastInstance = obj)[key];
756
- }
757
- }
758
- if (!bindFnToScope && isFunction(obj)) {
759
- return bind(lastInstance, obj);
760
- }
761
- return obj;
762
- }
763
-
764
731
  export function stringify(value) {
765
732
  if (value == null) {
766
733
  // null || undefined
@@ -1277,7 +1244,8 @@ export function mergeClasses(a, b) {
1277
1244
 
1278
1245
  /**
1279
1246
  * Converts all accepted directives format into proper directive name.
1280
- * @param name Name to normalize
1247
+ * @param {string} name Name to normalize
1248
+ * @returns {string}
1281
1249
  */
1282
1250
 
1283
1251
  export function directiveNormalize(name) {