@angular-wave/angular.ts 0.0.1 → 0.0.4

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 (84) hide show
  1. package/Makefile +1 -1
  2. package/dist/angular-ts.cjs.js +506 -1696
  3. package/dist/angular-ts.esm.js +506 -1696
  4. package/dist/angular-ts.umd.js +506 -1696
  5. package/package.json +1 -1
  6. package/public/README.md +1 -0
  7. package/src/animations/{animateCss.js → animate-css.js} +0 -1
  8. package/src/animations/animation.js +428 -431
  9. package/src/animations/module.js +9 -9
  10. package/src/core/cache.js +2 -0
  11. package/src/core/compile.js +6 -1102
  12. package/src/core/compile.md +1192 -0
  13. package/src/core/location.js +1 -1
  14. package/src/core/utils.js +1 -1
  15. package/src/directive/a.js +1 -1
  16. package/src/directive/attrs.js +1 -1
  17. package/src/directive/csp.md +89 -0
  18. package/src/directive/input.js +3 -3
  19. package/src/directive/{ngModel.js → model.js} +1 -1
  20. package/src/directive/select.js +5 -5
  21. package/src/jqLite.js +1 -22
  22. package/src/public.js +24 -24
  23. package/src/services/log.js +66 -116
  24. package/src/services/log.md +39 -0
  25. package/test/jqlite.spec.js +5 -35
  26. package/test/messages/messages.spec.js +1 -1
  27. package/test/ng/compile.spec.js +17 -16
  28. package/test/ng/directive/model-options.spec.js +1 -1
  29. package/test/ng/directive/model.spec.js +1 -1
  30. package/test/ng/directive/options.spec.js +61 -61
  31. package/test/ng/directive/select.spec.js +22 -22
  32. package/test/ng/http-backend.spec.js +1 -1
  33. package/test/ng/on.spec.js +1 -1
  34. package/test/ng/prop.spec.js +54 -62
  35. package/test/ng/sanitize-uri.spec.js +1 -1
  36. package/test/ng/scope.spec.js +1 -1
  37. package/test/original-test.html +1 -1
  38. package/types/jqlite.d.ts +1 -32
  39. package/dist/build/angular-mocks.js +0 -3757
  40. package/dist/build/angular-parse-ext.js +0 -1275
  41. package/dist/build/angular-resource.js +0 -911
  42. package/dist/build/angular-touch.js +0 -368
  43. package/src/core/attributes.js +0 -199
  44. package/src/directive/ngCsp.js +0 -82
  45. /package/{dist/build → legacy}/angular-animate.js +0 -0
  46. /package/{dist/build → legacy}/angular-aria.js +0 -0
  47. /package/{dist/build → legacy}/angular-message-format.js +0 -0
  48. /package/{dist/build → legacy}/angular-messages.js +0 -0
  49. /package/{dist/build → legacy}/angular-route.js +0 -0
  50. /package/{dist/build → legacy}/angular-sanitize.js +0 -0
  51. /package/{dist/build → legacy}/angular.js +0 -0
  52. /package/src/animations/{animateCache.js → animate-cache.js} +0 -0
  53. /package/src/animations/{animateChildrenDirective.js → animate-children-directive.js} +0 -0
  54. /package/src/animations/{animateCssDriver.js → animate-css-driver.js} +0 -0
  55. /package/src/animations/{animateJsDriver.js → animate-js-driver.js} +0 -0
  56. /package/src/animations/{animateJs.js → animate-js.js} +0 -0
  57. /package/src/animations/{animateQueue.js → animate-queue.js} +0 -0
  58. /package/src/animations/{ngAnimateSwap.js → animate-swap.js} +0 -0
  59. /package/src/animations/{rafScheduler.js → raf-scheduler.js} +0 -0
  60. /package/src/core/{animateCss.js → animate-css.js} +0 -0
  61. /package/src/core/{animateRunner.js → animate-runner.js} +0 -0
  62. /package/src/core/{exceptionHandler.js → exception-handler.js} +0 -0
  63. /package/src/core/{intervalFactory.js → interval-factory.js} +0 -0
  64. /package/src/core/{rootScope.js → root-scope.js} +0 -0
  65. /package/src/core/{sanitizeUri.js → sanitize-uri.js} +0 -0
  66. /package/src/core/{taskTrackerFactory.js → task-tracker-factory.js} +0 -0
  67. /package/src/directive/{ngClass.js → class.js} +0 -0
  68. /package/src/directive/{ngController.js → controller.js} +0 -0
  69. /package/src/directive/{ngIf.js → if.js} +0 -0
  70. /package/src/directive/{ngInclude.js → include.js} +0 -0
  71. /package/src/directive/{ngModelOptions.js → model-options.js} +0 -0
  72. /package/src/directive/{ngOptions.js → options.js} +0 -0
  73. /package/src/directive/{ngRef.js → ref.js} +0 -0
  74. /package/src/directive/{ngRepeat.js → repeat.js} +0 -0
  75. /package/src/directive/{ngShowHide.js → show-hide.js} +0 -0
  76. /package/src/directive/{ngSwitch.js → switch.js} +0 -0
  77. /package/src/directive/{ngTransclude.js → transclude.js} +0 -0
  78. /package/src/{routeToRegExp.js → route-to-reg-exp.js} +0 -0
  79. /package/src/services/{anchorScroll.js → anchor-scroll.js} +0 -0
  80. /package/src/services/{cacheFactory.js → cache-factory.js} +0 -0
  81. /package/src/services/{cookieReader.js → cookie-reader.js} +0 -0
  82. /package/src/services/{httpBackend.js → http-backend.js} +0 -0
  83. /package/src/services/{templateRequest.js → template-request.js} +0 -0
  84. /package/test/ng/{anomate.spec.js → animate.spec.js} +0 -0
