@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,544 @@
1
+ import { extend } from "../core/utils";
2
+
3
+ /**
4
+ * @ngdoc module
5
+ * @name ngAria
6
+ * @description
7
+ *
8
+ * The `ngAria` module provides support for common
9
+ * [<abbr title="Accessible Rich Internet Applications">ARIA</abbr>](http://www.w3.org/TR/wai-aria/)
10
+ * attributes that convey state or semantic information about the application for users
11
+ * of assistive technologies, such as screen readers.
12
+ *
13
+ * ## Usage
14
+ *
15
+ * For ngAria to do its magic, simply include the module `ngAria` as a dependency. The following
16
+ * directives are supported:
17
+ * `ngModel`, `ngChecked`, `ngReadonly`, `ngRequired`, `ngValue`, `ngDisabled`, `ngShow`, `ngHide`,
18
+ * `ngClick`, `ngDblClick`, and `ngMessages`.
19
+ *
20
+ * Below is a more detailed breakdown of the attributes handled by ngAria:
21
+ *
22
+ * | Directive | Supported Attributes |
23
+ * |---------------------------------------------|-----------------------------------------------------------------------------------------------------|
24
+ * | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles |
25
+ * | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled |
26
+ * | {@link ng.directive:ngRequired ngRequired} | aria-required |
27
+ * | {@link ng.directive:ngChecked ngChecked} | aria-checked |
28
+ * | {@link ng.directive:ngReadonly ngReadonly} | aria-readonly |
29
+ * | {@link ng.directive:ngValue ngValue} | aria-checked |
30
+ * | {@link ng.directive:ngShow ngShow} | aria-hidden |
31
+ * | {@link ng.directive:ngHide ngHide} | aria-hidden |
32
+ * | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
33
+ * | {@link module:ngMessages ngMessages} | aria-live |
34
+ * | {@link ng.directive:ngClick ngClick} | tabindex, keydown event, button role |
35
+ *
36
+ * Find out more information about each directive by reading the
37
+ * {@link guide/accessibility ngAria Developer Guide}.
38
+ *
39
+ * ## Example
40
+ * Using ngDisabled with ngAria:
41
+ * ```html
42
+ * <md-checkbox ng-disabled="disabled">
43
+ * ```
44
+ * Becomes:
45
+ * ```html
46
+ * <md-checkbox ng-disabled="disabled" aria-disabled="true">
47
+ * ```
48
+ *
49
+ * ## Disabling Specific Attributes
50
+ * It is possible to disable individual attributes added by ngAria with the
51
+ * {@link ngAria.$ariaProvider#config config} method. For more details, see the
52
+ * {@link guide/accessibility Developer Guide}.
53
+ *
54
+ * ## Disabling `ngAria` on Specific Elements
55
+ * It is possible to make `ngAria` ignore a specific element, by adding the `ng-aria-disable`
56
+ * attribute on it. Note that only the element itself (and not its child elements) will be ignored.
57
+ */
58
+ const ARIA_DISABLE_ATTR = "ngAriaDisable";
59
+
60
+ export function initAriaModule() {
61
+ window.angular
62
+ .module("ngAria", ["ng"])
63
+ .provider("$aria", $AriaProvider)
64
+ .directive("ngShow", [
65
+ "$aria",
66
+ function ($aria) {
67
+ return $aria.$$watchExpr("ngShow", "aria-hidden", [], true);
68
+ },
69
+ ])
70
+ .directive("ngHide", [
71
+ "$aria",
72
+ function ($aria) {
73
+ return $aria.$$watchExpr("ngHide", "aria-hidden", [], false);
74
+ },
75
+ ])
76
+ .directive("ngValue", [
77
+ "$aria",
78
+ function ($aria) {
79
+ return $aria.$$watchExpr(
80
+ "ngValue",
81
+ "aria-checked",
82
+ nativeAriaNodeNames,
83
+ false,
84
+ );
85
+ },
86
+ ])
87
+ .directive("ngChecked", [
88
+ "$aria",
89
+ function ($aria) {
90
+ return $aria.$$watchExpr(
91
+ "ngChecked",
92
+ "aria-checked",
93
+ nativeAriaNodeNames,
94
+ false,
95
+ );
96
+ },
97
+ ])
98
+ .directive("ngReadonly", [
99
+ "$aria",
100
+ function ($aria) {
101
+ return $aria.$$watchExpr(
102
+ "ngReadonly",
103
+ "aria-readonly",
104
+ nativeAriaNodeNames,
105
+ false,
106
+ );
107
+ },
108
+ ])
109
+ .directive("ngRequired", [
110
+ "$aria",
111
+ function ($aria) {
112
+ return $aria.$$watchExpr(
113
+ "ngRequired",
114
+ "aria-required",
115
+ nativeAriaNodeNames,
116
+ false,
117
+ );
118
+ },
119
+ ])
120
+ .directive("ngModel", [
121
+ "$aria",
122
+ function ($aria) {
123
+ function shouldAttachAttr(
124
+ attr,
125
+ normalizedAttr,
126
+ elem,
127
+ allowNonAriaNodes,
128
+ ) {
129
+ return (
130
+ $aria.config(normalizedAttr) &&
131
+ !elem.attr(attr) &&
132
+ (allowNonAriaNodes || !isNodeOneOf(elem, nativeAriaNodeNames)) &&
133
+ (elem.attr("type") !== "hidden" || elem[0].nodeName !== "INPUT")
134
+ );
135
+ }
136
+
137
+ function shouldAttachRole(role, elem) {
138
+ // if element does not have role attribute
139
+ // AND element type is equal to role (if custom element has a type equaling shape) <-- remove?
140
+ // AND element is not in nativeAriaNodeNames
141
+ return (
142
+ !elem.attr("role") &&
143
+ elem.attr("type") === role &&
144
+ !isNodeOneOf(elem, nativeAriaNodeNames)
145
+ );
146
+ }
147
+
148
+ function getShape(attr) {
149
+ const { type } = attr;
150
+ const { role } = attr;
151
+
152
+ return (type || role) === "checkbox" || role === "menuitemcheckbox"
153
+ ? "checkbox"
154
+ : (type || role) === "radio" || role === "menuitemradio"
155
+ ? "radio"
156
+ : type === "range" || role === "progressbar" || role === "slider"
157
+ ? "range"
158
+ : "";
159
+ }
160
+
161
+ return {
162
+ restrict: "A",
163
+ require: "ngModel",
164
+ priority: 200, // Make sure watches are fired after any other directives that affect the ngModel value
165
+ compile(elem, attr) {
166
+ if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
167
+ return;
168
+
169
+ const shape = getShape(attr);
170
+
171
+ return {
172
+ post(scope, elem, attr, ngModel) {
173
+ const needsTabIndex = shouldAttachAttr(
174
+ "tabindex",
175
+ "tabindex",
176
+ elem,
177
+ false,
178
+ );
179
+
180
+ function ngAriaWatchModelValue() {
181
+ return ngModel.$modelValue;
182
+ }
183
+
184
+ function getRadioReaction() {
185
+ // Strict comparison would cause a BC
186
+ // eslint-disable-next-line eqeqeq
187
+ elem[0].setAttribute(
188
+ "aria-checked",
189
+ (attr.value == ngModel.$viewValue).toString(),
190
+ );
191
+ }
192
+
193
+ function getCheckboxReaction() {
194
+ elem.attr(
195
+ "aria-checked",
196
+ (!ngModel.$isEmpty(ngModel.$viewValue)).toString(),
197
+ );
198
+ }
199
+
200
+ switch (shape) {
201
+ case "radio":
202
+ case "checkbox":
203
+ if (shouldAttachRole(shape, elem)) {
204
+ elem.attr("role", shape);
205
+ }
206
+ if (
207
+ shouldAttachAttr(
208
+ "aria-checked",
209
+ "ariaChecked",
210
+ elem,
211
+ false,
212
+ )
213
+ ) {
214
+ scope.$watch(
215
+ ngAriaWatchModelValue,
216
+ shape === "radio"
217
+ ? getRadioReaction
218
+ : getCheckboxReaction,
219
+ );
220
+ }
221
+ if (needsTabIndex) {
222
+ elem.attr("tabindex", 0);
223
+ }
224
+ break;
225
+ case "range":
226
+ if (shouldAttachRole(shape, elem)) {
227
+ elem.attr("role", "slider");
228
+ }
229
+ if ($aria.config("ariaValue")) {
230
+ const needsAriaValuemin =
231
+ !elem.attr("aria-valuemin") &&
232
+ (Object.prototype.hasOwnProperty.call(attr, "min") ||
233
+ Object.prototype.hasOwnProperty.call(attr, "ngMin"));
234
+ const needsAriaValuemax =
235
+ !elem.attr("aria-valuemax") &&
236
+ (Object.prototype.hasOwnProperty.call(attr, "max") ||
237
+ Object.prototype.hasOwnProperty.call(attr, "ngMax"));
238
+ const needsAriaValuenow = !elem.attr("aria-valuenow");
239
+
240
+ if (needsAriaValuemin) {
241
+ attr.$observe("min", (newVal) => {
242
+ elem.attr("aria-valuemin", newVal);
243
+ });
244
+ }
245
+ if (needsAriaValuemax) {
246
+ attr.$observe("max", (newVal) => {
247
+ elem.attr("aria-valuemax", newVal);
248
+ });
249
+ }
250
+ if (needsAriaValuenow) {
251
+ scope.$watch(ngAriaWatchModelValue, (newVal) => {
252
+ elem.attr("aria-valuenow", newVal);
253
+ });
254
+ }
255
+ }
256
+ if (needsTabIndex) {
257
+ elem.attr("tabindex", 0);
258
+ }
259
+ break;
260
+ }
261
+
262
+ if (
263
+ !Object.prototype.hasOwnProperty.call(attr, "ngRequired") &&
264
+ ngModel.$validators.required &&
265
+ shouldAttachAttr("aria-required", "ariaRequired", elem, false)
266
+ ) {
267
+ // ngModel.$error.required is undefined on custom controls
268
+ attr.$observe("required", () => {
269
+ elem.attr("aria-required", (!!attr.required).toString());
270
+ });
271
+ }
272
+
273
+ if (
274
+ shouldAttachAttr("aria-invalid", "ariaInvalid", elem, true)
275
+ ) {
276
+ scope.$watch(
277
+ () => ngModel.$invalid,
278
+ (newVal) => {
279
+ elem.attr("aria-invalid", (!!newVal).toString());
280
+ },
281
+ );
282
+ }
283
+ },
284
+ };
285
+ },
286
+ };
287
+ },
288
+ ])
289
+ .directive("ngDisabled", [
290
+ "$aria",
291
+ function ($aria) {
292
+ return $aria.$$watchExpr(
293
+ "ngDisabled",
294
+ "aria-disabled",
295
+ nativeAriaNodeNames,
296
+ false,
297
+ );
298
+ },
299
+ ])
300
+ .directive("ngMessages", () => ({
301
+ restrict: "A",
302
+ require: "?ngMessages",
303
+ link(_scope, elem, attr) {
304
+ if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
305
+ return;
306
+
307
+ if (!elem.attr("aria-live")) {
308
+ elem.attr("aria-live", "assertive");
309
+ }
310
+ },
311
+ }))
312
+ .directive("ngClick", [
313
+ "$aria",
314
+ "$parse",
315
+ function ($aria, $parse) {
316
+ return {
317
+ restrict: "A",
318
+ compile(elem, attr) {
319
+ if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
320
+ return;
321
+
322
+ const fn = $parse(attr.ngClick);
323
+ return function (scope, elem, attr) {
324
+ if (!isNodeOneOf(elem, nativeAriaNodeNames)) {
325
+ if ($aria.config("bindRoleForClick") && !elem.attr("role")) {
326
+ elem.attr("role", "button");
327
+ }
328
+
329
+ if ($aria.config("tabindex") && !elem.attr("tabindex")) {
330
+ elem.attr("tabindex", 0);
331
+ }
332
+
333
+ if (
334
+ $aria.config("bindKeydown") &&
335
+ !attr.ngKeydown &&
336
+ !attr.ngKeypress &&
337
+ !attr.ngKeyup
338
+ ) {
339
+ elem.on("keydown", (event) => {
340
+ const keyCode = event.which || event.keyCode;
341
+
342
+ if (keyCode === 13 || keyCode === 32) {
343
+ // If the event is triggered on a non-interactive element ...
344
+ if (
345
+ nativeAriaNodeNames.indexOf(event.target.nodeName) ===
346
+ -1 &&
347
+ !event.target.isContentEditable
348
+ ) {
349
+ // ... prevent the default browser behavior (e.g. scrolling when pressing spacebar)
350
+ // See https://github.com/angular/angular.js/issues/16664
351
+ event.preventDefault();
352
+ }
353
+ scope.$apply(callback);
354
+ }
355
+
356
+ function callback() {
357
+ fn(scope, { $event: event });
358
+ }
359
+ });
360
+ }
361
+ }
362
+ };
363
+ },
364
+ };
365
+ },
366
+ ])
367
+ .directive("ngDblclick", [
368
+ "$aria",
369
+ function ($aria) {
370
+ return function (scope, elem, attr) {
371
+ if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
372
+ return;
373
+
374
+ if (
375
+ $aria.config("tabindex") &&
376
+ !elem.attr("tabindex") &&
377
+ !isNodeOneOf(elem, nativeAriaNodeNames)
378
+ ) {
379
+ elem.attr("tabindex", 0);
380
+ }
381
+ };
382
+ },
383
+ ]);
384
+ }
385
+
386
+ /**
387
+ * Internal Utilities
388
+ */
389
+ const nativeAriaNodeNames = [
390
+ "BUTTON",
391
+ "A",
392
+ "INPUT",
393
+ "TEXTAREA",
394
+ "SELECT",
395
+ "DETAILS",
396
+ "SUMMARY",
397
+ ];
398
+
399
+ const isNodeOneOf = function (elem, nodeTypeArray) {
400
+ if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
401
+ return true;
402
+ }
403
+ };
404
+ /**
405
+ * @ngdoc provider
406
+ * @name $ariaProvider
407
+ *
408
+ *
409
+ * @description
410
+ *
411
+ * Used for configuring the ARIA attributes injected and managed by ngAria.
412
+ *
413
+ * ```js
414
+ * angular.module('myApp', ['ngAria'], function config($ariaProvider) {
415
+ * $ariaProvider.config({
416
+ * ariaValue: true,
417
+ * tabindex: false
418
+ * });
419
+ * });
420
+ *```
421
+ *
422
+ * ## Dependencies
423
+ * Requires the {@link ngAria} module to be installed.
424
+ *
425
+ */
426
+ function $AriaProvider() {
427
+ let config = {
428
+ ariaHidden: true,
429
+ ariaChecked: true,
430
+ ariaReadonly: true,
431
+ ariaDisabled: true,
432
+ ariaRequired: true,
433
+ ariaInvalid: true,
434
+ ariaValue: true,
435
+ tabindex: true,
436
+ bindKeydown: true,
437
+ bindRoleForClick: true,
438
+ };
439
+
440
+ /**
441
+ * @ngdoc method
442
+ * @name $ariaProvider#config
443
+ *
444
+ * @param {object} newConfig object to enable/disable specific ARIA attributes
445
+ *
446
+ * - **ariaHidden** – `{boolean}` – Enables/disables aria-hidden tags
447
+ * - **ariaChecked** – `{boolean}` – Enables/disables aria-checked tags
448
+ * - **ariaReadonly** – `{boolean}` – Enables/disables aria-readonly tags
449
+ * - **ariaDisabled** – `{boolean}` – Enables/disables aria-disabled tags
450
+ * - **ariaRequired** – `{boolean}` – Enables/disables aria-required tags
451
+ * - **ariaInvalid** – `{boolean}` – Enables/disables aria-invalid tags
452
+ * - **ariaValue** – `{boolean}` – Enables/disables aria-valuemin, aria-valuemax and
453
+ * aria-valuenow tags
454
+ * - **tabindex** – `{boolean}` – Enables/disables tabindex tags
455
+ * - **bindKeydown** – `{boolean}` – Enables/disables keyboard event binding on non-interactive
456
+ * elements (such as `div` or `li`) using ng-click, making them more accessible to users of
457
+ * assistive technologies
458
+ * - **bindRoleForClick** – `{boolean}` – Adds role=button to non-interactive elements (such as
459
+ * `div` or `li`) using ng-click, making them more accessible to users of assistive
460
+ * technologies
461
+ *
462
+ * @description
463
+ * Enables/disables various ARIA attributes
464
+ */
465
+ this.config = function (newConfig) {
466
+ config = extend(config, newConfig);
467
+ };
468
+
469
+ function watchExpr(attrName, ariaAttr, nativeAriaNodeNames, negate) {
470
+ return function (scope, elem, attr) {
471
+ if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR)) return;
472
+
473
+ const ariaCamelName = attr.$normalize(ariaAttr);
474
+ if (
475
+ config[ariaCamelName] &&
476
+ !isNodeOneOf(elem, nativeAriaNodeNames) &&
477
+ !attr[ariaCamelName]
478
+ ) {
479
+ scope.$watch(attr[attrName], (boolVal) => {
480
+ // ensure boolean value
481
+ boolVal = negate ? !boolVal : !!boolVal;
482
+ elem.attr(ariaAttr, boolVal);
483
+ });
484
+ }
485
+ };
486
+ }
487
+ /**
488
+ * @ngdoc service
489
+ * @name $aria
490
+ *
491
+ * @description
492
+ *
493
+ * The $aria service contains helper methods for applying common
494
+ * [ARIA](http://www.w3.org/TR/wai-aria/) attributes to HTML directives.
495
+ *
496
+ * ngAria injects common accessibility attributes that tell assistive technologies when HTML
497
+ * elements are enabled, selected, hidden, and more. To see how this is performed with ngAria,
498
+ * let's review a code snippet from ngAria itself:
499
+ *
500
+ *```js
501
+ * ngAriaModule.directive('ngDisabled', ['$aria', function($aria) {
502
+ * return $aria.$$watchExpr('ngDisabled', 'aria-disabled', nativeAriaNodeNames, false);
503
+ * }])
504
+ *```
505
+ * Shown above, the ngAria module creates a directive with the same signature as the
506
+ * traditional `ng-disabled` directive. But this ngAria version is dedicated to
507
+ * solely managing accessibility attributes on custom elements. The internal `$aria` service is
508
+ * used to watch the boolean attribute `ngDisabled`. If it has not been explicitly set by the
509
+ * developer, `aria-disabled` is injected as an attribute with its value synchronized to the
510
+ * value in `ngDisabled`.
511
+ *
512
+ * Because ngAria hooks into the `ng-disabled` directive, developers do not have to do
513
+ * anything to enable this feature. The `aria-disabled` attribute is automatically managed
514
+ * simply as a silent side-effect of using `ng-disabled` with the ngAria module.
515
+ *
516
+ * The full list of directives that interface with ngAria:
517
+ * * **ngModel**
518
+ * * **ngChecked**
519
+ * * **ngReadonly**
520
+ * * **ngRequired**
521
+ * * **ngDisabled**
522
+ * * **ngValue**
523
+ * * **ngShow**
524
+ * * **ngHide**
525
+ * * **ngClick**
526
+ * * **ngDblclick**
527
+ * * **ngMessages**
528
+ *
529
+ * Read the {@link guide/accessibility ngAria Developer Guide} for a thorough explanation of each
530
+ * directive.
531
+ *
532
+ *
533
+ * ## Dependencies
534
+ * Requires the {@link ngAria} module to be installed.
535
+ */
536
+ this.$get = function () {
537
+ return {
538
+ config(key) {
539
+ return config[key];
540
+ },
541
+ $$watchExpr: watchExpr,
542
+ };
543
+ };
544
+ }