@angular-wave/angular.ts 0.0.1

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 (231) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +29 -0
  3. package/.github/workflows/playwright.yml +27 -0
  4. package/CHANGELOG.md +17974 -0
  5. package/CODE_OF_CONDUCT.md +3 -0
  6. package/CONTRIBUTING.md +246 -0
  7. package/DEVELOPERS.md +488 -0
  8. package/LICENSE +22 -0
  9. package/Makefile +31 -0
  10. package/README.md +115 -0
  11. package/RELEASE.md +98 -0
  12. package/SECURITY.md +16 -0
  13. package/TRIAGING.md +135 -0
  14. package/css/angular.css +22 -0
  15. package/dist/angular-ts.cjs.js +36843 -0
  16. package/dist/angular-ts.esm.js +36841 -0
  17. package/dist/angular-ts.umd.js +36848 -0
  18. package/dist/build/angular-animate.js +4272 -0
  19. package/dist/build/angular-aria.js +426 -0
  20. package/dist/build/angular-message-format.js +1072 -0
  21. package/dist/build/angular-messages.js +829 -0
  22. package/dist/build/angular-mocks.js +3757 -0
  23. package/dist/build/angular-parse-ext.js +1275 -0
  24. package/dist/build/angular-resource.js +911 -0
  25. package/dist/build/angular-route.js +1266 -0
  26. package/dist/build/angular-sanitize.js +891 -0
  27. package/dist/build/angular-touch.js +368 -0
  28. package/dist/build/angular.js +36600 -0
  29. package/e2e/unit.spec.ts +15 -0
  30. package/images/android-chrome-192x192.png +0 -0
  31. package/images/android-chrome-512x512.png +0 -0
  32. package/images/apple-touch-icon.png +0 -0
  33. package/images/favicon-16x16.png +0 -0
  34. package/images/favicon-32x32.png +0 -0
  35. package/images/favicon.ico +0 -0
  36. package/images/site.webmanifest +1 -0
  37. package/index.html +104 -0
  38. package/package.json +47 -0
  39. package/playwright.config.ts +78 -0
  40. package/public/circle.html +1 -0
  41. package/public/my_child_directive.html +1 -0
  42. package/public/my_directive.html +1 -0
  43. package/public/my_other_directive.html +1 -0
  44. package/public/test.html +1 -0
  45. package/rollup.config.js +31 -0
  46. package/src/animations/animateCache.js +55 -0
  47. package/src/animations/animateChildrenDirective.js +105 -0
  48. package/src/animations/animateCss.js +1139 -0
  49. package/src/animations/animateCssDriver.js +291 -0
  50. package/src/animations/animateJs.js +367 -0
  51. package/src/animations/animateJsDriver.js +67 -0
  52. package/src/animations/animateQueue.js +851 -0
  53. package/src/animations/animation.js +506 -0
  54. package/src/animations/module.js +779 -0
  55. package/src/animations/ngAnimateSwap.js +119 -0
  56. package/src/animations/rafScheduler.js +50 -0
  57. package/src/animations/shared.js +378 -0
  58. package/src/constants.js +20 -0
  59. package/src/core/animate.js +845 -0
  60. package/src/core/animateCss.js +73 -0
  61. package/src/core/animateRunner.js +195 -0
  62. package/src/core/attributes.js +199 -0
  63. package/src/core/cache.js +45 -0
  64. package/src/core/compile.js +4727 -0
  65. package/src/core/controller.js +225 -0
  66. package/src/core/exceptionHandler.js +63 -0
  67. package/src/core/filter.js +146 -0
  68. package/src/core/interpolate.js +442 -0
  69. package/src/core/interval.js +188 -0
  70. package/src/core/intervalFactory.js +57 -0
  71. package/src/core/location.js +1086 -0
  72. package/src/core/parser/parse.js +2562 -0
  73. package/src/core/parser/parse.md +13 -0
  74. package/src/core/q.js +746 -0
  75. package/src/core/rootScope.js +1596 -0
  76. package/src/core/sanitizeUri.js +85 -0
  77. package/src/core/sce.js +1161 -0
  78. package/src/core/taskTrackerFactory.js +125 -0
  79. package/src/core/timeout.js +121 -0
  80. package/src/core/urlUtils.js +187 -0
  81. package/src/core/utils.js +1349 -0
  82. package/src/directive/a.js +37 -0
  83. package/src/directive/attrs.js +283 -0
  84. package/src/directive/bind.js +51 -0
  85. package/src/directive/bind.md +142 -0
  86. package/src/directive/change.js +12 -0
  87. package/src/directive/change.md +25 -0
  88. package/src/directive/cloak.js +12 -0
  89. package/src/directive/cloak.md +24 -0
  90. package/src/directive/events.js +75 -0
  91. package/src/directive/events.md +166 -0
  92. package/src/directive/form.js +725 -0
  93. package/src/directive/init.js +15 -0
  94. package/src/directive/init.md +41 -0
  95. package/src/directive/input.js +1783 -0
  96. package/src/directive/list.js +46 -0
  97. package/src/directive/list.md +22 -0
  98. package/src/directive/ngClass.js +249 -0
  99. package/src/directive/ngController.js +64 -0
  100. package/src/directive/ngCsp.js +82 -0
  101. package/src/directive/ngIf.js +134 -0
  102. package/src/directive/ngInclude.js +217 -0
  103. package/src/directive/ngModel.js +1356 -0
  104. package/src/directive/ngModelOptions.js +509 -0
  105. package/src/directive/ngOptions.js +670 -0
  106. package/src/directive/ngRef.js +90 -0
  107. package/src/directive/ngRepeat.js +650 -0
  108. package/src/directive/ngShowHide.js +255 -0
  109. package/src/directive/ngSwitch.js +178 -0
  110. package/src/directive/ngTransclude.js +98 -0
  111. package/src/directive/non-bindable.js +11 -0
  112. package/src/directive/non-bindable.md +17 -0
  113. package/src/directive/script.js +30 -0
  114. package/src/directive/select.js +624 -0
  115. package/src/directive/style.js +25 -0
  116. package/src/directive/style.md +23 -0
  117. package/src/directive/validators.js +329 -0
  118. package/src/exts/aria.js +544 -0
  119. package/src/exts/messages.js +852 -0
  120. package/src/filters/filter.js +207 -0
  121. package/src/filters/filter.md +69 -0
  122. package/src/filters/filters.js +239 -0
  123. package/src/filters/json.md +16 -0
  124. package/src/filters/limit-to.js +43 -0
  125. package/src/filters/limit-to.md +19 -0
  126. package/src/filters/order-by.js +183 -0
  127. package/src/filters/order-by.md +83 -0
  128. package/src/index.js +13 -0
  129. package/src/injector.js +1034 -0
  130. package/src/jqLite.js +1117 -0
  131. package/src/loader.js +1320 -0
  132. package/src/public.js +215 -0
  133. package/src/routeToRegExp.js +41 -0
  134. package/src/services/anchorScroll.js +135 -0
  135. package/src/services/browser.js +321 -0
  136. package/src/services/cacheFactory.js +398 -0
  137. package/src/services/cookieReader.js +72 -0
  138. package/src/services/document.js +64 -0
  139. package/src/services/http.js +1537 -0
  140. package/src/services/httpBackend.js +206 -0
  141. package/src/services/log.js +160 -0
  142. package/src/services/templateRequest.js +139 -0
  143. package/test/angular.spec.js +2153 -0
  144. package/test/aria/aria.spec.js +1245 -0
  145. package/test/binding.spec.js +504 -0
  146. package/test/build-test.html +14 -0
  147. package/test/injector.spec.js +2327 -0
  148. package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
  149. package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
  150. package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
  151. package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
  152. package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
  153. package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
  154. package/test/jasmine/jasmine-browser.json +17 -0
  155. package/test/jasmine/jasmine.json +9 -0
  156. package/test/jqlite.spec.js +2133 -0
  157. package/test/loader.spec.js +219 -0
  158. package/test/messages/messages.spec.js +1146 -0
  159. package/test/min-err.spec.js +174 -0
  160. package/test/mock-test.html +13 -0
  161. package/test/module-test.html +15 -0
  162. package/test/ng/anomate.spec.js +606 -0
  163. package/test/ng/cache-factor.spec.js +334 -0
  164. package/test/ng/compile.spec.js +17956 -0
  165. package/test/ng/controller-provider.spec.js +227 -0
  166. package/test/ng/cookie-reader.spec.js +98 -0
  167. package/test/ng/directive/a.spec.js +192 -0
  168. package/test/ng/directive/bind.spec.js +334 -0
  169. package/test/ng/directive/boolean.spec.js +136 -0
  170. package/test/ng/directive/change.spec.js +71 -0
  171. package/test/ng/directive/class.spec.js +858 -0
  172. package/test/ng/directive/click.spec.js +38 -0
  173. package/test/ng/directive/cloak.spec.js +44 -0
  174. package/test/ng/directive/constoller.spec.js +194 -0
  175. package/test/ng/directive/element-style.spec.js +92 -0
  176. package/test/ng/directive/event.spec.js +282 -0
  177. package/test/ng/directive/form.spec.js +1518 -0
  178. package/test/ng/directive/href.spec.js +143 -0
  179. package/test/ng/directive/if.spec.js +402 -0
  180. package/test/ng/directive/include.spec.js +828 -0
  181. package/test/ng/directive/init.spec.js +68 -0
  182. package/test/ng/directive/input.spec.js +3810 -0
  183. package/test/ng/directive/list.spec.js +170 -0
  184. package/test/ng/directive/model-options.spec.js +1008 -0
  185. package/test/ng/directive/model.spec.js +1905 -0
  186. package/test/ng/directive/non-bindable.spec.js +55 -0
  187. package/test/ng/directive/options.spec.js +3583 -0
  188. package/test/ng/directive/ref.spec.js +575 -0
  189. package/test/ng/directive/repeat.spec.js +1675 -0
  190. package/test/ng/directive/script.spec.js +52 -0
  191. package/test/ng/directive/scrset.spec.js +67 -0
  192. package/test/ng/directive/select.spec.js +2541 -0
  193. package/test/ng/directive/show-hide.spec.js +253 -0
  194. package/test/ng/directive/src.spec.js +157 -0
  195. package/test/ng/directive/style.spec.js +178 -0
  196. package/test/ng/directive/switch.spec.js +647 -0
  197. package/test/ng/directive/validators.spec.js +717 -0
  198. package/test/ng/document.spec.js +52 -0
  199. package/test/ng/filter/filter.spec.js +714 -0
  200. package/test/ng/filter/filters.spec.js +35 -0
  201. package/test/ng/filter/limit-to.spec.js +251 -0
  202. package/test/ng/filter/order-by.spec.js +891 -0
  203. package/test/ng/filter.spec.js +149 -0
  204. package/test/ng/http-backend.spec.js +398 -0
  205. package/test/ng/http.spec.js +4071 -0
  206. package/test/ng/interpolate.spec.js +642 -0
  207. package/test/ng/interval.spec.js +343 -0
  208. package/test/ng/location.spec.js +3488 -0
  209. package/test/ng/on.spec.js +229 -0
  210. package/test/ng/parse.spec.js +4655 -0
  211. package/test/ng/prop.spec.js +805 -0
  212. package/test/ng/q.spec.js +2904 -0
  213. package/test/ng/root-element.spec.js +16 -0
  214. package/test/ng/sanitize-uri.spec.js +249 -0
  215. package/test/ng/sce.spec.js +660 -0
  216. package/test/ng/scope.spec.js +3442 -0
  217. package/test/ng/template-request.spec.js +236 -0
  218. package/test/ng/timeout.spec.js +351 -0
  219. package/test/ng/url-utils.spec.js +156 -0
  220. package/test/ng/utils.spec.js +144 -0
  221. package/test/original-test.html +21 -0
  222. package/test/public.spec.js +34 -0
  223. package/test/sanitize/bing-html.spec.js +36 -0
  224. package/test/server/express.js +158 -0
  225. package/test/test-utils.js +11 -0
  226. package/tsconfig.json +17 -0
  227. package/types/angular.d.ts +138 -0
  228. package/types/global.d.ts +9 -0
  229. package/types/index.d.ts +2357 -0
  230. package/types/jqlite.d.ts +558 -0
  231. package/vite.config.js +14 -0
