@angular-wave/angular.ts 0.3.0 → 0.3.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 (93) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-cache.js +1 -1
  5. package/src/animations/animate-css-driver.js +2 -2
  6. package/src/animations/animate-css.js +1 -1
  7. package/src/animations/animate-js-driver.js +2 -2
  8. package/src/animations/animate-js.js +2 -2
  9. package/src/animations/animate-queue.js +2 -2
  10. package/src/animations/animation.js +1 -1
  11. package/src/core/cache/cache-factory.js +18 -2
  12. package/src/core/compile/compile.js +9 -11
  13. package/src/core/compile/compile.spec.js +0 -1
  14. package/src/core/controller/controller.js +1 -1
  15. package/src/core/exception-handler.js +1 -1
  16. package/src/core/filter/filter.js +2 -2
  17. package/src/core/interpolate/interpolate.js +3 -3
  18. package/src/core/interval/interval-factory.js +1 -1
  19. package/src/core/interval/interval.js +1 -1
  20. package/src/core/location/location.js +1 -1
  21. package/src/core/location/location.spec.js +3 -3
  22. package/src/core/parser/parse.js +2 -2
  23. package/src/core/sce/sce.js +2 -2
  24. package/src/core/scope/scope.js +1 -1
  25. package/src/core/task-tracker-factory.js +1 -1
  26. package/src/core/timeout/timeout.js +3 -3
  27. package/src/directive/if/if.js +5 -5
  28. package/src/directive/script/script.js +11 -9
  29. package/src/directive/validators/validators.js +70 -42
  30. package/src/public.js +56 -60
  31. package/src/router/params/param.js +1 -2
  32. package/src/router/path/path-node.js +5 -5
  33. package/src/router/path/path-utils.js +19 -21
  34. package/src/router/state/state-builder.js +17 -11
  35. package/src/router/state/state-queue-manager.js +16 -7
  36. package/src/router/state/state-registry.js +9 -5
  37. package/src/router/state/state-service.js +4 -8
  38. package/src/router/template-factory.js +2 -2
  39. package/src/router/transition/transition-service.js +1 -1
  40. package/src/router/transition/transition.js +13 -11
  41. package/src/router/url/url-matcher.js +2 -2
  42. package/src/router/url/url-service.js +1 -1
  43. package/src/router/view/view.js +3 -3
  44. package/src/services/http/http.js +2 -82
  45. package/src/services/http/http.spec.js +0 -118
  46. package/src/services/http/template-request.spec.js +10 -12
  47. package/src/services/http-backend/http-backend.js +1 -1
  48. package/src/services/log.js +1 -1
  49. package/src/services/template-request.js +3 -3
  50. package/src/shared/common.js +3 -9
  51. package/src/shared/hof.js +6 -8
  52. package/src/types.js +0 -14
  53. package/types/animations/animate-cache.d.ts +2 -2
  54. package/types/animations/animate-css-driver.d.ts +3 -3
  55. package/types/animations/animate-css.d.ts +2 -2
  56. package/types/animations/animate-js-driver.d.ts +3 -3
  57. package/types/animations/animate-js.d.ts +3 -3
  58. package/types/animations/animate-queue.d.ts +3 -3
  59. package/types/animations/animation.d.ts +2 -2
  60. package/types/core/cache/cache-factory.d.ts +20 -2
  61. package/types/core/compile/attributes.d.ts +1 -1
  62. package/types/core/compile/compile.d.ts +11 -11
  63. package/types/core/controller/controller.d.ts +1 -1
  64. package/types/core/exception-handler.d.ts +2 -3
  65. package/types/core/filter/filter.d.ts +3 -3
  66. package/types/core/interpolate/interpolate.d.ts +6 -6
  67. package/types/core/interval/interval-factory.d.ts +2 -2
  68. package/types/core/interval/interval.d.ts +2 -2
  69. package/types/core/location/location.d.ts +2 -2
  70. package/types/core/parser/parse.d.ts +4 -4
  71. package/types/core/sce/sce.d.ts +4 -4
  72. package/types/core/scope/scope.d.ts +1 -1
  73. package/types/core/task-tracker-factory.d.ts +1 -1
  74. package/types/core/timeout/timeout.d.ts +1 -2
  75. package/types/directive/script/script.d.ts +8 -5
  76. package/types/directive/validators/validators.d.ts +3 -15
  77. package/types/router/path/path-node.d.ts +0 -7
  78. package/types/router/path/path-utils.d.ts +7 -2
  79. package/types/router/state/state-queue-manager.d.ts +13 -3
  80. package/types/router/state/state-registry.d.ts +5 -2
  81. package/types/router/state/state-service.d.ts +1 -1
  82. package/types/router/template-factory.d.ts +3 -3
  83. package/types/router/transition/transition-service.d.ts +1 -1
  84. package/types/router/transition/transition.d.ts +3 -3
  85. package/types/router/url/url-service.d.ts +3 -3
  86. package/types/services/http/http.d.ts +4 -48
  87. package/types/services/http-backend/http-backend.d.ts +2 -2
  88. package/types/services/log.d.ts +2 -3
  89. package/types/services/template-request.d.ts +1 -1
  90. package/types/shared/common.d.ts +0 -5
  91. package/types/shared/hof.d.ts +0 -1
  92. package/types/types.d.ts +1 -1
  93. package/src/directive/csp.md +0 -63
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "description": "A modern, optimized and typesafe version of AngularJS",
4
4
  "license": "MIT",