@@ -9,498 +9,495 @@ import {
9
9
  prepareAnimationOptions,
10
10
  } from "./shared";
11
11
 
12
- export const $$AnimationProvider = [
13
- "$animateProvider",
14
- function ($animateProvider) {
15
- const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
16
-
17
- const drivers = (this.drivers = []);
18
-
19
- const RUNNER_STORAGE_KEY = "$$animationRunner";
20
- const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
21
-
22
- function setRunner(element, runner) {
23
- element.data(RUNNER_STORAGE_KEY, runner);
24
- }
25
-
26
- function removeRunner(element) {
27
- element.removeData(RUNNER_STORAGE_KEY);
28
- }
29
-
30
- function getRunner(element) {
31
- return element.data(RUNNER_STORAGE_KEY);
32
- }
33
-
34
- this.$get = [
35
- "$rootScope",
36
- "$injector",
37
- "$$AnimateRunner",
38
- "$$rAFScheduler",
39
- "$$animateCache",
40
- function (
41
- $rootScope,
42
- $injector,
43
- $$AnimateRunner,
44
- $$rAFScheduler,
45
- $$animateCache,
46
- ) {
47
- const animationQueue = [];
48
- const applyAnimationClasses = applyAnimationClassesFactory();
49
-
50
- function sortAnimations(animations) {
51
- const tree = { children: [] };
52
- let i;
53
- const lookup = new Map();
54
-
55
- // this is done first beforehand so that the map
56
- // is filled with a list of the elements that will be animated
57
- // eslint-disable-next-line no-plusplus
58
- for (i = 0; i < animations.length; i++) {
59
- const animation = animations[i];
60
- lookup.set(
61
- animation.domNode,
62
- (animations[i] = {
63
- domNode: animation.domNode,
64
- element: animation.element,
65
- fn: animation.fn,
66
- children: [],
67
- }),
68
- );
69
- }
12
+ export function $$AnimationProvider() {
13
+ const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
14
+
15
+ const drivers = (this.drivers = []);
16
+
17
+ const RUNNER_STORAGE_KEY = "$$animationRunner";
18
+ const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
19
+
20
+ function setRunner(element, runner) {
21
+ element.data(RUNNER_STORAGE_KEY, runner);
22
+ }
23
+
24
+ function removeRunner(element) {
25
+ element.removeData(RUNNER_STORAGE_KEY);
26
+ }
27
+
28
+ function getRunner(element) {
29
+ return element.data(RUNNER_STORAGE_KEY);
30
+ }
31
+
32
+ this.$get = [
33
+ "$rootScope",
34
+ "$injector",
35
+ "$$AnimateRunner",
36
+ "$$rAFScheduler",
37
+ "$$animateCache",
38
+ function (
39
+ $rootScope,
40
+ $injector,
41
+ $$AnimateRunner,
42
+ $$rAFScheduler,
43
+ $$animateCache,
44
+ ) {
45
+ const animationQueue = [];
46
+ const applyAnimationClasses = applyAnimationClassesFactory();
47
+
48
+ function sortAnimations(animations) {
49
+ const tree = { children: [] };
50
+ let i;
51
+ const lookup = new Map();
52
+
53
+ // this is done first beforehand so that the map
54
+ // is filled with a list of the elements that will be animated
55
+ // eslint-disable-next-line no-plusplus
56
+ for (i = 0; i < animations.length; i++) {
57
+ const animation = animations[i];
58
+ lookup.set(
59
+ animation.domNode,
60
+ (animations[i] = {
61
+ domNode: animation.domNode,
62
+ element: animation.element,
63
+ fn: animation.fn,
64
+ children: [],
65
+ }),
66
+ );
67
+ }
70
68
 
71
- for (i = 0; i < animations.length; i++) {
72
- processNode(animations[i]);
73
- }
69
+ for (i = 0; i < animations.length; i++) {
70
+ processNode(animations[i]);
71
+ }
74
72
 
75
- return flatten(tree);
73
+ return flatten(tree);
76
74
 
77
- function processNode(entry) {
78
- if (entry.processed) return entry;
79
- entry.processed = true;
75
+ function processNode(entry) {
76
+ if (entry.processed) return entry;
77
+ entry.processed = true;
80
78
 
81
- const elementNode = entry.domNode;
82
- let { parentNode } = elementNode;
83
- lookup.set(elementNode, entry);
79
+ const elementNode = entry.domNode;
80
+ let { parentNode } = elementNode;
81
+ lookup.set(elementNode, entry);
84
82
 
85
- let parentEntry;
86
- while (parentNode) {
87
- parentEntry = lookup.get(parentNode);
88
- if (parentEntry) {
89
- if (!parentEntry.processed) {
90
- parentEntry = processNode(parentEntry);
91
- }
92
- break;
83
+ let parentEntry;
84
+ while (parentNode) {
85
+ parentEntry = lookup.get(parentNode);
86
+ if (parentEntry) {
87
+ if (!parentEntry.processed) {
88
+ parentEntry = processNode(parentEntry);
93
89
  }
94
- parentNode = parentNode.parentNode;
90
+ break;
95
91
  }
96
-
97
- (parentEntry || tree).children.push(entry);
98
- return entry;
92
+ parentNode = parentNode.parentNode;
99
93
  }
100
94
 
101
- function flatten(tree) {
102
- const result = [];
103
- const queue = [];
104
- let i;
95
+ (parentEntry || tree).children.push(entry);
96
+ return entry;
97
+ }
105
98
 
106
- for (i = 0; i < tree.children.length; i++) {
107
- queue.push(tree.children[i]);
108
- }
99
+ function flatten(tree) {
100
+ const result = [];
101
+ const queue = [];
102
+ let i;
109
103
 
110
- let remainingLevelEntries = queue.length;
111
- let nextLevelEntries = 0;
112
- let row = [];
113
-
114
- for (i = 0; i < queue.length; i++) {
115
- const entry = queue[i];
116
- if (remainingLevelEntries <= 0) {
117
- remainingLevelEntries = nextLevelEntries;
118
- nextLevelEntries = 0;
119
- result.push(row);
120
- row = [];
121
- }
122
- row.push(entry);
123
- entry.children.forEach((childEntry) => {
124
- nextLevelEntries++;
125
- queue.push(childEntry);
126
- });
127
- remainingLevelEntries--;
128
- }
104
+ for (i = 0; i < tree.children.length; i++) {
105
+ queue.push(tree.children[i]);
106
+ }
129
107
 
130
- if (row.length) {
108
+ let remainingLevelEntries = queue.length;
109
+ let nextLevelEntries = 0;
110
+ let row = [];
111
+
112
+ for (i = 0; i < queue.length; i++) {
113
+ const entry = queue[i];
114
+ if (remainingLevelEntries <= 0) {
115
+ remainingLevelEntries = nextLevelEntries;
116
+ nextLevelEntries = 0;
131
117
  result.push(row);
118
+ row = [];
132
119
  }
133
-
134
- return result;
120
+ row.push(entry);
121
+ entry.children.forEach((childEntry) => {
122
+ nextLevelEntries++;
123
+ queue.push(childEntry);
124
+ });
125
+ remainingLevelEntries--;
135
126
  }
136
- }
137
127
 
138
- // TODO(matsko): document the signature in a better way
139
- return function (element, event, options) {
140
- options = prepareAnimationOptions(options);
141
- const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
142
-
143
- // there is no animation at the current moment, however
144
- // these runner methods will get later updated with the
145
- // methods leading into the driver's end/cancel methods
146
- // for now they just stop the animation from starting
147
- const runner = new $$AnimateRunner({
148
- end() {
149
- close();
150
- },
151
- cancel() {
152
- close(true);
153
- },
154
- });
128
+ if (row.length) {
129
+ result.push(row);
130
+ }
155
131
 
156
- if (!drivers.length) {
132
+ return result;
133
+ }
134
+ }
135
+
136
+ // TODO(matsko): document the signature in a better way
137
+ return function (element, event, options) {
138
+ options = prepareAnimationOptions(options);
139
+ const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
140
+
141
+ // there is no animation at the current moment, however
142
+ // these runner methods will get later updated with the
143
+ // methods leading into the driver's end/cancel methods
144
+ // for now they just stop the animation from starting
145
+ const runner = new $$AnimateRunner({
146
+ end() {
157
147
  close();
158
- return runner;
159
- }
148
+ },
149
+ cancel() {
150
+ close(true);
151
+ },
152
+ });
153
+
154
+ if (!drivers.length) {
155
+ close();
156
+ return runner;
157
+ }
160
158
 
161
- let classes = mergeClasses(
162
- element.attr("class"),
163
- mergeClasses(options.addClass, options.removeClass),
164
- );
165
- let { tempClasses } = options;
166
- if (tempClasses) {
167
- classes += ` ${tempClasses}`;
168
- options.tempClasses = null;
169
- }
159
+ let classes = mergeClasses(
160
+ element.attr("class"),
161
+ mergeClasses(options.addClass, options.removeClass),
162
+ );
163
+ let { tempClasses } = options;
164
+ if (tempClasses) {
165
+ classes += ` ${tempClasses}`;
166
+ options.tempClasses = null;
167
+ }
170
168
 
171
- if (isStructural) {
172
- element.data(
173
- PREPARE_CLASSES_KEY,
174
- `ng-${event}${PREPARE_CLASS_SUFFIX}`,
175
- );
176
- }
169
+ if (isStructural) {
170
+ element.data(
171
+ PREPARE_CLASSES_KEY,
172
+ `ng-${event}${PREPARE_CLASS_SUFFIX}`,
173
+ );
174
+ }
177
175
 
178
- setRunner(element, runner);
179
-
180
- animationQueue.push({
181
- // this data is used by the postDigest code and passed into
182
- // the driver step function
183
- element,
184
- classes,
185
- event,
186
- structural: isStructural,
187
- options,
188
- beforeStart,
189
- close,
176
+ setRunner(element, runner);
177
+
178
+ animationQueue.push({
179
+ // this data is used by the postDigest code and passed into
180
+ // the driver step function
181
+ element,
182
+ classes,
183
+ event,
184
+ structural: isStructural,
185
+ options,
186
+ beforeStart,
187
+ close,
188
+ });
189
+
190
+ element.on("$destroy", handleDestroyedElement);
191
+
192
+ // we only want there to be one function called within the post digest
193
+ // block. This way we can group animations for all the animations that
194
+ // were apart of the same postDigest flush call.
195
+ if (animationQueue.length > 1) return runner;
196
+
197
+ $rootScope.$$postDigest(() => {
198
+ const animations = [];
199
+ forEach(animationQueue, (entry) => {
200
+ // the element was destroyed early on which removed the runner
201
+ // form its storage. This means we can't animate this element
202
+ // at all and it already has been closed due to destruction.
203
+ if (getRunner(entry.element)) {
204
+ animations.push(entry);
205
+ } else {
206
+ entry.close();
207
+ }
190
208
  });
191
209
 
192
- element.on("$destroy", handleDestroyedElement);
193
-
194
- // we only want there to be one function called within the post digest
195
- // block. This way we can group animations for all the animations that
196
- // were apart of the same postDigest flush call.
197
- if (animationQueue.length > 1) return runner;
198
-
199
- $rootScope.$$postDigest(() => {
200
- const animations = [];
201
- forEach(animationQueue, (entry) => {
202
- // the element was destroyed early on which removed the runner
203
- // form its storage. This means we can't animate this element
204
- // at all and it already has been closed due to destruction.
205
- if (getRunner(entry.element)) {
206
- animations.push(entry);
207
- } else {
208
- entry.close();
209
- }
210
- });
210
+ // now any future animations will be in another postDigest
211
+ animationQueue.length = 0;
212
+
213
+ const groupedAnimations = groupAnimations(animations);
214
+ const toBeSortedAnimations = [];
215
+
216
+ forEach(groupedAnimations, (animationEntry) => {
217
+ const element = animationEntry.from
218
+ ? animationEntry.from.element
219
+ : animationEntry.element;
220
+ let extraClasses = options.addClass;
221
+
222
+ extraClasses =
223
+ (extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
224
+ const cacheKey = $$animateCache.cacheKey(
225
+ element[0],
226
+ animationEntry.event,
227
+ extraClasses,
228
+ options.removeClass,
229
+ );
211
230
 
212
- // now any future animations will be in another postDigest
213
- animationQueue.length = 0;
214
-
215
- const groupedAnimations = groupAnimations(animations);
216
- const toBeSortedAnimations = [];
217
-
218
- forEach(groupedAnimations, (animationEntry) => {
219
- const element = animationEntry.from
220
- ? animationEntry.from.element
221
- : animationEntry.element;
222
- let extraClasses = options.addClass;
223
-
224
- extraClasses =
225
- (extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
226
- const cacheKey = $$animateCache.cacheKey(
227
- element[0],
228
- animationEntry.event,
229
- extraClasses,
230
- options.removeClass,
231
- );
232
-
233
- toBeSortedAnimations.push({
234
- element,
235
- domNode: getDomNode(element),
236
- fn: function triggerAnimationStart() {
237
- let startAnimationFn;
238
- const closeFn = animationEntry.close;
239
-
240
- // in the event that we've cached the animation status for this element
241
- // and it's in fact an invalid animation (something that has duration = 0)
242
- // then we should skip all the heavy work from here on
243
- if (
244
- $$animateCache.containsCachedAnimationWithoutDuration(
245
- cacheKey,
246
- )
247
- ) {
248
- closeFn();
249
- return;
250
- }
231
+ toBeSortedAnimations.push({
232
+ element,
233
+ domNode: getDomNode(element),
234
+ fn: function triggerAnimationStart() {
235
+ let startAnimationFn;
236
+ const closeFn = animationEntry.close;
237
+
238
+ // in the event that we've cached the animation status for this element
239
+ // and it's in fact an invalid animation (something that has duration = 0)
240
+ // then we should skip all the heavy work from here on
241
+ if (
242
+ $$animateCache.containsCachedAnimationWithoutDuration(
243
+ cacheKey,
244
+ )
245
+ ) {
246
+ closeFn();
247
+ return;
248
+ }
251
249
 
252
- // it's important that we apply the `ng-animate` CSS class and the
253
- // temporary classes before we do any driver invoking since these
254
- // CSS classes may be required for proper CSS detection.
255
- animationEntry.beforeStart();
256
-
257
- // in the event that the element was removed before the digest runs or
258
- // during the RAF sequencing then we should not trigger the animation.
259
- const targetElement = animationEntry.anchors
260
- ? animationEntry.from.element || animationEntry.to.element
261
- : animationEntry.element;
262
-
263
- if (getRunner(targetElement)) {
264
- const operation = invokeFirstDriver(animationEntry);
265
- if (operation) {
266
- startAnimationFn = operation.start;
267
- }
250
+ // it's important that we apply the `ng-animate` CSS class and the
251
+ // temporary classes before we do any driver invoking since these
252
+ // CSS classes may be required for proper CSS detection.
253
+ animationEntry.beforeStart();
254
+
255
+ // in the event that the element was removed before the digest runs or
256
+ // during the RAF sequencing then we should not trigger the animation.
257
+ const targetElement = animationEntry.anchors
258
+ ? animationEntry.from.element || animationEntry.to.element
259
+ : animationEntry.element;
260
+
261
+ if (getRunner(targetElement)) {
262
+ const operation = invokeFirstDriver(animationEntry);
263
+ if (operation) {
264
+ startAnimationFn = operation.start;
268
265
  }
266
+ }
269
267
 
270
- if (!startAnimationFn) {
271
- closeFn();
272
- } else {
273
- const animationRunner = startAnimationFn();
274
- animationRunner.done((status) => {
275
- closeFn(!status);
276
- });
277
- updateAnimationRunners(animationEntry, animationRunner);
278
- }
279
- },
280
- });
268
+ if (!startAnimationFn) {
269
+ closeFn();
270
+ } else {
271
+ const animationRunner = startAnimationFn();
272
+ animationRunner.done((status) => {
273
+ closeFn(!status);
274
+ });
275
+ updateAnimationRunners(animationEntry, animationRunner);
276
+ }
277
+ },
281
278
  });
279
+ });
282
280
 
283
- // we need to sort each of the animations in order of parent to child
284
- // relationships. This ensures that the child classes are applied at the
285
- // right time.
286
- const finalAnimations = sortAnimations(toBeSortedAnimations);
287
- for (let i = 0; i < finalAnimations.length; i++) {
288
- const innerArray = finalAnimations[i];
289
- for (let j = 0; j < innerArray.length; j++) {
290
- const entry = innerArray[j];
291
- const { element } = entry;
292
-
293
- // the RAFScheduler code only uses functions
294
- finalAnimations[i][j] = entry.fn;
295
-
296
- // the first row of elements shouldn't have a prepare-class added to them
297
- // since the elements are at the top of the animation hierarchy and they
298
- // will be applied without a RAF having to pass...
299
- if (i === 0) {
300
- element.removeData(PREPARE_CLASSES_KEY);
301
- continue;
302
- }
281
+ // we need to sort each of the animations in order of parent to child
282
+ // relationships. This ensures that the child classes are applied at the
283
+ // right time.
284
+ const finalAnimations = sortAnimations(toBeSortedAnimations);
285
+ for (let i = 0; i < finalAnimations.length; i++) {
286
+ const innerArray = finalAnimations[i];
287
+ for (let j = 0; j < innerArray.length; j++) {
288
+ const entry = innerArray[j];
289
+ const { element } = entry;
290
+
291
+ // the RAFScheduler code only uses functions
292
+ finalAnimations[i][j] = entry.fn;
293
+
294
+ // the first row of elements shouldn't have a prepare-class added to them
295
+ // since the elements are at the top of the animation hierarchy and they
296
+ // will be applied without a RAF having to pass...
297
+ if (i === 0) {
298
+ element.removeData(PREPARE_CLASSES_KEY);
299
+ continue;
300
+ }
303
301
 
304
- const prepareClassName = element.data(PREPARE_CLASSES_KEY);
305
- if (prepareClassName) {
306
- element[0].classList.add(prepareClassName);
307
- }
302
+ const prepareClassName = element.data(PREPARE_CLASSES_KEY);
303
+ if (prepareClassName) {
304
+ element[0].classList.add(prepareClassName);
308
305
  }
309
306
  }
307
+ }
310
308
 
311
- $$rAFScheduler(finalAnimations);
309
+ $$rAFScheduler(finalAnimations);
310
+ });
311
+
312
+ return runner;
313
+
314
+ // TODO(matsko): change to reference nodes
315
+ function getAnchorNodes(node) {
316
+ const SELECTOR = `[${NG_ANIMATE_REF_ATTR}]`;
317
+ const items = node.hasAttribute(NG_ANIMATE_REF_ATTR)
318
+ ? [node]
319
+ : node.querySelectorAll(SELECTOR);
320
+ const anchors = [];
321
+ forEach(items, (node) => {
322
+ const attr = node.getAttribute(NG_ANIMATE_REF_ATTR);
323
+ if (attr && attr.length) {
324
+ anchors.push(node);
325
+ }
312
326
  });
327
+ return anchors;
328
+ }
313
329
 
314
- return runner;
315
-
316
- // TODO(matsko): change to reference nodes
317
- function getAnchorNodes(node) {
318
- const SELECTOR = `[${NG_ANIMATE_REF_ATTR}]`;
319
- const items = node.hasAttribute(NG_ANIMATE_REF_ATTR)
320
- ? [node]
321
- : node.querySelectorAll(SELECTOR);
322
- const anchors = [];
323
- forEach(items, (node) => {
324
- const attr = node.getAttribute(NG_ANIMATE_REF_ATTR);
325
- if (attr && attr.length) {
326
- anchors.push(node);
327
- }
328
- });
329
- return anchors;
330
- }
330
+ function groupAnimations(animations) {
331
+ const preparedAnimations = [];
332
+ const refLookup = {};
333
+ forEach(animations, (animation, index) => {
334
+ const { element } = animation;
335
+ const node = getDomNode(element);
336
+ const { event } = animation;
337
+ const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
338
+ const anchorNodes = animation.structural
339
+ ? getAnchorNodes(node)
340
+ : [];
341
+
342
+ if (anchorNodes.length) {
343
+ const direction = enterOrMove ? "to" : "from";
344
+
345
+ forEach(anchorNodes, (anchor) => {
346
+ const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
347
+ refLookup[key] = refLookup[key] || {};
348
+ refLookup[key][direction] = {
349
+ animationID: index,
350
+ element: jqLite(anchor),
351
+ };
352
+ });
353
+ } else {
354
+ preparedAnimations.push(animation);
355
+ }
356
+ });
331
357
 
332
- function groupAnimations(animations) {
333
- const preparedAnimations = [];
334
- const refLookup = {};
335
- forEach(animations, (animation, index) => {
336
- const { element } = animation;
337
- const node = getDomNode(element);
338
- const { event } = animation;
339
- const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
340
- const anchorNodes = animation.structural
341
- ? getAnchorNodes(node)
342
- : [];
343
-
344
- if (anchorNodes.length) {
345
- const direction = enterOrMove ? "to" : "from";
346
-
347
- forEach(anchorNodes, (anchor) => {
348
- const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
349
- refLookup[key] = refLookup[key] || {};
350
- refLookup[key][direction] = {
351
- animationID: index,
352
- element: jqLite(anchor),
353
- };
354
- });
355
- } else {
356
- preparedAnimations.push(animation);
358
+ const usedIndicesLookup = {};
359
+ const anchorGroups = {};
360
+ Object.values(refLookup).forEach((operations) => {
361
+ const { from } = operations;
362
+ const { to } = operations;
363
+
364
+ if (!from || !to) {
365
+ // only one of these is set therefore we can't have an
366
+ // anchor animation since all three pieces are required
367
+ const index = from ? from.animationID : to.animationID;
368
+ const indexKey = index.toString();
369
+ if (!usedIndicesLookup[indexKey]) {
370
+ usedIndicesLookup[indexKey] = true;
371
+ preparedAnimations.push(animations[index]);
357
372
  }
358
- });
373
+ return;
374
+ }
359
375
 
360
- const usedIndicesLookup = {};
361
- const anchorGroups = {};
362
- Object.values(refLookup).forEach((operations) => {
363
- const { from } = operations;
364
- const { to } = operations;
365
-
366
- if (!from || !to) {
367
- // only one of these is set therefore we can't have an
368
- // anchor animation since all three pieces are required
369
- const index = from ? from.animationID : to.animationID;
370
- const indexKey = index.toString();
371
- if (!usedIndicesLookup[indexKey]) {
372
- usedIndicesLookup[indexKey] = true;
373
- preparedAnimations.push(animations[index]);
374
- }
375
- return;
376
- }
376
+ const fromAnimation = animations[from.animationID];
377
+ const toAnimation = animations[to.animationID];
378
+ const lookupKey = from.animationID.toString();
379
+ if (!anchorGroups[lookupKey]) {
380
+ const group = (anchorGroups[lookupKey] = {
381
+ structural: true,
382
+ beforeStart() {
383
+ fromAnimation.beforeStart();
384
+ toAnimation.beforeStart();
385
+ },
386
+ close() {
387
+ fromAnimation.close();
388
+ toAnimation.close();
389
+ },
390
+ classes: cssClassesIntersection(
391
+ fromAnimation.classes,
392
+ toAnimation.classes,
393
+ ),
394
+ from: fromAnimation,
395
+ to: toAnimation,
396
+ anchors: [], // TODO(matsko): change to reference nodes
397
+ });
377
398
 
378
- const fromAnimation = animations[from.animationID];
379
- const toAnimation = animations[to.animationID];
380
- const lookupKey = from.animationID.toString();
381
- if (!anchorGroups[lookupKey]) {
382
- const group = (anchorGroups[lookupKey] = {
383
- structural: true,
384
- beforeStart() {
385
- fromAnimation.beforeStart();
386
- toAnimation.beforeStart();
387
- },
388
- close() {
389
- fromAnimation.close();
390
- toAnimation.close();
391
- },
392
- classes: cssClassesIntersection(
393
- fromAnimation.classes,
394
- toAnimation.classes,
395
- ),
396
- from: fromAnimation,
397
- to: toAnimation,
398
- anchors: [], // TODO(matsko): change to reference nodes
399
- });
400
-
401
- // the anchor animations require that the from and to elements both have at least
402
- // one shared CSS class which effectively marries the two elements together to use
403
- // the same animation driver and to properly sequence the anchor animation.
404
- if (group.classes.length) {
405
- preparedAnimations.push(group);
406
- } else {
407
- preparedAnimations.push(fromAnimation);
408
- preparedAnimations.push(toAnimation);
409
- }
399
+ // the anchor animations require that the from and to elements both have at least
400
+ // one shared CSS class which effectively marries the two elements together to use
401
+ // the same animation driver and to properly sequence the anchor animation.
402
+ if (group.classes.length) {
403
+ preparedAnimations.push(group);
404
+ } else {
405
+ preparedAnimations.push(fromAnimation);
406
+ preparedAnimations.push(toAnimation);
410
407
  }
408
+ }
411
409
 
412
- anchorGroups[lookupKey].anchors.push({
413
- out: from.element,
414
- in: to.element,
415
- });
410
+ anchorGroups[lookupKey].anchors.push({
411
+ out: from.element,
412
+ in: to.element,
416
413
  });
414
+ });
417
415
 
418
- return preparedAnimations;
419
- }
416
+ return preparedAnimations;
417
+ }
420
418
 
421
- function cssClassesIntersection(a, b) {
422
- a = a.split(" ");
423
- b = b.split(" ");
424
- const matches = [];
419
+ function cssClassesIntersection(a, b) {
420
+ a = a.split(" ");
421
+ b = b.split(" ");
422
+ const matches = [];
425
423
 
426
- for (let i = 0; i < a.length; i++) {
427
- const aa = a[i];
428
- if (aa.substring(0, 3) === "ng-") continue;
424
+ for (let i = 0; i < a.length; i++) {
425
+ const aa = a[i];
426
+ if (aa.substring(0, 3) === "ng-") continue;
429
427
 
430
- for (let j = 0; j < b.length; j++) {
431
- if (aa === b[j]) {
432
- matches.push(aa);
433
- break;
434
- }
428
+ for (let j = 0; j < b.length; j++) {
429
+ if (aa === b[j]) {
430
+ matches.push(aa);
431
+ break;
435
432
  }
436
433
  }
437
-
438
- return matches.join(" ");
439
434
  }
440
435
 
441
- function invokeFirstDriver(animationDetails) {
442
- // we loop in reverse order since the more general drivers (like CSS and JS)
443
- // may attempt more elements, but custom drivers are more particular
444
- for (let i = drivers.length - 1; i >= 0; i--) {
445
- const driverName = drivers[i];
446
- const factory = $injector.get(driverName);
447
- const driver = factory(animationDetails);
448
- if (driver) {
449
- return driver;
450
- }
451
- }
452
- }
436
+ return matches.join(" ");
437
+ }
453
438
 
454
- function beforeStart() {
455
- tempClasses =
456
- (tempClasses ? `${tempClasses} ` : "") + NG_ANIMATE_CLASSNAME;
457
- element.className += ` ${tempClasses}`;
458
- let prepareClassName = element.data(PREPARE_CLASSES_KEY);
459
- if (prepareClassName) {
460
- element[0].classList.remove(prepareClassName);
461
- prepareClassName = null;
439
+ function invokeFirstDriver(animationDetails) {
440
+ // we loop in reverse order since the more general drivers (like CSS and JS)
441
+ // may attempt more elements, but custom drivers are more particular
442
+ for (let i = drivers.length - 1; i >= 0; i--) {
443
+ const driverName = drivers[i];
444
+ const factory = $injector.get(driverName);
445
+ const driver = factory(animationDetails);
446
+ if (driver) {
447
+ return driver;
462
448
  }
463
449
  }
450
+ }
464
451
 
465
- function updateAnimationRunners(animation, newRunner) {
466
- if (animation.from && animation.to) {
467
- update(animation.from.element);
468
- update(animation.to.element);
469
- } else {
470
- update(animation.element);
471
- }
452
+ function beforeStart() {
453
+ tempClasses =
454
+ (tempClasses ? `${tempClasses} ` : "") + NG_ANIMATE_CLASSNAME;
455
+ element.className += ` ${tempClasses}`;
456
+ let prepareClassName = element.data(PREPARE_CLASSES_KEY);
457
+ if (prepareClassName) {
458
+ element[0].classList.remove(prepareClassName);
459
+ prepareClassName = null;
460
+ }
461
+ }
472
462
 
473
- function update(element) {
474
- const runner = getRunner(element);
475
- if (runner) runner.setHost(newRunner);
476
- }
463
+ function updateAnimationRunners(animation, newRunner) {
464
+ if (animation.from && animation.to) {
465
+ update(animation.from.element);
466
+ update(animation.to.element);
467
+ } else {
468
+ update(animation.element);
477
469
  }
478
470
 
479
- function handleDestroyedElement() {
471
+ function update(element) {
480
472
  const runner = getRunner(element);
481
- if (runner && (event !== "leave" || !options.$$domOperationFired)) {
482
- runner.end();
483
- }
473
+ if (runner) runner.setHost(newRunner);
484
474
  }
475
+ }
485
476
 
486
- function close(rejected) {
487
- element.off("$destroy", handleDestroyedElement);
488
- removeRunner(element);
477
+ function handleDestroyedElement() {
478
+ const runner = getRunner(element);
479
+ if (runner && (event !== "leave" || !options.$$domOperationFired)) {
480
+ runner.end();
481
+ }
482
+ }
489
483
 
490
- applyAnimationClasses(element, options);
491
- applyAnimationStyles(element, options);
492
- options.domOperation();
484
+ function close(rejected) {
485
+ element.off("$destroy", handleDestroyedElement);
486
+ removeRunner(element);
493
487
 
494
- if (tempClasses) {
495
- tempClasses
496
- .split(" ")
497
- .forEach((cls) => element[0].classList.remove(cls));
498
- }
488
+ applyAnimationClasses(element, options);
489
+ applyAnimationStyles(element, options);
490
+ options.domOperation();
499
491
 
500
- runner.complete(!rejected);
492
+ if (tempClasses) {
493
+ tempClasses
494
+ .split(" ")
495
+ .forEach((cls) => element[0].classList.remove(cls));
501
496
  }
502
- };
503
- },
504
- ];
505
- },
506
- ];
497
+
498
+ runner.complete(!rejected);
499
+ }
500
+ };
501
+ },
502
+ ];
503
+ }