@@ -0,0 +1,46 @@
1
+ import { forEach, isArray, isUndefined, trim } from "../core/utils";
2
+
3
+ /**
4
+ * @returns {angular.IDirective}
5
+ */
6
+ export function ngListDirective() {
7
+ return {
8
+ restrict: "A",
9
+ priority: 100,
10
+ require: "ngModel",
11
+ link(_scope, _element, attr, ctrl) {
12
+ const ngList = attr.ngList || ", ";
13
+ const trimValues = attr.ngTrim !== "false";
14
+ const separator = trimValues ? trim(ngList) : ngList;
15
+
16
+ const parse = function (viewValue) {
17
+ // If the viewValue is invalid (say required but empty) it will be `undefined`
18
+ if (isUndefined(viewValue)) return;
19
+
20
+ const list = [];
21
+
22
+ if (viewValue) {
23
+ forEach(viewValue.split(separator), (value) => {
24
+ if (value) list.push(trimValues ? trim(value) : value);
25
+ });
26
+ }
27
+
28
+ return list;
29
+ };
30
+
31
+ ctrl.$parsers.push(parse);
32
+ ctrl.$formatters.push((value) => {
33
+ if (isArray(value)) {
34
+ return value.join(ngList);
35
+ }
36
+
37
+ return undefined;
38
+ });
39
+
40
+ // Override the standard $isEmpty because an empty array means the input is empty.
41
+ ctrl.$isEmpty = function (value) {
42
+ return !value || !value.length;
43
+ };
44
+ },
45
+ };
46
+ }
@@ -0,0 +1,22 @@
1
+ ## `ngList` Directive
2
+
3
+ ### Restrict
4
+
5
+ `A`
6
+
7
+ ### Priority
8
+
9
+ 100
10
+
11
+ ### Parameter
12
+
13
+ - `{string=} ngList`: Optional delimiter that should be used to split the value.
14
+
15
+ ### Description
16
+
17
+ Text input that converts between a delimited string and an array of strings. The default delimiter is a comma followed by a space - equivalent to `ng-list=", "`. You can specify a custom delimiter as the value of the `ngList` attribute - for example, `ng-list=" | "`.
18
+
19
+ The behavior of the directive is affected by the use of the `ngTrim` attribute.
20
+
21
+ - If `ngTrim` is set to `"false"` then whitespace around both the separator and each list item is respected. This implies that the user of the directive is responsible for dealing with whitespace but also allows you to use whitespace as a delimiter, such as a tab or newline character.
22
+ - Otherwise, whitespace around the delimiter is ignored when splitting (although it is respected when joining the list items back together) and whitespace around each list item is stripped before it is added to the model.
@@ -0,0 +1,249 @@
1
+ import { createMap, forEach, isArray, isObject, isString } from "../core/utils";
2
+
3
+ function classDirective(name, selector) {
4
+ // eslint-disable-next-line no-param-reassign
5
+ name = `ngClass${name}`;
6
+ var indexWatchExpression;
7
+
8
+ return [
9
+ "$parse",
10
+ ($parse) => ({
11
+ restrict: "EA",
12
+ link(scope, element, attr) {
13
+ let classCounts = element.data("$classCounts");
14
+ let oldModulo = true;
15
+ let oldClassString;
16
+
17
+ if (!classCounts) {
18
+ // Use createMap() to prevent class assumptions involving property
19
+ // names in Object.prototype
20
+ classCounts = createMap();
21
+ element.data("$classCounts", classCounts);
22
+ }
23
+
24
+ if (name !== "ngClass") {
25
+ if (!indexWatchExpression) {
26
+ indexWatchExpression = $parse("$index", function moduloTwo($index) {
27
+ // eslint-disable-next-line no-bitwise
28
+ return $index & 1;
29
+ });
30
+ }
31
+
32
+ scope.$watch(indexWatchExpression, ngClassIndexWatchAction);
33
+ }
34
+
35
+ scope.$watch($parse(attr[name], toClassString), ngClassWatchAction);
36
+
37
+ function addClasses(classString) {
38
+ classString = digestClassCounts(split(classString), 1);
39
+ attr.$addClass(classString);
40
+ }
41
+
42
+ function removeClasses(classString) {
43
+ classString = digestClassCounts(split(classString), -1);
44
+ attr.$removeClass(classString);
45
+ }
46
+
47
+ function updateClasses(oldClassString, newClassString) {
48
+ const oldClassArray = split(oldClassString);
49
+ const newClassArray = split(newClassString);
50
+
51
+ const toRemoveArray = arrayDifference(oldClassArray, newClassArray);
52
+ const toAddArray = arrayDifference(newClassArray, oldClassArray);
53
+
54
+ const toRemoveString = digestClassCounts(toRemoveArray, -1);
55
+ const toAddString = digestClassCounts(toAddArray, 1);
56
+
57
+ attr.$addClass(toAddString);
58
+ attr.$removeClass(toRemoveString);
59
+ }
60
+
61
+ function digestClassCounts(classArray, count) {
62
+ const classesToUpdate = [];
63
+
64
+ forEach(classArray, (className) => {
65
+ if (count > 0 || classCounts[className]) {
66
+ classCounts[className] = (classCounts[className] || 0) + count;
67
+ if (classCounts[className] === +(count > 0)) {
68
+ classesToUpdate.push(className);
69
+ }
70
+ }
71
+ });
72
+
73
+ return classesToUpdate.join(" ");
74
+ }
75
+
76
+ function ngClassIndexWatchAction(newModulo) {
77
+ // This watch-action should run before the `ngClassWatchAction()`, thus it
78
+ // adds/removes `oldClassString`. If the `ngClass` expression has changed as well, the
79
+ // `ngClassWatchAction()` will update the classes.
80
+ if (newModulo === selector) {
81
+ addClasses(oldClassString);
82
+ } else {
83
+ removeClasses(oldClassString);
84
+ }
85
+
86
+ oldModulo = newModulo;
87
+ }
88
+
89
+ function ngClassWatchAction(newClassString) {
90
+ if (oldModulo === selector) {
91
+ updateClasses(oldClassString, newClassString);
92
+ }
93
+
94
+ oldClassString = newClassString;
95
+ }
96
+ },
97
+ }),
98
+ ];
99
+
100
+ // Helpers
101
+ function arrayDifference(tokens1, tokens2) {
102
+ if (!tokens1 || !tokens1.length) return [];
103
+ if (!tokens2 || !tokens2.length) return tokens1;
104
+
105
+ const values = [];
106
+
107
+ outer: for (let i = 0; i < tokens1.length; i++) {
108
+ const token = tokens1[i];
109
+ for (let j = 0; j < tokens2.length; j++) {
110
+ if (token === tokens2[j]) continue outer;
111
+ }
112
+ values.push(token);
113
+ }
114
+
115
+ return values;
116
+ }
117
+
118
+ function split(classString) {
119
+ return classString && classString.split(" ");
120
+ }
121
+
122
+ function toClassString(classValue) {
123
+ if (!classValue) return classValue;
124
+
125
+ let classString = classValue;
126
+
127
+ if (isArray(classValue)) {
128
+ classString = classValue.map(toClassString).join(" ");
129
+ } else if (isObject(classValue)) {
130
+ classString = Object.keys(classValue)
131
+ .filter((key) => classValue[key])
132
+ .join(" ");
133
+ } else if (!isString(classValue)) {
134
+ classString = `${classValue}`;
135
+ }
136
+
137
+ return classString;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @ngdoc directive
143
+ * @name ngClass
144
+ * @restrict AC
145
+ * @element ANY
146
+ *
147
+ * @description
148
+ * The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding
149
+ * an expression that represents all classes to be added.
150
+ *
151
+ * The directive operates in three different ways, depending on which of three types the expression
152
+ * evaluates to:
153
+ *
154
+ * 1. If the expression evaluates to a string, the string should be one or more space-delimited class
155
+ * names.
156
+ *
157
+ * 2. If the expression evaluates to an object, then for each key-value pair of the
158
+ * object with a truthy value the corresponding key is used as a class name.
159
+ *
160
+ * 3. If the expression evaluates to an array, each element of the array should either be a string as in
161
+ * type 1 or an object as in type 2. This means that you can mix strings and objects together in an array
162
+ * to give you more control over what CSS classes appear. See the code below for an example of this.
163
+ *
164
+ *
165
+ * The directive won't add duplicate classes if a particular class was already set.
166
+ *
167
+ * When the expression changes, the previously added classes are removed and only then are the
168
+ * new classes added.
169
+ *
170
+ * @knownIssue
171
+ * You should not use {@link guide/interpolation interpolation} in the value of the `class`
172
+ * attribute, when using the `ngClass` directive on the same element.
173
+ * See {@link guide/interpolation#known-issues here} for more info.
174
+ *
175
+ * @animations
176
+ * | Animation | Occurs |
177
+ * |----------------------------------|-------------------------------------|
178
+ * | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
179
+ * | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
180
+ * | {@link ng.$animate#setClass setClass} | just before classes are added and classes are removed from the element at the same time |
181
+ *
182
+ * ### ngClass and pre-existing CSS3 Transitions/Animations
183
+ The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.
184
+ Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder
185
+ any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure
186
+ to view the step by step details of {@link $animate#addClass $animate.addClass} and
187
+ {@link $animate#removeClass $animate.removeClass}.
188
+ *
189
+ * @param {String} ngClass {@link guide/expression Expression} to eval. The result
190
+ * of the evaluation can be a string representing space delimited class
191
+ * names, an array, or a map of class names to boolean values. In the case of a map, the
192
+ * names of the properties whose values are truthy will be added as css classes to the
193
+ * element.
194
+ *
195
+ */
196
+ export const ngClassDirective = classDirective("", true);
197
+
198
+ /**
199
+ * @ngdoc directive
200
+ * @name ngClassOdd
201
+ * @restrict AC
202
+ *
203
+ * @description
204
+ * The `ngClassOdd` and `ngClassEven` directives work exactly as
205
+ * {@link ng.directive:ngClass ngClass}, except they work in
206
+ * conjunction with `ngRepeat` and take effect only on odd (even) rows.
207
+ *
208
+ * This directive can be applied only within the scope of an
209
+ * {@link ng.directive:ngRepeat ngRepeat}.
210
+ *
211
+ * @animations
212
+ * | Animation | Occurs |
213
+ * |----------------------------------|-------------------------------------|
214
+ * | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
215
+ * | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
216
+ *
217
+ * @element ANY
218
+ * @param {String} ngClassOdd {@link guide/expression Expression} to eval. The result
219
+ * of the evaluation can be a string representing space delimited class names or an array.
220
+ *
221
+ *
222
+ */
223
+ export const ngClassOddDirective = classDirective("Odd", 0);
224
+
225
+ /**
226
+ * @ngdoc directive
227
+ * @name ngClassEven
228
+ * @restrict AC
229
+ *
230
+ * @description
231
+ * The `ngClassOdd` and `ngClassEven` directives work exactly as
232
+ * {@link ng.directive:ngClass ngClass}, except they work in
233
+ * conjunction with `ngRepeat` and take effect only on odd (even) rows.
234
+ *
235
+ * This directive can be applied only within the scope of an
236
+ * {@link ng.directive:ngRepeat ngRepeat}.
237
+ *
238
+ * @animations
239
+ * | Animation | Occurs |
240
+ * |----------------------------------|-------------------------------------|
241
+ * | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
242
+ * | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
243
+ *
244
+ * @element ANY
245
+ * @param {String} ngClassEven {@link guide/expression Expression} to eval. The
246
+ * result of the evaluation can be a string representing space delimited class names or an array.
247
+ *
248
+ */
249
+ export const ngClassEvenDirective = classDirective("Even", 1);
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @ngdoc directive
3
+ * @name ngController
4
+ *
5
+ * @description
6
+ * The `ngController` directive attaches a controller class to the view. This is a key aspect of how angular
7
+ * supports the principles behind the Model-View-Controller design pattern.
8
+ *
9
+ * MVC components in angular:
10
+ *
11
+ * * Model — Models are the properties of a scope; scopes are attached to the DOM where scope properties
12
+ * are accessed through bindings.
13
+ * * View — The template (HTML with data bindings) that is rendered into the View.
14
+ * * Controller — The `ngController` directive specifies a Controller class; the class contains business
15
+ * logic behind the application to decorate the scope with functions and values
16
+ *
17
+ * Note that you can also attach controllers to the DOM by declaring it in a route definition
18
+ * via the {@link ngRoute.$route $route} service. A common mistake is to declare the controller
19
+ * again using `ng-controller` in the template itself. This will cause the controller to be attached
20
+ * and executed twice.
21
+ *
22
+ * @element ANY
23
+ * @scope
24
+ * @priority 500
25
+ * @param {String} ngController Name of a constructor function registered with the current
26
+ * {@link ng.$controllerProvider $controllerProvider} or an {@link guide/expression expression}
27
+ * that on the current scope evaluates to a constructor function.
28
+ *
29
+ * The controller instance can be published into a scope property by specifying
30
+ * `ng-controller="as propertyName"`.
31
+ *
32
+ * @example
33
+ * Here is a simple form for editing user contact information. Adding, removing, clearing, and
34
+ * greeting are methods declared on the controller (see source tab). These methods can
35
+ * easily be called from the AngularJS markup. Any changes to the data are automatically reflected
36
+ * in the View without the need for a manual update.
37
+ *
38
+ * Two different declaration styles are included below:
39
+ *
40
+ * * one binds methods and properties directly onto the controller using `this`:
41
+ * `ng-controller="SettingsController1 as settings"`
42
+ * * one injects `$scope` into the controller:
43
+ * `ng-controller="SettingsController2"`
44
+ *
45
+ * The second option is more common in the AngularJS community, and is generally used in boilerplates
46
+ * and in this guide. However, there are advantages to binding properties directly to the controller
47
+ * and avoiding scope.
48
+ *
49
+ * * Using `controller as` makes it obvious which controller you are accessing in the template when
50
+ * multiple controllers apply to an element.
51
+ * * If you are writing your controllers as classes you have easier access to the properties and
52
+ * methods, which will appear on the scope, from inside the controller code.
53
+ * * Since there is always a `.` in the bindings, you don't have to worry about prototypal
54
+ * inheritance masking primitives.
55
+ *
56
+ */
57
+ export const ngControllerDirective = [
58
+ () => ({
59
+ restrict: "A",
60
+ scope: true,
61
+ controller: "@",
62
+ priority: 500,
63
+ }),
64
+ ];
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @ngdoc directive
3
+ * @name ngCsp
4
+ *
5
+ * @restrict A
6
+ * @element ANY
7
+ * @description
8
+ *
9
+ * AngularJS has some features that can conflict with certain restrictions that are applied when using
10
+ * [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) rules.
11
+ *
12
+ * If you intend to implement CSP with these rules then you must tell AngularJS not to use these
13
+ * features.
14
+ *
15
+ * This is necessary when developing things like Google Chrome Extensions or Universal Windows Apps.
16
+ *
17
+ *
18
+ * The following default rules in CSP affect AngularJS:
19
+ *
20
+ * * The use of `eval()`, `Function(string)` and similar functions to dynamically create and execute
21
+ * code from strings is forbidden. AngularJS makes use of this in the {@link $parse} service to
22
+ * provide a 30% increase in the speed of evaluating AngularJS expressions. (This CSP rule can be
23
+ * disabled with the CSP keyword `unsafe-eval`, but it is generally not recommended as it would
24
+ * weaken the protections offered by CSP.)
25
+ *
26
+ * * The use of inline resources, such as inline `<script>` and `<style>` elements, are forbidden.
27
+ * This prevents apps from injecting custom styles directly into the document. AngularJS makes use of
28
+ * this to include some CSS rules (e.g. {@link ngCloak} and {@link ngHide}). To make these
29
+ * directives work when a CSP rule is blocking inline styles, you must link to the `angular-csp.css`
30
+ * in your HTML manually. (This CSP rule can be disabled with the CSP keyword `unsafe-inline`, but
31
+ * it is generally not recommended as it would weaken the protections offered by CSP.)
32
+ *
33
+ * If you do not provide `ngCsp` then AngularJS tries to autodetect if CSP is blocking dynamic code
34
+ * creation from strings (e.g., `unsafe-eval` not specified in CSP header) and automatically
35
+ * deactivates this feature in the {@link $parse} service. This autodetection, however, triggers a
36
+ * CSP error to be logged in the console:
37
+ *
38
+ * ```
39
+ * Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of
40
+ * script in the following Content Security Policy directive: "default-src 'self'". Note that
41
+ * 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
42
+ * ```
43
+ *
44
+ * This error is harmless but annoying. To prevent the error from showing up, put the `ngCsp`
45
+ * directive on an element of the HTML document that appears before the `<script>` tag that loads
46
+ * the `angular.js` file.
47
+ *
48
+ * *Note: This directive is only available in the `ng-csp` and `data-ng-csp` attribute form.*
49
+ *
50
+ * You can specify which of the CSP related AngularJS features should be deactivated by providing
51
+ * a value for the `ng-csp` attribute. The options are as follows:
52
+ *
53
+ * * no-inline-style: this stops AngularJS from injecting CSS styles into the DOM
54
+ *
55
+ * * no-unsafe-eval: this stops AngularJS from optimizing $parse with unsafe eval of strings
56
+ *
57
+ * You can use these values in the following combinations:
58
+ *
59
+ *
60
+ * * No declaration means that AngularJS will assume that you can do inline styles, but it will do
61
+ * a runtime check for unsafe-eval. E.g. `<body>`. This is backwardly compatible with previous
62
+ * versions of AngularJS.
63
+ *
64
+ * * A simple `ng-csp` (or `data-ng-csp`) attribute will tell AngularJS to deactivate both inline
65
+ * styles and unsafe eval. E.g. `<body ng-csp>`. This is backwardly compatible with previous
66
+ * versions of AngularJS.
67
+ *
68
+ * * Specifying only `no-unsafe-eval` tells AngularJS that we must not use eval, but that we can
69
+ * inject inline styles. E.g. `<body ng-csp="no-unsafe-eval">`.
70
+ *
71
+ * * Specifying only `no-inline-style` tells AngularJS that we must not inject styles, but that we can
72
+ * run eval - no automatic check for unsafe eval will occur. E.g. `<body ng-csp="no-inline-style">`
73
+ *
74
+ * * Specifying both `no-unsafe-eval` and `no-inline-style` tells AngularJS that we must not inject
75
+ * styles nor use eval, which is the same as an empty: ng-csp.
76
+ * E.g.`<body ng-csp="no-inline-style;no-unsafe-eval">`
77
+
78
+ // `ngCsp` is not implemented as a proper directive any more, because we need it be processed while
79
+ // we bootstrap the app (before `$parse` is instantiated). For this reason, we just have the `csp()`
80
+ // fn that looks for the `ng-csp` attribute anywhere in the current doc.
81
+ // TODO MOVE CSP to PARSE CONFIG as this should not even be a directive
82
+ */
@@ -0,0 +1,134 @@
1
+ import { getBlockNodes } from "../jqLite";
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name ngIf
6
+ * @restrict A
7
+ * @multiElement
8
+ *
9
+ * @description
10
+ * The `ngIf` directive removes or recreates a portion of the DOM tree based on an
11
+ * {expression}. If the expression assigned to `ngIf` evaluates to a false
12
+ * value then the element is removed from the DOM, otherwise a clone of the
13
+ * element is reinserted into the DOM.
14
+ *
15
+ * `ngIf` differs from `ngShow` and `ngHide` in that `ngIf` completely removes and recreates the
16
+ * element in the DOM rather than changing its visibility via the `display` css property. A common
17
+ * case when this difference is significant is when using css selectors that rely on an element's
18
+ * position within the DOM, such as the `:first-child` or `:last-child` pseudo-classes.
19
+ *
20
+ * Note that when an element is removed using `ngIf` its scope is destroyed and a new scope
21
+ * is created when the element is restored. The scope created within `ngIf` inherits from
22
+ * its parent scope using
23
+ * [prototypal inheritance](https://github.com/angular/angular.js/wiki/Understanding-Scopes#javascript-prototypal-inheritance).
24
+ * An important implication of this is if `ngModel` is used within `ngIf` to bind to
25
+ * a javascript primitive defined in the parent scope. In this case any modifications made to the
26
+ * variable within the child scope will override (hide) the value in the parent scope.
27
+ *
28
+ * Also, `ngIf` recreates elements using their compiled state. An example of this behavior
29
+ * is if an element's class attribute is directly modified after it's compiled, using something like
30
+ * jQuery's `.addClass()` method, and the element is later removed. When `ngIf` recreates the element
31
+ * the added class will be lost because the original compiled state is used to regenerate the element.
32
+ *
33
+ * Additionally, you can provide animations via the `ngAnimate` module to animate the `enter`
34
+ * and `leave` effects.
35
+ *
36
+ * @animations
37
+ * | Animation | Occurs |
38
+ * |----------------------------------|-------------------------------------|
39
+ * | {@link ng.$animate#enter enter} | just after the `ngIf` contents change and a new DOM element is created and injected into the `ngIf` container |
40
+ * | {@link ng.$animate#leave leave} | just before the `ngIf` contents are removed from the DOM |
41
+ *
42
+ * @element ANY
43
+ * @scope
44
+ * @priority 600
45
+ * @param {string} ngIf If the {@link guide/expression expression} is falsy then
46
+ * the element is removed from the DOM tree. If it is truthy a copy of the compiled
47
+ * element is added to the DOM tree.
48
+ *
49
+ * @example
50
+ <example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-if">
51
+ <file name="index.html">
52
+ <label>Click me: <input type="checkbox" ng-model="checked" ng-init="checked=true" /></label><br/>
53
+ Show when checked:
54
+ <span ng-if="checked" class="animate-if">
55
+ This is removed when the checkbox is unchecked.
56
+ </span>
57
+ </file>
58
+ <file name="animations.css">
59
+ .animate-if {
60
+ background:white;
61
+ border:1px solid black;
62
+ padding:10px;
63
+ }
64
+
65
+ .animate-if.ng-enter, .animate-if.ng-leave {
66
+ transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
67
+ }
68
+
69
+ .animate-if.ng-enter,
70
+ .animate-if.ng-leave.ng-leave-active {
71
+ opacity:0;
72
+ }
73
+
74
+ .animate-if.ng-leave,
75
+ .animate-if.ng-enter.ng-enter-active {
76
+ opacity:1;
77
+ }
78
+ </file>
79
+ </example>
80
+ */
81
+ export const ngIfDirective = [
82
+ "$animate",
83
+ "$compile",
84
+ ($animate, $compile) => ({
85
+ multiElement: true,
86
+ transclude: "element",
87
+ priority: 600,
88
+ terminal: true,
89
+ restrict: "A",
90
+ $$tlb: true,
91
+ link($scope, $element, $attr, ctrl, $transclude) {
92
+ let block;
93
+ let childScope;
94
+ let previousElements;
95
+ $scope.$watch($attr.ngIf, (value) => {
96
+ if (value) {
97
+ if (!childScope) {
98
+ $transclude((clone, newScope) => {
99
+ childScope = newScope;
100
+ // eslint-disable-next-line no-plusplus, no-param-reassign
101
+ clone[clone.length++] = $compile.$$createComment(
102
+ "end ngIf",
103
+ $attr.ngIf,
104
+ );
105
+ // Note: We only need the first/last node of the cloned nodes.
106
+ // However, we need to keep the reference to the jqlite wrapper as it might be changed later
107
+ // by a directive with templateUrl when its template arrives.
108
+ block = {
109
+ clone,
110
+ };
111
+ $animate.enter(clone, $element.parent(), $element);
112
+ });
113
+ }
114
+ } else {
115
+ if (previousElements) {
116
+ previousElements.remove();
117
+ previousElements = null;
118
+ }
119
+ if (childScope) {
120
+ childScope.$destroy();
121
+ childScope = null;
122
+ }
123
+ if (block) {
124
+ previousElements = getBlockNodes(block.clone);
125
+ $animate.leave(previousElements).done((response) => {
126
+ if (response !== false) previousElements = null;
127
+ });
128
+ block = null;
129
+ }
130
+ }
131
+ });
132
+ },
133
+ }),
134
+ ];