5
- "version": "0.3.0",
5
+ "version": "0.3.1",
6
6
  "type": "module",
7
7
  "main": "dist/angular-ts.esm.js",
8
8
  "browser": "dist/angular-ts.umd.js",
@@ -75,6 +75,6 @@ export function animateCache() {
75
75
  };
76
76
  }
77
77
 
78
- export function $$AnimateCacheProvider() {
78
+ export function AnimateCacheProvider() {
79
79
  this.$get = [animateCache];
80
80
  }
@@ -8,8 +8,8 @@ const NG_ANIMATE_ANCHOR_CLASS_NAME = "ng-anchor";
8
8
  const NG_OUT_ANCHOR_CLASS_NAME = "ng-anchor-out";
9
9
  const NG_IN_ANCHOR_CLASS_NAME = "ng-anchor-in";
10
10
 
11
- $$AnimateCssDriverProvider.$inject = ["$$animationProvider"];
12
- export function $$AnimateCssDriverProvider($$animationProvider) {
11
+ AnimateCssDriverProvider.$inject = ["$$animationProvider"];
12
+ export function AnimateCssDriverProvider($$animationProvider) {
13
13
  $$animationProvider.drivers.push("$$animateCssDriver");
14
14
 
15
15
  function isDocumentFragment(node) {
@@ -137,7 +137,7 @@ function registerRestorableStyles(backup, node, properties) {
137
137
  });
138
138
  }
139
139
 
140
- export function $AnimateCssProvider() {
140
+ export function AnimateCssProvider() {
141
141
  this.$get = [
142
142
  "$$AnimateRunner",
143
143
  "$timeout",
@@ -1,7 +1,7 @@
1
1
  import { forEach } from "../shared/utils";
2
2
 
3
- $$AnimateJsDriverProvider.$inject = ["$$animationProvider"];
4
- export function $$AnimateJsDriverProvider($$animationProvider) {
3
+ AnimateJsDriverProvider.$inject = ["$$animationProvider"];
4
+ export function AnimateJsDriverProvider($$animationProvider) {
5
5
  $$animationProvider.drivers.push("$$animateJsDriver");
6
6
  this.$get = [
7
7
  "$$animateJs",
@@ -8,8 +8,8 @@ import {
8
8
  // TODO: use caching here to speed things up for detection
9
9
  // TODO: add documentation
10
10
 
11
- $$AnimateJsProvider.$inject = ["$animateProvider"];
12
- export function $$AnimateJsProvider($animateProvider) {
11
+ AnimateJsProvider.$inject = ["$animateProvider"];
12
+ export function AnimateJsProvider($animateProvider) {
13
13
  this.$get = [
14
14
  "$injector",
15
15
  "$$AnimateRunner",
@@ -24,8 +24,8 @@ import {
24
24
 
25
25
  const NG_ANIMATE_ATTR_NAME = "data-ng-animate";
26
26
  const NG_ANIMATE_PIN_DATA = "$ngAnimatePin";
27
- $$AnimateQueueProvider.$inject = ["$animateProvider"];
28
- export function $$AnimateQueueProvider($animateProvider) {
27
+ AnimateQueueProvider.$inject = ["$animateProvider"];
28
+ export function AnimateQueueProvider($animateProvider) {
29
29
  const PRE_DIGEST_STATE = 1;
30
30
  const RUNNING_STATE = 2;
31
31
  const ONE_SPACE = " ";
@@ -12,7 +12,7 @@ import {
12
12
  const RUNNER_STORAGE_KEY = "$$animationRunner";
13
13
  const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
14
14
 
15
- export function $$AnimationProvider() {
15
+ export function AnimationProvider() {
16
16
  const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
17
17
 
18
18
  const drivers = (this.drivers = []);
@@ -1,3 +1,19 @@
1
- export function TemplateCacheProvider() {
2
- this.$get = () => new Map();
1
+ /**
2
+ * A cache for maping template names to their respective content.
3
+ *
4
+ * @typedef {Map<string, string>} TemplateCache
5
+ */
6
+
7
+ /**
8
+ * Service responsible for providing a cache for templates.
9
+ *
10
+ * @class TemplateCacheProvider
11
+ * @description Provides an instance of a template cache that can be used to store and retrieve template content.
12
+ */
13
+ export class TemplateCacheProvider {
14
+ /**
15
+ * @description Returns a new instance of a `TemplateCache`, which is a Map used to store templates.
16
+ * @returns {TemplateCache} A new instance of the template cache (Map object).
17
+ */
18
+ $get = () => new Map();
3
19
  }
@@ -51,8 +51,8 @@ const $compileMinErr = minErr("$compile");
51
51
  const UNINITALIZED_VALIED = new Object();
52
52
  const EXCLUDED_DIRECTIVES = ["ngIf", "ngRepeat"];
53
53
 
54
- $CompileProvider.$inject = ["$provide", "$$sanitizeUriProvider"];
55
- export function $CompileProvider($provide, $$sanitizeUriProvider) {
54
+ CompileProvider.$inject = ["$provide", "$$sanitizeUriProvider"];
55
+ export function CompileProvider($provide, $$sanitizeUriProvider) {
56
56
  const hasDirectives = {};
57
57
  const Suffix = "Directive";
58
58
  const ALL_OR_NOTHING_ATTRS = {
@@ -186,7 +186,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
186
186
  * are the factories.
187
187
  * @param {Function|Array} directiveFactory An injectable directive factory function. See the
188
188
  * {@link guide/directive directive guide} and the {@link $compile compile API} for more info.
189
- * @returns {$CompileProvider} Self for chaining.
189
+ * @returns {CompileProvider} Self for chaining.
190
190
  */
191
191
  this.directive = function registerDirective(name, directiveFactory) {
192
192
  assertArg(name, "name");
@@ -282,7 +282,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
282
282
  * - `$...` – additional properties to attach to the directive factory function and the controller
283
283
  * constructor function. (This is used by the component router to annotate)
284
284
  *
285
- * @returns {$CompileProvider} the compile provider itself, for chaining of function calls.
285
+ * @returns {CompileProvider} the compile provider itself, for chaining of function calls.
286
286
  */
287
287
  this.component = function (name, options) {
288
288
  if (!isString(name)) {
@@ -362,7 +362,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
362
362
  * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.
363
363
  *
364
364
  * @param {RegExp=} regexp New regexp to trust urls with.
365
- * @returns {RegExp|$CompileProvider} Current RegExp if called without value or self for
365
+ * @returns {RegExp|CompileProvider} Current RegExp if called without value or self for
366
366
  * chaining otherwise.
367
367
  */
368
368
  this.aHrefSanitizationTrustedUrlList = function (regexp) {
@@ -385,7 +385,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
385
385
  * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.
386
386
  *
387
387
  * @param {RegExp=} regexp New regexp to trust urls with.
388
- * @returns {RegExp|$CompileProvider} Current RegExp if called without value or self for
388
+ * @returns {RegExp|CompileProvider} Current RegExp if called without value or self for
389
389
  * chaining otherwise.
390
390
  */
391
391
  this.imgSrcSanitizationTrustedUrlList = function (regexp) {
@@ -581,14 +581,12 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
581
581
 
582
582
  const startSymbol = $interpolate.startSymbol();
583
583
  const endSymbol = $interpolate.endSymbol();
584
+ /** @type {(string) => string} */
584
585
  const denormalizeTemplate =
585
586
  startSymbol === "{{" && endSymbol === "}}"
586
587
  ? (x) => x
587
- : function denormalizeTemplate(template) {
588
- return template
589
- .replace(/\{\{/g, startSymbol)
590
- .replace(/}}/g, endSymbol);
591
- };
588
+ : (x) => x.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol);
589
+
592
590
  const NG_PREFIX_BINDING = /^ng(Attr|Prop|On)([A-Z].*)$/;
593
591
  const MULTI_ELEMENT_DIR_RE = /^(.+)Start$/;
594
592
  return compile;
@@ -15166,7 +15166,6 @@ describe("$compile", () => {
15166
15166
  );
15167
15167
  initInjector("test1");
15168
15168
  $templateCache.set("baz.html", "<div>Baz</div>");
15169
- debugger;
15170
15169
  element = $compile("<trans><inner></inner></trans>")($rootScope);
15171
15170
  $rootScope.$digest();
15172
15171
 
@@ -25,7 +25,7 @@ export function identifierForController(controller, ident) {
25
25
  * This provider allows controller registration via the
26
26
  * {@link ng.$controllerProvider#register register} method.
27
27
  */
28
- export class $ControllerProvider {
28
+ export class ControllerProvider {
29
29
  constructor() {
30
30
  /**
31
31
  * @type {Map<string, Function|Object>}
@@ -52,7 +52,7 @@ export const errorHandler = (exception, cause) => {
52
52
  * @constructor
53
53
  * @this {ExceptionHandlerProvider}
54
54
  */
55
- export function $ExceptionHandlerProvider() {
55
+ export function ExceptionHandlerProvider() {
56
56
  this.$get = [
57
57
  "$log",
58
58
  /**
@@ -8,8 +8,8 @@ import {
8
8
  $IsStateFilter,
9
9
  } from "../../router/state-filters";
10
10
 
11
- $FilterProvider.$inject = ["$provide"];
12
- export function $FilterProvider($provide) {
11
+ FilterProvider.$inject = ["$provide"];
12
+ export function FilterProvider($provide) {
13
13
  const suffix = "Filter";
14
14
 
15
15
  function register(name, factory) {
@@ -40,7 +40,7 @@ function interr(text, err) {
40
40
  * security bugs!
41
41
  * </div>
42
42
  */
43
- export function $InterpolateProvider() {
43
+ export function InterpolateProvider() {
44
44
  let startSymbol = "{{";
45
45
  let endSymbol = "}}";
46
46
 
@@ -48,7 +48,7 @@ export function $InterpolateProvider() {
48
48
  * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
49
49
  *
50
50
  * @param {string=} value new value to set the starting symbol to.
51
- * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
51
+ * @returns {string|InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
52
52
  */
53
53
  this.startSymbol = function (value) {
54
54
  if (value) {
@@ -62,7 +62,7 @@ export function $InterpolateProvider() {
62
62
  * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
63
63
  *
64
64
  * @param {string=} value new value to set the ending symbol to.
65
- * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
65
+ * @returns {string|InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
66
66
  */
67
67
  this.endSymbol = function (value) {
68
68
  if (value) {
@@ -1,6 +1,6 @@
1
1
  import { isDefined, sliceArgs } from "../../shared/utils";
2
2
 
3
- export function $$IntervalFactoryProvider() {
3
+ export function $IntervalFactoryProvider() {
4
4
  this.$get = [
5
5
  "$browser",
6
6
  "$q",
@@ -13,7 +13,7 @@ const $intervalMinErr = minErr("$interval");
13
13
  */
14
14
  const intervals = new Map();
15
15
 
16
- export function $IntervalProvider() {
16
+ export function IntervalProvider() {
17
17
  this.$get = [
18
18
  "$$intervalFactory",
19
19
  // TODO Add type
@@ -544,7 +544,7 @@ export class LocationHashbangUrl extends Location {
544
544
  }
545
545
  }
546
546
 
547
- export function $LocationProvider() {
547
+ export function LocationProvider() {
548
548
  let hashPrefix = "!";
549
549
  const html5Mode = {
550
550
  enabled: false,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LocationHtml5Url,
3
3
  LocationHashbangUrl,
4
- $LocationProvider,
4
+ LocationProvider,
5
5
  } from "./location";
6
6
  import { Angular } from "../../loader";
7
7
  import { createInjector } from "../di/injector";
@@ -23,12 +23,12 @@ describe("$location", () => {
23
23
 
24
24
  describe("defaults", () => {
25
25
  it('should have hashPrefix of "!"', () => {
26
- let provider = new $LocationProvider();
26
+ let provider = new LocationProvider();
27
27
  expect(provider.hashPrefix()).toBe("!");
28
28
  });
29
29
 
30
30
  it("should not be html5 mode", () => {
31
- let provider = new $LocationProvider();
31
+ let provider = new LocationProvider();
32
32
  expect(provider.html5Mode().enabled).toBeFalse();
33
33
  });
34
34
  });
@@ -33,7 +33,7 @@ import { Parser } from "./parser";
33
33
  * @typedef {function(CompiledExpression|string|function(import('../scope/scope').Scope):any, function(any, import('../scope/scope').Scope, any):any=, boolean=): CompiledExpression} ParseService
34
34
  */
35
35
 
36
- export function $ParseProvider() {
36
+ export function ParseProvider() {
37
37
  const cache = Object.create(null);
38
38
 
39
39
  /** @type {function(any):boolean?} */
@@ -60,7 +60,7 @@ export function $ParseProvider() {
60
60
  * a valid identifier start character.
61
61
  * @param {function(any):boolean} [identifierContinue] The function that will decide whether the given character is
62
62
  * a valid identifier continue character.
63
- * @returns {$ParseProvider}
63
+ * @returns {ParseProvider}
64
64
  */
65
65
  this.setIdentifierFns = function (identifierStart, identifierContinue) {
66
66
  identStart = identifierStart;
@@ -162,7 +162,7 @@ export function adjustMatcher(matcher) {
162
162
  * of issues, like for instance attacker-controlled `ng-includes`.
163
163
  */
164
164
 
165
- export function $SceDelegateProvider() {
165
+ export function SceDelegateProvider() {
166
166
  this.SCE_CONTEXTS = SCE_CONTEXTS;
167
167
 
168
168
  // Resource URLs can also be trusted by policy.
@@ -473,7 +473,7 @@ export function $SceDelegateProvider() {
473
473
  ];
474
474
  }
475
475
 
476
- export function $SceProvider() {
476
+ export function SceProvider() {
477
477
  let enabled = true;
478
478
 
479
479
  /**
@@ -92,7 +92,7 @@ let rootScope;
92
92
  * The provider also injects runtime services to make them available to all scopes.
93
93
  *
94
94
  */
95
- export class $RootScopeProvider {
95
+ export class RootScopeProvider {
96
96
  constructor() {
97
97
  rootScope = new Scope();
98
98
  }
@@ -1,4 +1,4 @@
1
- export class $$TaskTrackerFactoryProvider {
1
+ export class TaskTrackerFactoryProvider {
2
2
  $get = [
3
3
  "$log",
4
4
  /**
@@ -3,8 +3,8 @@ import { isDefined, minErr, sliceArgs } from "../../shared/utils";
3
3
 
4
4
  const $timeoutMinErr = minErr("$timeout");
5
5
 
6
- export function $TimeoutProvider() {
7
- this.$get = [
6
+ export class TimeoutProvider {
7
+ $get = [
8
8
  "$rootScope",
9
9
  "$browser",
10
10
  "$q",
@@ -19,7 +19,7 @@ export function $TimeoutProvider() {
19
19
  * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
20
20
  * @returns
21
21
  */
22
- function ($rootScope, $browser, $q, $$q, $exceptionHandler) {
22
+ ($rootScope, $browser, $q, $$q, $exceptionHandler) => {
23
23
  const deferreds = {};
24
24
 
25
25
  /**
@@ -18,10 +18,10 @@ export function ngIfDirective($animate) {
18
18
  restrict: "A",
19
19
  /**
20
20
  *
21
- * @param {*} $scope
22
- * @param {*} $element
23
- * @param {*} $attr
24
- * @param {*} _ctrl
21
+ * @param {import("../../core/scope/scope").Scope} $scope
22
+ * @param {import("../../shared/jqlite/jqlite").JQLite} $element
23
+ * @param {import("../../core/compile/attributes").Attributes} $attr
24
+ * @param {Object} _ctrl
25
25
  * @param {*} $transclude
26
26
  */
27
27
  link($scope, $element, $attr, _ctrl, $transclude) {
@@ -32,7 +32,7 @@ export function ngIfDirective($animate) {
32
32
  let childScope;
33
33
  /** @type {import("../../shared/jqlite/jqlite").JQLite} */
34
34
  let previousElements;
35
- $scope.$watch($attr.ngIf, (value) => {
35
+ $scope.$watch($attr["ngIf"], (value) => {
36
36
  if (value) {
37
37
  if (!childScope) {
38
38
  $transclude((clone, newScope) => {
@@ -1,15 +1,17 @@
1
- export const scriptDirective = [
2
- "$templateCache",
3
- ($templateCache) => ({
1
+ scriptDirective.$inject = ["$templateCache"];
2
+
3
+ /**
4
+ * @param {import('../../core/cache/cache-factory').TemplateCache} $templateCache
5
+ * @returns {import('../../types').Directive}
6
+ */
7
+ export function scriptDirective($templateCache) {
8
+ return {
4
9
  restrict: "E",
5
10
  terminal: true,
6
11
  compile(element, attr) {
7
12
  if (attr.type === "text/ng-template") {
8
- const templateUrl = attr.id;
9
- const { text } = element[0];
10
-
11
- $templateCache.set(templateUrl, text);
13
+ $templateCache.set(attr.id, element[0].text);
12
14
  }
13
15
  },
14
- }),
15
- ];
16
+ };
17
+ }
@@ -33,33 +33,45 @@ import { startingTag } from "../../shared/jqlite/jqlite";
33
33
  */
34
34
  export const requiredDirective = [
35
35
  "$parse",
36
+ /**
37
+ * @param {import("../../core/parser/parse.js").ParseService} $parse
38
+ * @returns {import("../../types.js").Directive}
39
+ */
36
40
  ($parse) => ({
37
41
  restrict: "A",
38
42
  require: "?ngModel",
39
- link(scope, elm, attr, ctrl) {
40
- if (!ctrl) return;
41
- // For boolean attributes like required, presence means true
42
- let value =
43
- Object.prototype.hasOwnProperty.call(attr, "required") ||
44
- $parse(attr.ngRequired)(scope);
43
+ link:
44
+ /**
45
+ * @param {import("../../core/scope/scope.js").Scope} scope
46
+ * @param {*} _elm
47
+ * @param {import("../../types.js").Attributes} attr
48
+ * @param {import("../../types.js").NgModelController} ctrl
49
+ * @returns
50
+ */
51
+ (scope, _elm, attr, ctrl) => {
52
+ if (!ctrl) return;
53
+ // For boolean attributes like required, presence means true
54
+ let value =
55
+ Object.prototype.hasOwnProperty.call(attr, "required") ||
56
+ $parse(attr.ngRequired)(scope);
45
57
 
46
- if (!attr.ngRequired) {
47
- // force truthy in case we are on non input element
48
- // (input elements do this automatically for boolean attributes like required)
49
- attr.required = true;
50
- }
58
+ if (!attr.ngRequired) {
59
+ // force truthy in case we are on non input element
60
+ // (input elements do this automatically for boolean attributes like required)
61
+ attr.required = true;
62
+ }
51
63
 
52
- ctrl.$validators.required = function (modelValue, viewValue) {
53
- return !value || !ctrl.$isEmpty(viewValue);
54
- };
64
+ ctrl.$validators.required = (_modelValue, viewValue) => {
65
+ return !value || !ctrl.$isEmpty(viewValue);
66
+ };
55
67
 
56
- attr.$observe("required", (newVal) => {
57
- if (value !== newVal) {
58
- value = newVal;
59
- ctrl.$validate();
60
- }
61
- });
62
- },
68
+ attr.$observe("required", (newVal) => {
69
+ if (value !== newVal) {
70
+ value = newVal;
71
+ ctrl.$validate();
72
+ }
73
+ });
74
+ },
63
75
  }),
64
76
  ];
65
77
 
@@ -104,11 +116,15 @@ export const requiredDirective = [
104
116
  */
105
117
  export const patternDirective = [
106
118
  "$parse",
107
- function ($parse) {
119
+ /**
120
+ * @param {import("../../core/parser/parse.js").ParseService} $parse
121
+ * @returns {import("../../types.js").Directive}
122
+ */
123
+ ($parse) => {
108
124
  return {
109
125
  restrict: "A",
110
126
  require: "?ngModel",
111
- compile: function (tElm, tAttr) {
127
+ compile: (_Elm, tAttr) => {
112
128
  var patternExp;
113
129
  var parseFn;
114
130
 
@@ -201,30 +217,42 @@ export const patternDirective = [
201
217
  */
202
218
  export const maxlengthDirective = [
203
219
  "$parse",
220
+ /**
221
+ * @param {import("../../core/parser/parse.js").ParseService} $parse
222
+ * @returns {import("../../types.js").Directive}
223
+ */
204
224
  ($parse) => ({
205
225
  restrict: "A",
206
226
  require: "?ngModel",
207
- link(scope, elm, attr, ctrl) {
208
- if (!ctrl) return;
227
+ link:
228
+ /**
229
+ * @param {import("../../core/scope/scope.js").Scope} scope
230
+ * @param {*} _elm
231
+ * @param {import("../../types.js").Attributes} attr
232
+ * @param {import("../../types.js").NgModelController} ctrl
233
+ * @returns
234
+ */
235
+ (scope, _elm, attr, ctrl) => {
236
+ if (!ctrl) return;
209
237
 
210
- let maxlength = attr.maxlength || $parse(attr.ngMaxlength)(scope);
211
- let maxlengthParsed = parseLength(maxlength);
238
+ let maxlength = attr.maxlength || $parse(attr.ngMaxlength)(scope);
239
+ let maxlengthParsed = parseLength(maxlength);
212
240
 
213
- attr.$observe("maxlength", (value) => {
214
- if (maxlength !== value) {
215
- maxlengthParsed = parseLength(value);
216
- maxlength = value;
217
- ctrl.$validate();
218
- }
219
- });
220
- ctrl.$validators.maxlength = function (modelValue, viewValue) {
221
- return (
222
- maxlengthParsed < 0 ||
223
- ctrl.$isEmpty(viewValue) ||
224
- viewValue.length <= maxlengthParsed
225
- );
226
- };
227
- },
241
+ attr.$observe("maxlength", (value) => {
242
+ if (maxlength !== value) {
243
+ maxlengthParsed = parseLength(value);
244
+ maxlength = value;
245
+ ctrl.$validate();
246
+ }
247
+ });
248
+ ctrl.$validators.maxlength = function (modelValue, viewValue) {
249
+ return (
250
+ maxlengthParsed < 0 ||
251
+ ctrl.$isEmpty(viewValue) ||
252
+ viewValue.length <= maxlengthParsed
253
+ );
254
+ };
255
+ },
228
256
  }),
229
257
  ];
230
258