@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.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-cache.js +1 -1
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +1 -1
- package/src/animations/animate-js-driver.js +2 -2
- package/src/animations/animate-js.js +2 -2
- package/src/animations/animate-queue.js +2 -2
- package/src/animations/animation.js +1 -1
- package/src/core/cache/cache-factory.js +18 -2
- package/src/core/compile/compile.js +9 -11
- package/src/core/compile/compile.spec.js +0 -1
- package/src/core/controller/controller.js +1 -1
- package/src/core/exception-handler.js +1 -1
- package/src/core/filter/filter.js +2 -2
- package/src/core/interpolate/interpolate.js +3 -3
- package/src/core/interval/interval-factory.js +1 -1
- package/src/core/interval/interval.js +1 -1
- package/src/core/location/location.js +1 -1
- package/src/core/location/location.spec.js +3 -3
- package/src/core/parser/parse.js +2 -2
- package/src/core/sce/sce.js +2 -2
- package/src/core/scope/scope.js +1 -1
- package/src/core/task-tracker-factory.js +1 -1
- package/src/core/timeout/timeout.js +3 -3
- package/src/directive/if/if.js +5 -5
- package/src/directive/script/script.js +11 -9
- package/src/directive/validators/validators.js +70 -42
- package/src/public.js +56 -60
- package/src/router/params/param.js +1 -2
- package/src/router/path/path-node.js +5 -5
- package/src/router/path/path-utils.js +19 -21
- package/src/router/state/state-builder.js +17 -11
- package/src/router/state/state-queue-manager.js +16 -7
- package/src/router/state/state-registry.js +9 -5
- package/src/router/state/state-service.js +4 -8
- package/src/router/template-factory.js +2 -2
- package/src/router/transition/transition-service.js +1 -1
- package/src/router/transition/transition.js +13 -11
- package/src/router/url/url-matcher.js +2 -2
- package/src/router/url/url-service.js +1 -1
- package/src/router/view/view.js +3 -3
- package/src/services/http/http.js +2 -82
- package/src/services/http/http.spec.js +0 -118
- package/src/services/http/template-request.spec.js +10 -12
- package/src/services/http-backend/http-backend.js +1 -1
- package/src/services/log.js +1 -1
- package/src/services/template-request.js +3 -3
- package/src/shared/common.js +3 -9
- package/src/shared/hof.js +6 -8
- package/src/types.js +0 -14
- package/types/animations/animate-cache.d.ts +2 -2
- package/types/animations/animate-css-driver.d.ts +3 -3
- package/types/animations/animate-css.d.ts +2 -2
- package/types/animations/animate-js-driver.d.ts +3 -3
- package/types/animations/animate-js.d.ts +3 -3
- package/types/animations/animate-queue.d.ts +3 -3
- package/types/animations/animation.d.ts +2 -2
- package/types/core/cache/cache-factory.d.ts +20 -2
- package/types/core/compile/attributes.d.ts +1 -1
- package/types/core/compile/compile.d.ts +11 -11
- package/types/core/controller/controller.d.ts +1 -1
- package/types/core/exception-handler.d.ts +2 -3
- package/types/core/filter/filter.d.ts +3 -3
- package/types/core/interpolate/interpolate.d.ts +6 -6
- package/types/core/interval/interval-factory.d.ts +2 -2
- package/types/core/interval/interval.d.ts +2 -2
- package/types/core/location/location.d.ts +2 -2
- package/types/core/parser/parse.d.ts +4 -4
- package/types/core/sce/sce.d.ts +4 -4
- package/types/core/scope/scope.d.ts +1 -1
- package/types/core/task-tracker-factory.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +1 -2
- package/types/directive/script/script.d.ts +8 -5
- package/types/directive/validators/validators.d.ts +3 -15
- package/types/router/path/path-node.d.ts +0 -7
- package/types/router/path/path-utils.d.ts +7 -2
- package/types/router/state/state-queue-manager.d.ts +13 -3
- package/types/router/state/state-registry.d.ts +5 -2
- package/types/router/state/state-service.d.ts +1 -1
- package/types/router/template-factory.d.ts +3 -3
- package/types/router/transition/transition-service.d.ts +1 -1
- package/types/router/transition/transition.d.ts +3 -3
- package/types/router/url/url-service.d.ts +3 -3
- package/types/services/http/http.d.ts +4 -48
- package/types/services/http-backend/http-backend.d.ts +2 -2
- package/types/services/log.d.ts +2 -3
- package/types/services/template-request.d.ts +1 -1
- package/types/shared/common.d.ts +0 -5
- package/types/shared/hof.d.ts +0 -1
- package/types/types.d.ts +1 -1
- 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.
|
|
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",
|
|
@@ -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
|
-
|
|
12
|
-
export function
|
|
11
|
+
AnimateCssDriverProvider.$inject = ["$$animationProvider"];
|
|
12
|
+
export function AnimateCssDriverProvider($$animationProvider) {
|
|
13
13
|
$$animationProvider.drivers.push("$$animateCssDriver");
|
|
14
14
|
|
|
15
15
|
function isDocumentFragment(node) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { forEach } from "../shared/utils";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export function
|
|
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
|
-
|
|
12
|
-
export function
|
|
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
|
-
|
|
28
|
-
export function
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
55
|
-
export function
|
|
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 {
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
:
|
|
588
|
-
|
|
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
|
|
28
|
+
export class ControllerProvider {
|
|
29
29
|
constructor() {
|
|
30
30
|
/**
|
|
31
31
|
* @type {Map<string, Function|Object>}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
$IsStateFilter,
|
|
9
9
|
} from "../../router/state-filters";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
export function
|
|
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
|
|
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
|
|
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
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationHtml5Url,
|
|
3
3
|
LocationHashbangUrl,
|
|
4
|
-
|
|
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
|
|
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
|
|
31
|
+
let provider = new LocationProvider();
|
|
32
32
|
expect(provider.html5Mode().enabled).toBeFalse();
|
|
33
33
|
});
|
|
34
34
|
});
|
package/src/core/parser/parse.js
CHANGED
|
@@ -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
|
|
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 {
|
|
63
|
+
* @returns {ParseProvider}
|
|
64
64
|
*/
|
|
65
65
|
this.setIdentifierFns = function (identifierStart, identifierContinue) {
|
|
66
66
|
identStart = identifierStart;
|
package/src/core/sce/sce.js
CHANGED
|
@@ -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
|
|
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
|
|
476
|
+
export function SceProvider() {
|
|
477
477
|
let enabled = true;
|
|
478
478
|
|
|
479
479
|
/**
|
package/src/core/scope/scope.js
CHANGED
|
@@ -3,8 +3,8 @@ import { isDefined, minErr, sliceArgs } from "../../shared/utils";
|
|
|
3
3
|
|
|
4
4
|
const $timeoutMinErr = minErr("$timeout");
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
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
|
-
|
|
22
|
+
($rootScope, $browser, $q, $$q, $exceptionHandler) => {
|
|
23
23
|
const deferreds = {};
|
|
24
24
|
|
|
25
25
|
/**
|
package/src/directive/if/if.js
CHANGED
|
@@ -18,10 +18,10 @@ export function ngIfDirective($animate) {
|
|
|
18
18
|
restrict: "A",
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
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
|
|
35
|
+
$scope.$watch($attr["ngIf"], (value) => {
|
|
36
36
|
if (value) {
|
|
37
37
|
if (!childScope) {
|
|
38
38
|
$transclude((clone, newScope) => {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
ctrl.$validators.required = (_modelValue, viewValue) => {
|
|
65
|
+
return !value || !ctrl.$isEmpty(viewValue);
|
|
66
|
+
};
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
|
208
|
-
|
|
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
|
-
|
|
211
|
-
|
|
238
|
+
let maxlength = attr.maxlength || $parse(attr.ngMaxlength)(scope);
|
|
239
|
+
let maxlengthParsed = parseLength(maxlength);
|
|
212
240
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
|