@angular-wave/angular.ts 0.16.1 → 0.17.0
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/@types/angular.d.ts +4 -0
- package/@types/animations/animate-css-driver.d.ts +10 -2
- package/@types/animations/animate-css.d.ts +8 -14
- package/@types/animations/animation.d.ts +1 -3
- package/@types/animations/cache/animate-cache.d.ts +99 -0
- package/@types/animations/cache/interface.d.ts +17 -0
- package/@types/animations/interface.d.ts +15 -18
- package/@types/animations/raf/raf-scheduler.d.ts +37 -0
- package/@types/core/compile/interface.d.ts +36 -5
- package/@types/core/interpolate/interface.d.ts +7 -1
- package/@types/core/scope/interface.d.ts +14 -4
- package/@types/core/scope/scope.d.ts +58 -22
- package/@types/directive/form/form.d.ts +16 -4
- package/@types/directive/model/model.d.ts +6 -4
- package/@types/filters/order-by.d.ts +13 -0
- package/@types/interface.d.ts +3 -3
- package/@types/router/path/path-node.d.ts +1 -1
- package/@types/router/resolve/resolve-context.d.ts +1 -1
- package/@types/router/transition/hook-registry.d.ts +1 -1
- package/@types/router/url/url-matcher.d.ts +1 -1
- package/@types/services/sce/interface.d.ts +1 -4
- package/@types/services/sce/sce.d.ts +7 -2
- package/@types/shared/common.d.ts +100 -39
- package/@types/shared/node.d.ts +5 -5
- package/@types/shared/strings.d.ts +2 -2
- package/dist/angular-ts.esm.js +1342 -901
- package/dist/angular-ts.umd.js +1342 -901
- package/dist/angular-ts.umd.min.js +1 -1
- package/dist/angular-ts.umd.min.js.gz +0 -0
- package/dist/angular-ts.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/@types/animations/animate-cache.d.ts +0 -94
- package/@types/animations/raf-scheduler.d.ts +0 -35
package/dist/angular-ts.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Version: 0.
|
|
1
|
+
/* Version: 0.17.0 - January 10, 2026 13:15:01 */
|
|
2
2
|
const VALID_CLASS = "ng-valid";
|
|
3
3
|
const INVALID_CLASS = "ng-invalid";
|
|
4
4
|
const PRISTINE_CLASS = "ng-pristine";
|
|
@@ -25,11 +25,11 @@ const ALIASED_ATTR = {
|
|
|
25
25
|
/** @internal */
|
|
26
26
|
/** @enum {number} */
|
|
27
27
|
const NodeType = {
|
|
28
|
-
_ELEMENT_NODE: Node.ELEMENT_NODE,
|
|
29
|
-
_DOCUMENT_NODE: Node.DOCUMENT_NODE,
|
|
30
|
-
_TEXT_NODE: Node.TEXT_NODE,
|
|
31
|
-
_COMMENT_NODE: Node.COMMENT_NODE,
|
|
32
|
-
_DOCUMENT_FRAGMENT_NODE: Node.DOCUMENT_FRAGMENT_NODE,
|
|
28
|
+
_ELEMENT_NODE: 1, // Node.ELEMENT_NODE,
|
|
29
|
+
_DOCUMENT_NODE: 9, // Node.DOCUMENT_NODE,
|
|
30
|
+
_TEXT_NODE: 3, // Node.TEXT_NODE,
|
|
31
|
+
_COMMENT_NODE: 8, //Node.COMMENT_NODE,
|
|
32
|
+
_DOCUMENT_FRAGMENT_NODE: 11, // Node.DOCUMENT_FRAGMENT_NODE,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const isProxySymbol = Symbol("isProxy");
|
|
@@ -1186,20 +1186,17 @@ function mergeClasses(firstClass, secondClass) {
|
|
|
1186
1186
|
if (!firstClass && !secondClass) return "";
|
|
1187
1187
|
|
|
1188
1188
|
if (!firstClass)
|
|
1189
|
-
|
|
1190
|
-
|
|
1189
|
+
return isArray(secondClass)
|
|
1190
|
+
? secondClass.join(" ").trim()
|
|
1191
|
+
: /** @type {string} */ (secondClass);
|
|
1191
1192
|
|
|
1192
1193
|
if (!secondClass)
|
|
1193
|
-
// @ts-ignore
|
|
1194
1194
|
return isArray(firstClass) ? firstClass.join(" ").trim() : firstClass;
|
|
1195
1195
|
|
|
1196
|
-
// @ts-ignore
|
|
1197
1196
|
if (isArray(firstClass)) firstClass = normalizeStringArray(firstClass);
|
|
1198
1197
|
|
|
1199
|
-
// @ts-ignore
|
|
1200
1198
|
if (isArray(secondClass)) secondClass = normalizeStringArray(secondClass);
|
|
1201
1199
|
|
|
1202
|
-
// @ts-ignore
|
|
1203
1200
|
return `${firstClass.trim()} ${secondClass.trim()}`.trim();
|
|
1204
1201
|
}
|
|
1205
1202
|
|
|
@@ -1448,13 +1445,11 @@ const $injectTokens = {
|
|
|
1448
1445
|
_attrs: "$attrs",
|
|
1449
1446
|
_scope: "$scope",
|
|
1450
1447
|
_element: "$element",
|
|
1451
|
-
_animateCache: "$$animateCache",
|
|
1452
1448
|
_animateCssDriver: "$$animateCssDriver",
|
|
1453
1449
|
_animateJs: "$$animateJs",
|
|
1454
1450
|
_animateJsDriver: "$$animateJsDriver",
|
|
1455
1451
|
_animateQueue: "$$animateQueue",
|
|
1456
1452
|
_animation: "$$animation",
|
|
1457
|
-
_rAFScheduler: "$$rAFScheduler",
|
|
1458
1453
|
_taskTrackerFactory: "$$taskTrackerFactory",
|
|
1459
1454
|
_anchorScroll: "$anchorScroll",
|
|
1460
1455
|
_animate: "$animate",
|
|
@@ -4250,9 +4245,10 @@ function defineDirective(method, attrOverride) {
|
|
|
4250
4245
|
const attrName =
|
|
4251
4246
|
attrOverride || `ng${method.charAt(0).toUpperCase()}${method.slice(1)}`;
|
|
4252
4247
|
|
|
4253
|
-
const directive =
|
|
4248
|
+
const directive = /** @type {ng.DirectiveFactory & Function} */ (
|
|
4249
|
+
createHttpDirective(method, attrName)
|
|
4250
|
+
);
|
|
4254
4251
|
|
|
4255
|
-
// @ts-ignore
|
|
4256
4252
|
directive.$inject = [
|
|
4257
4253
|
$injectTokens._http,
|
|
4258
4254
|
$injectTokens._compile,
|
|
@@ -4354,9 +4350,9 @@ function createHttpDirective(method, attrName) {
|
|
|
4354
4350
|
element.name.length > 0
|
|
4355
4351
|
) {
|
|
4356
4352
|
if (
|
|
4357
|
-
element
|
|
4358
|
-
element
|
|
4359
|
-
element
|
|
4353
|
+
isInstanceOf(element, HTMLInputElement) ||
|
|
4354
|
+
isInstanceOf(element, HTMLTextAreaElement) ||
|
|
4355
|
+
isInstanceOf(element, HTMLSelectElement)
|
|
4360
4356
|
) {
|
|
4361
4357
|
const key = element.name;
|
|
4362
4358
|
|
|
@@ -5886,9 +5882,6 @@ const SCE_CONTEXTS = {
|
|
|
5886
5882
|
// code. (e.g. ng-include, script src binding, templateUrl)
|
|
5887
5883
|
// A value that can be trusted as a RESOURCE_URL, can also trusted as a URL and a MEDIA_URL.
|
|
5888
5884
|
RESOURCE_URL: "resourceUrl",
|
|
5889
|
-
|
|
5890
|
-
// Script. Currently unused in AngularTS.
|
|
5891
|
-
JS: "js",
|
|
5892
5885
|
};
|
|
5893
5886
|
|
|
5894
5887
|
// Copied from:
|
|
@@ -6158,7 +6151,7 @@ class SceDelegateProvider {
|
|
|
6158
6151
|
|
|
6159
6152
|
function generateHolderType(Base) {
|
|
6160
6153
|
const holderType = function TrustedValueHolderType(trustedValue) {
|
|
6161
|
-
this
|
|
6154
|
+
this._unwrapTrustedValue = function () {
|
|
6162
6155
|
return trustedValue;
|
|
6163
6156
|
};
|
|
6164
6157
|
};
|
|
@@ -6167,10 +6160,10 @@ class SceDelegateProvider {
|
|
|
6167
6160
|
holderType.prototype = new Base();
|
|
6168
6161
|
}
|
|
6169
6162
|
holderType.prototype.valueOf = function sceValueOf() {
|
|
6170
|
-
return this
|
|
6163
|
+
return this._unwrapTrustedValue();
|
|
6171
6164
|
};
|
|
6172
6165
|
holderType.prototype.toString = function sceToString() {
|
|
6173
|
-
return this
|
|
6166
|
+
return this._unwrapTrustedValue().toString();
|
|
6174
6167
|
};
|
|
6175
6168
|
|
|
6176
6169
|
return holderType;
|
|
@@ -6214,7 +6207,8 @@ class SceDelegateProvider {
|
|
|
6214
6207
|
* @return {*} A trusted representation of value, that can be used in the given context.
|
|
6215
6208
|
*/
|
|
6216
6209
|
function trustAs(type, trustedValue) {
|
|
6217
|
-
const Constructor =
|
|
6210
|
+
const Constructor =
|
|
6211
|
+
isDefined(type) && hasOwn(byType, type) ? byType[type] : null;
|
|
6218
6212
|
|
|
6219
6213
|
if (!Constructor) {
|
|
6220
6214
|
$exceptionHandler(
|
|
@@ -6272,7 +6266,7 @@ class SceDelegateProvider {
|
|
|
6272
6266
|
*/
|
|
6273
6267
|
function valueOf(maybeTrusted) {
|
|
6274
6268
|
if (maybeTrusted instanceof trustedValueHolderBase) {
|
|
6275
|
-
return maybeTrusted
|
|
6269
|
+
return maybeTrusted._unwrapTrustedValue();
|
|
6276
6270
|
}
|
|
6277
6271
|
|
|
6278
6272
|
return maybeTrusted;
|
|
@@ -6321,13 +6315,13 @@ class SceDelegateProvider {
|
|
|
6321
6315
|
// If maybeTrusted is a trusted class instance or subclass instance, then unwrap and return
|
|
6322
6316
|
// as-is.
|
|
6323
6317
|
if (constructor && maybeTrusted instanceof constructor) {
|
|
6324
|
-
return maybeTrusted
|
|
6318
|
+
return maybeTrusted._unwrapTrustedValue();
|
|
6325
6319
|
}
|
|
6326
6320
|
|
|
6327
6321
|
// If maybeTrusted is a trusted class instance but not of the correct trusted type
|
|
6328
6322
|
// then unwrap it and allow it to pass through to the rest of the checks
|
|
6329
|
-
if (isFunction(maybeTrusted
|
|
6330
|
-
maybeTrusted = maybeTrusted
|
|
6323
|
+
if (isFunction(maybeTrusted._unwrapTrustedValue)) {
|
|
6324
|
+
maybeTrusted = maybeTrusted._unwrapTrustedValue();
|
|
6331
6325
|
}
|
|
6332
6326
|
|
|
6333
6327
|
// If we get here, then we will either sanitize the value or throw an exception.
|
|
@@ -6396,8 +6390,8 @@ function SceProvider() {
|
|
|
6396
6390
|
/**
|
|
6397
6391
|
*
|
|
6398
6392
|
* @param {ng.ParseService} $parse
|
|
6399
|
-
* @param $sceDelegate
|
|
6400
|
-
* @return {
|
|
6393
|
+
* @param {ng.SCEDelegateService} $sceDelegate
|
|
6394
|
+
* @return {ng.SCEService}
|
|
6401
6395
|
*/
|
|
6402
6396
|
($parse, $sceDelegate) => {
|
|
6403
6397
|
const sce = shallowCopy(SCE_CONTEXTS);
|
|
@@ -6653,7 +6647,7 @@ function SceProvider() {
|
|
|
6653
6647
|
};
|
|
6654
6648
|
});
|
|
6655
6649
|
|
|
6656
|
-
return sce;
|
|
6650
|
+
return /** @type {ng.SCEService} */ (sce);
|
|
6657
6651
|
},
|
|
6658
6652
|
];
|
|
6659
6653
|
}
|
|
@@ -7872,24 +7866,24 @@ class CompileProvider {
|
|
|
7872
7866
|
}
|
|
7873
7867
|
|
|
7874
7868
|
options = options || {};
|
|
7875
|
-
let {
|
|
7869
|
+
let { _parentBoundTranscludeFn } = options;
|
|
7876
7870
|
|
|
7877
|
-
const { transcludeControllers,
|
|
7871
|
+
const { transcludeControllers, _futureParentElement } = options;
|
|
7878
7872
|
|
|
7879
|
-
// When `
|
|
7873
|
+
// When `_parentBoundTranscludeFn` is passed, it is a
|
|
7880
7874
|
// `controllersBoundTransclude` function (it was previously passed
|
|
7881
7875
|
// as `transclude` to directive.link) so we must unwrap it to get
|
|
7882
7876
|
// its `boundTranscludeFn`
|
|
7883
7877
|
if (
|
|
7884
|
-
|
|
7885
|
-
|
|
7878
|
+
_parentBoundTranscludeFn &&
|
|
7879
|
+
_parentBoundTranscludeFn._boundTransclude
|
|
7886
7880
|
) {
|
|
7887
|
-
|
|
7888
|
-
|
|
7881
|
+
_parentBoundTranscludeFn =
|
|
7882
|
+
_parentBoundTranscludeFn._boundTransclude;
|
|
7889
7883
|
}
|
|
7890
7884
|
|
|
7891
7885
|
if (!namespace) {
|
|
7892
|
-
namespace = detectNamespaceForChildElements(
|
|
7886
|
+
namespace = detectNamespaceForChildElements(_futureParentElement);
|
|
7893
7887
|
}
|
|
7894
7888
|
/** @type {NodeRef} */
|
|
7895
7889
|
let $linkNode;
|
|
@@ -7931,7 +7925,7 @@ class CompileProvider {
|
|
|
7931
7925
|
}
|
|
7932
7926
|
|
|
7933
7927
|
if (compositeLinkFn) {
|
|
7934
|
-
compositeLinkFn(scope, $linkNode,
|
|
7928
|
+
compositeLinkFn(scope, $linkNode, _parentBoundTranscludeFn);
|
|
7935
7929
|
}
|
|
7936
7930
|
|
|
7937
7931
|
if (!cloneConnectFn) {
|
|
@@ -8066,9 +8060,9 @@ class CompileProvider {
|
|
|
8066
8060
|
*
|
|
8067
8061
|
* @param {ng.Scope} scope
|
|
8068
8062
|
* @param {NodeRef} nodeRef
|
|
8069
|
-
* @param {*} [
|
|
8063
|
+
* @param {*} [_parentBoundTranscludeFn]
|
|
8070
8064
|
*/
|
|
8071
|
-
function compositeLinkFn(scope, nodeRef,
|
|
8065
|
+
function compositeLinkFn(scope, nodeRef, _parentBoundTranscludeFn) {
|
|
8072
8066
|
assertArg(nodeRef, "nodeRef");
|
|
8073
8067
|
let stableNodeList = [];
|
|
8074
8068
|
|
|
@@ -8115,14 +8109,14 @@ class CompileProvider {
|
|
|
8115
8109
|
childBoundTranscludeFn = createBoundTranscludeFn(
|
|
8116
8110
|
scope,
|
|
8117
8111
|
nodeLinkFnCtx.transclude,
|
|
8118
|
-
|
|
8112
|
+
_parentBoundTranscludeFn,
|
|
8119
8113
|
);
|
|
8120
8114
|
} else if (
|
|
8121
8115
|
!nodeLinkFnCtx.templateOnThisElement &&
|
|
8122
|
-
|
|
8116
|
+
_parentBoundTranscludeFn
|
|
8123
8117
|
) {
|
|
8124
|
-
childBoundTranscludeFn =
|
|
8125
|
-
} else if (!
|
|
8118
|
+
childBoundTranscludeFn = _parentBoundTranscludeFn;
|
|
8119
|
+
} else if (!_parentBoundTranscludeFn && transcludeFn) {
|
|
8126
8120
|
childBoundTranscludeFn = createBoundTranscludeFn(
|
|
8127
8121
|
scope,
|
|
8128
8122
|
transcludeFn,
|
|
@@ -8135,9 +8129,8 @@ class CompileProvider {
|
|
|
8135
8129
|
if (nodeLinkFnCtx?.newScope) {
|
|
8136
8130
|
setScope(node, childScope);
|
|
8137
8131
|
}
|
|
8138
|
-
|
|
8132
|
+
|
|
8139
8133
|
nodeLinkFnCtx.nodeLinkFn(
|
|
8140
|
-
// @ts-ignore
|
|
8141
8134
|
childLinkFn,
|
|
8142
8135
|
childScope,
|
|
8143
8136
|
node,
|
|
@@ -8147,7 +8140,7 @@ class CompileProvider {
|
|
|
8147
8140
|
childLinkFn(
|
|
8148
8141
|
scope,
|
|
8149
8142
|
new NodeRef(node.childNodes),
|
|
8150
|
-
|
|
8143
|
+
_parentBoundTranscludeFn,
|
|
8151
8144
|
);
|
|
8152
8145
|
}
|
|
8153
8146
|
});
|
|
@@ -8170,18 +8163,17 @@ class CompileProvider {
|
|
|
8170
8163
|
transcludedScope,
|
|
8171
8164
|
cloneFn,
|
|
8172
8165
|
controllers,
|
|
8173
|
-
|
|
8166
|
+
_futureParentElement,
|
|
8174
8167
|
containingScope,
|
|
8175
8168
|
) {
|
|
8176
8169
|
if (!transcludedScope) {
|
|
8177
8170
|
transcludedScope = scope.$transcluded(containingScope);
|
|
8178
|
-
transcludedScope.$$transcluded = true;
|
|
8179
8171
|
}
|
|
8180
8172
|
|
|
8181
8173
|
const transcludeRes = transcludeFn(transcludedScope, cloneFn, {
|
|
8182
|
-
|
|
8174
|
+
_parentBoundTranscludeFn: previousBoundTranscludeFn,
|
|
8183
8175
|
transcludeControllers: controllers,
|
|
8184
|
-
|
|
8176
|
+
_futureParentElement,
|
|
8185
8177
|
});
|
|
8186
8178
|
|
|
8187
8179
|
return transcludeRes;
|
|
@@ -8189,13 +8181,13 @@ class CompileProvider {
|
|
|
8189
8181
|
|
|
8190
8182
|
// We need to attach the transclusion slots onto the `boundTranscludeFn`
|
|
8191
8183
|
// so that they are available inside the `controllersBoundTransclude` function
|
|
8192
|
-
const boundSlots = (boundTranscludeFn
|
|
8184
|
+
const boundSlots = (boundTranscludeFn._slots = Object.create(null));
|
|
8193
8185
|
|
|
8194
|
-
for (const slotName in transcludeFn
|
|
8195
|
-
if (transcludeFn
|
|
8186
|
+
for (const slotName in transcludeFn._slots) {
|
|
8187
|
+
if (transcludeFn._slots[slotName]) {
|
|
8196
8188
|
boundSlots[slotName] = createBoundTranscludeFn(
|
|
8197
8189
|
scope,
|
|
8198
|
-
transcludeFn
|
|
8190
|
+
transcludeFn._slots[slotName],
|
|
8199
8191
|
previousBoundTranscludeFn,
|
|
8200
8192
|
);
|
|
8201
8193
|
} else {
|
|
@@ -8447,11 +8439,11 @@ class CompileProvider {
|
|
|
8447
8439
|
let terminal = false;
|
|
8448
8440
|
|
|
8449
8441
|
let {
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8442
|
+
_newScopeDirective,
|
|
8443
|
+
_controllerDirectives,
|
|
8444
|
+
_newIsolateScopeDirective,
|
|
8445
|
+
_templateDirective,
|
|
8446
|
+
_nonTlbTranscludeDirective,
|
|
8455
8447
|
hasElementTranscludeDirective,
|
|
8456
8448
|
} = previousCompileContext;
|
|
8457
8449
|
|
|
@@ -8474,7 +8466,7 @@ class CompileProvider {
|
|
|
8474
8466
|
|
|
8475
8467
|
let replaceDirective = originalReplaceDirective;
|
|
8476
8468
|
|
|
8477
|
-
/** @type {
|
|
8469
|
+
/** @type {import("./interface.ts").ChildTranscludeOrLinkFn} */
|
|
8478
8470
|
let childTranscludeFn = transcludeFn;
|
|
8479
8471
|
|
|
8480
8472
|
let didScanForMultipleTransclusion = false;
|
|
@@ -8487,7 +8479,7 @@ class CompileProvider {
|
|
|
8487
8479
|
* Links all the directives of a single node.
|
|
8488
8480
|
* @type {ng.NodeLinkFn}
|
|
8489
8481
|
*/
|
|
8490
|
-
|
|
8482
|
+
|
|
8491
8483
|
let nodeLinkFn = function (
|
|
8492
8484
|
childLinkFn,
|
|
8493
8485
|
scope,
|
|
@@ -8530,49 +8522,49 @@ class CompileProvider {
|
|
|
8530
8522
|
|
|
8531
8523
|
controllerScope = scope;
|
|
8532
8524
|
|
|
8533
|
-
if (
|
|
8525
|
+
if (_newIsolateScopeDirective) {
|
|
8534
8526
|
isolateScope = scope.$newIsolate();
|
|
8535
|
-
} else if (
|
|
8527
|
+
} else if (_newScopeDirective) {
|
|
8536
8528
|
controllerScope = scope.$parent;
|
|
8537
8529
|
}
|
|
8538
8530
|
|
|
8539
8531
|
if (boundTranscludeFn) {
|
|
8540
8532
|
// track `boundTranscludeFn` so it can be unwrapped if `transcludeFn`
|
|
8541
|
-
// is later passed as `
|
|
8533
|
+
// is later passed as `_parentBoundTranscludeFn` to `publicLinkFn`
|
|
8542
8534
|
/** @type {any} */
|
|
8543
8535
|
const newTrancludeFn = /** @type {any} */ (
|
|
8544
8536
|
controllersBoundTransclude
|
|
8545
8537
|
);
|
|
8546
8538
|
|
|
8547
|
-
newTrancludeFn
|
|
8539
|
+
newTrancludeFn._boundTransclude = boundTranscludeFn;
|
|
8548
8540
|
// expose the slots on the `$transclude` function
|
|
8549
8541
|
newTrancludeFn.isSlotFilled = function (slotName) {
|
|
8550
|
-
return !!boundTranscludeFn
|
|
8542
|
+
return !!boundTranscludeFn._slots[slotName];
|
|
8551
8543
|
};
|
|
8552
8544
|
transcludeFn = newTrancludeFn;
|
|
8553
8545
|
}
|
|
8554
8546
|
|
|
8555
|
-
if (
|
|
8547
|
+
if (_controllerDirectives) {
|
|
8556
8548
|
elementControllers = setupControllers(
|
|
8557
8549
|
$element,
|
|
8558
8550
|
attrs,
|
|
8559
8551
|
transcludeFn,
|
|
8560
|
-
|
|
8552
|
+
_controllerDirectives,
|
|
8561
8553
|
isolateScope,
|
|
8562
8554
|
scope,
|
|
8563
|
-
|
|
8555
|
+
_newIsolateScopeDirective,
|
|
8564
8556
|
);
|
|
8565
8557
|
}
|
|
8566
8558
|
|
|
8567
|
-
if (
|
|
8568
|
-
isolateScope.$target
|
|
8569
|
-
|
|
8559
|
+
if (_newIsolateScopeDirective) {
|
|
8560
|
+
isolateScope.$target._isolateBindings =
|
|
8561
|
+
_newIsolateScopeDirective._isolateBindings;
|
|
8570
8562
|
scopeBindingInfo = initializeDirectiveBindings(
|
|
8571
8563
|
scope,
|
|
8572
8564
|
attrs,
|
|
8573
8565
|
isolateScope,
|
|
8574
|
-
isolateScope
|
|
8575
|
-
|
|
8566
|
+
isolateScope._isolateBindings,
|
|
8567
|
+
_newIsolateScopeDirective,
|
|
8576
8568
|
);
|
|
8577
8569
|
|
|
8578
8570
|
if (scopeBindingInfo.removeWatches) {
|
|
@@ -8582,11 +8574,11 @@ class CompileProvider {
|
|
|
8582
8574
|
|
|
8583
8575
|
// Initialize bindToController bindings
|
|
8584
8576
|
for (const name in elementControllers) {
|
|
8585
|
-
const controllerDirective =
|
|
8577
|
+
const controllerDirective = _controllerDirectives[name];
|
|
8586
8578
|
|
|
8587
8579
|
const controller = elementControllers[name];
|
|
8588
8580
|
|
|
8589
|
-
const bindings = controllerDirective
|
|
8581
|
+
const bindings = controllerDirective._bindings.bindToController;
|
|
8590
8582
|
|
|
8591
8583
|
// Controller instance is bound to the scope
|
|
8592
8584
|
const controllerInstance = controller();
|
|
@@ -8607,8 +8599,8 @@ class CompileProvider {
|
|
|
8607
8599
|
}
|
|
8608
8600
|
|
|
8609
8601
|
// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
|
|
8610
|
-
if (
|
|
8611
|
-
entries(
|
|
8602
|
+
if (_controllerDirectives) {
|
|
8603
|
+
entries(_controllerDirectives).forEach(
|
|
8612
8604
|
([name, controllerDirective]) => {
|
|
8613
8605
|
const { require } = controllerDirective;
|
|
8614
8606
|
|
|
@@ -8694,9 +8686,9 @@ class CompileProvider {
|
|
|
8694
8686
|
// otherwise the child elements do not belong to the isolate directive.
|
|
8695
8687
|
|
|
8696
8688
|
if (
|
|
8697
|
-
|
|
8698
|
-
(
|
|
8699
|
-
|
|
8689
|
+
_newIsolateScopeDirective &&
|
|
8690
|
+
(_newIsolateScopeDirective.template ||
|
|
8691
|
+
_newIsolateScopeDirective.templateUrl === null)
|
|
8700
8692
|
) {
|
|
8701
8693
|
scopeToChild = isolateScope;
|
|
8702
8694
|
}
|
|
@@ -8763,15 +8755,15 @@ class CompileProvider {
|
|
|
8763
8755
|
function controllersBoundTransclude(
|
|
8764
8756
|
scopeParam,
|
|
8765
8757
|
cloneAttachFn,
|
|
8766
|
-
|
|
8758
|
+
_futureParentElement,
|
|
8767
8759
|
slotName,
|
|
8768
8760
|
) {
|
|
8769
8761
|
let transcludeControllers;
|
|
8770
8762
|
|
|
8771
8763
|
// No scope passed in:
|
|
8772
8764
|
if (!isScope(scopeParam)) {
|
|
8773
|
-
slotName =
|
|
8774
|
-
|
|
8765
|
+
slotName = _futureParentElement;
|
|
8766
|
+
_futureParentElement = cloneAttachFn;
|
|
8775
8767
|
cloneAttachFn = scopeParam;
|
|
8776
8768
|
scopeParam = undefined;
|
|
8777
8769
|
}
|
|
@@ -8780,8 +8772,8 @@ class CompileProvider {
|
|
|
8780
8772
|
transcludeControllers = elementControllers;
|
|
8781
8773
|
}
|
|
8782
8774
|
|
|
8783
|
-
if (!
|
|
8784
|
-
|
|
8775
|
+
if (!_futureParentElement) {
|
|
8776
|
+
_futureParentElement = hasElementTranscludeDirective
|
|
8785
8777
|
? $element.node.parentElement
|
|
8786
8778
|
: $element.node;
|
|
8787
8779
|
}
|
|
@@ -8791,14 +8783,14 @@ class CompileProvider {
|
|
|
8791
8783
|
// * a transclude function - a filled slot
|
|
8792
8784
|
// * `null` - an optional slot that was not filled
|
|
8793
8785
|
// * `undefined` - a slot that was not declared (i.e. invalid)
|
|
8794
|
-
const slotTranscludeFn = boundTranscludeFn
|
|
8786
|
+
const slotTranscludeFn = boundTranscludeFn._slots[slotName];
|
|
8795
8787
|
|
|
8796
8788
|
if (slotTranscludeFn) {
|
|
8797
8789
|
return slotTranscludeFn(
|
|
8798
8790
|
scopeParam,
|
|
8799
8791
|
cloneAttachFn,
|
|
8800
8792
|
transcludeControllers,
|
|
8801
|
-
|
|
8793
|
+
_futureParentElement,
|
|
8802
8794
|
scopeToChild,
|
|
8803
8795
|
);
|
|
8804
8796
|
}
|
|
@@ -8819,7 +8811,7 @@ class CompileProvider {
|
|
|
8819
8811
|
scopeParam,
|
|
8820
8812
|
cloneAttachFn,
|
|
8821
8813
|
transcludeControllers,
|
|
8822
|
-
|
|
8814
|
+
_futureParentElement,
|
|
8823
8815
|
scopeToChild,
|
|
8824
8816
|
);
|
|
8825
8817
|
}
|
|
@@ -8845,24 +8837,24 @@ class CompileProvider {
|
|
|
8845
8837
|
// Check that there is no scope of any kind already
|
|
8846
8838
|
assertNoDuplicate(
|
|
8847
8839
|
"new/isolated scope",
|
|
8848
|
-
|
|
8840
|
+
_newIsolateScopeDirective || _newScopeDirective,
|
|
8849
8841
|
directive,
|
|
8850
8842
|
compileNodeRef,
|
|
8851
8843
|
);
|
|
8852
|
-
|
|
8844
|
+
_newIsolateScopeDirective = directive;
|
|
8853
8845
|
} else {
|
|
8854
8846
|
// This directive is trying to add a child scope.
|
|
8855
8847
|
// Check that there is no isolated scope already
|
|
8856
8848
|
assertNoDuplicate(
|
|
8857
8849
|
"new/isolated scope",
|
|
8858
|
-
|
|
8850
|
+
_newIsolateScopeDirective,
|
|
8859
8851
|
directive,
|
|
8860
8852
|
compileNodeRef,
|
|
8861
8853
|
);
|
|
8862
8854
|
}
|
|
8863
8855
|
}
|
|
8864
8856
|
|
|
8865
|
-
|
|
8857
|
+
_newScopeDirective = _newScopeDirective || directive;
|
|
8866
8858
|
}
|
|
8867
8859
|
|
|
8868
8860
|
directiveName = directive.name;
|
|
@@ -8908,15 +8900,15 @@ class CompileProvider {
|
|
|
8908
8900
|
}
|
|
8909
8901
|
|
|
8910
8902
|
if (!directive.templateUrl && directive.controller) {
|
|
8911
|
-
|
|
8912
|
-
|
|
8903
|
+
_controllerDirectives =
|
|
8904
|
+
_controllerDirectives || Object.create(null);
|
|
8913
8905
|
assertNoDuplicate(
|
|
8914
8906
|
`'${directiveName}' controller`,
|
|
8915
|
-
|
|
8907
|
+
_controllerDirectives[directiveName],
|
|
8916
8908
|
directive,
|
|
8917
8909
|
compileNodeRef,
|
|
8918
8910
|
);
|
|
8919
|
-
|
|
8911
|
+
_controllerDirectives[directiveName] = directive;
|
|
8920
8912
|
}
|
|
8921
8913
|
|
|
8922
8914
|
directiveValue = directive.transclude;
|
|
@@ -8930,11 +8922,11 @@ class CompileProvider {
|
|
|
8930
8922
|
if (!EXCLUDED_DIRECTIVES.includes(directive.name)) {
|
|
8931
8923
|
assertNoDuplicate(
|
|
8932
8924
|
"transclusion",
|
|
8933
|
-
|
|
8925
|
+
_nonTlbTranscludeDirective,
|
|
8934
8926
|
directive,
|
|
8935
8927
|
compileNodeRef,
|
|
8936
8928
|
);
|
|
8937
|
-
|
|
8929
|
+
_nonTlbTranscludeDirective = directive;
|
|
8938
8930
|
}
|
|
8939
8931
|
|
|
8940
8932
|
if (directiveValue === "element") {
|
|
@@ -8951,7 +8943,6 @@ class CompileProvider {
|
|
|
8951
8943
|
index,
|
|
8952
8944
|
);
|
|
8953
8945
|
|
|
8954
|
-
// @ts-ignore
|
|
8955
8946
|
childTranscludeFn = compilationGenerator(
|
|
8956
8947
|
mightHaveMultipleTransclusionError,
|
|
8957
8948
|
$template._element,
|
|
@@ -8960,13 +8951,13 @@ class CompileProvider {
|
|
|
8960
8951
|
replaceDirective && replaceDirective.name,
|
|
8961
8952
|
{
|
|
8962
8953
|
// Don't pass in:
|
|
8963
|
-
// -
|
|
8964
|
-
// -
|
|
8954
|
+
// - _controllerDirectives - otherwise we'll create duplicates controllers
|
|
8955
|
+
// - _newIsolateScopeDirective or _templateDirective - combining templates with
|
|
8965
8956
|
// element transclusion doesn't make sense.
|
|
8966
8957
|
//
|
|
8967
|
-
// We need only
|
|
8958
|
+
// We need only _nonTlbTranscludeDirective so that we prevent putting transclusion
|
|
8968
8959
|
// on the same element more than once.
|
|
8969
|
-
|
|
8960
|
+
_nonTlbTranscludeDirective,
|
|
8970
8961
|
},
|
|
8971
8962
|
);
|
|
8972
8963
|
} else {
|
|
@@ -9059,7 +9050,7 @@ class CompileProvider {
|
|
|
9059
9050
|
emptyElement(/** @type {Element} */ (compileNode)); // clear contents on transcluded directives
|
|
9060
9051
|
|
|
9061
9052
|
// lazily compile transcluded template and generate a transcluded link function
|
|
9062
|
-
|
|
9053
|
+
|
|
9063
9054
|
childTranscludeFn = compilationGenerator(
|
|
9064
9055
|
mightHaveMultipleTransclusionError,
|
|
9065
9056
|
nodes,
|
|
@@ -9071,7 +9062,9 @@ class CompileProvider {
|
|
|
9071
9062
|
directive.$$isolateScope || directive.$$newScope,
|
|
9072
9063
|
},
|
|
9073
9064
|
);
|
|
9074
|
-
|
|
9065
|
+
/** @type {import("./interface.ts").TranscludeFn} */ (
|
|
9066
|
+
childTranscludeFn
|
|
9067
|
+
)._slots = slots;
|
|
9075
9068
|
}
|
|
9076
9069
|
}
|
|
9077
9070
|
|
|
@@ -9079,11 +9072,11 @@ class CompileProvider {
|
|
|
9079
9072
|
hasTemplate = true;
|
|
9080
9073
|
assertNoDuplicate(
|
|
9081
9074
|
"template",
|
|
9082
|
-
|
|
9075
|
+
_templateDirective,
|
|
9083
9076
|
directive,
|
|
9084
9077
|
compileNodeRef,
|
|
9085
9078
|
);
|
|
9086
|
-
|
|
9079
|
+
_templateDirective = directive;
|
|
9087
9080
|
|
|
9088
9081
|
directiveValue = isFunction(directive.template)
|
|
9089
9082
|
? directive.template(compileNodeRef.node, templateAttrs)
|
|
@@ -9140,7 +9133,7 @@ class CompileProvider {
|
|
|
9140
9133
|
// - split it into two parts, those that already applied (processed) and those that weren't (unprocessed)
|
|
9141
9134
|
// - collect directives from the template and sort them by priority
|
|
9142
9135
|
// - combine directives as: processed + template + unprocessed
|
|
9143
|
-
const
|
|
9136
|
+
const _templateDirectives = collectDirectives(
|
|
9144
9137
|
/** @type {Element} */ (compileNode),
|
|
9145
9138
|
newTemplateAttrs,
|
|
9146
9139
|
);
|
|
@@ -9150,18 +9143,18 @@ class CompileProvider {
|
|
|
9150
9143
|
directives.length - (i + 1),
|
|
9151
9144
|
);
|
|
9152
9145
|
|
|
9153
|
-
if (
|
|
9146
|
+
if (_newIsolateScopeDirective || _newScopeDirective) {
|
|
9154
9147
|
// The original directive caused the current element to be replaced but this element
|
|
9155
9148
|
// also needs to have a new scope, so we need to tell the template directives
|
|
9156
9149
|
// that they would need to get their scope from further up, if they require transclusion
|
|
9157
9150
|
markDirectiveScope(
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9151
|
+
_templateDirectives,
|
|
9152
|
+
_newIsolateScopeDirective,
|
|
9153
|
+
_newScopeDirective,
|
|
9161
9154
|
);
|
|
9162
9155
|
}
|
|
9163
9156
|
directives = directives
|
|
9164
|
-
.concat(
|
|
9157
|
+
.concat(_templateDirectives)
|
|
9165
9158
|
.concat(unprocessedDirectives);
|
|
9166
9159
|
|
|
9167
9160
|
mergeTemplateAttributes(templateAttrs, newTemplateAttrs);
|
|
@@ -9178,16 +9171,16 @@ class CompileProvider {
|
|
|
9178
9171
|
hasTemplate = true;
|
|
9179
9172
|
assertNoDuplicate(
|
|
9180
9173
|
"template",
|
|
9181
|
-
|
|
9174
|
+
_templateDirective,
|
|
9182
9175
|
directive,
|
|
9183
9176
|
compileNodeRef,
|
|
9184
9177
|
);
|
|
9185
|
-
|
|
9178
|
+
_templateDirective = directive;
|
|
9186
9179
|
|
|
9187
9180
|
if (directive.replace) {
|
|
9188
9181
|
replaceDirective = directive;
|
|
9189
9182
|
}
|
|
9190
|
-
|
|
9183
|
+
|
|
9191
9184
|
nodeLinkFn = compileTemplateUrl(
|
|
9192
9185
|
directives.splice(i, directives.length - i),
|
|
9193
9186
|
compileNodeRef,
|
|
@@ -9198,14 +9191,14 @@ class CompileProvider {
|
|
|
9198
9191
|
postLinkFns,
|
|
9199
9192
|
{
|
|
9200
9193
|
index,
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
previousCompileContext.
|
|
9194
|
+
_controllerDirectives,
|
|
9195
|
+
_newScopeDirective:
|
|
9196
|
+
_newScopeDirective !== directive && _newScopeDirective,
|
|
9197
|
+
_newIsolateScopeDirective,
|
|
9198
|
+
_templateDirective,
|
|
9199
|
+
_nonTlbTranscludeDirective,
|
|
9200
|
+
_futureParentElement:
|
|
9201
|
+
previousCompileContext._futureParentElement,
|
|
9209
9202
|
},
|
|
9210
9203
|
);
|
|
9211
9204
|
ii = directives.length;
|
|
@@ -9249,7 +9242,7 @@ class CompileProvider {
|
|
|
9249
9242
|
transclude: childTranscludeFn,
|
|
9250
9243
|
transcludeOnThisElement: hasTranscludeDirective,
|
|
9251
9244
|
templateOnThisElement: hasTemplate,
|
|
9252
|
-
newScope:
|
|
9245
|
+
newScope: _newScopeDirective && _newScopeDirective.scope === true,
|
|
9253
9246
|
};
|
|
9254
9247
|
|
|
9255
9248
|
/// /////////////////
|
|
@@ -9259,7 +9252,7 @@ class CompileProvider {
|
|
|
9259
9252
|
pre.directiveName = directiveName;
|
|
9260
9253
|
|
|
9261
9254
|
if (
|
|
9262
|
-
|
|
9255
|
+
_newIsolateScopeDirective === directive ||
|
|
9263
9256
|
directive.$$isolateScope
|
|
9264
9257
|
) {
|
|
9265
9258
|
pre = cloneAndAnnotateFn(pre, { isolateScope: true });
|
|
@@ -9272,7 +9265,7 @@ class CompileProvider {
|
|
|
9272
9265
|
post.directiveName = directiveName;
|
|
9273
9266
|
|
|
9274
9267
|
if (
|
|
9275
|
-
|
|
9268
|
+
_newIsolateScopeDirective === directive ||
|
|
9276
9269
|
directive.$$isolateScope
|
|
9277
9270
|
) {
|
|
9278
9271
|
post = cloneAndAnnotateFn(post, { isolateScope: true });
|
|
@@ -9379,29 +9372,29 @@ class CompileProvider {
|
|
|
9379
9372
|
* @param {NodeRef} $element
|
|
9380
9373
|
* @param attrs
|
|
9381
9374
|
* @param transcludeFn
|
|
9382
|
-
* @param
|
|
9375
|
+
* @param _controllerDirectives
|
|
9383
9376
|
* @param isolateScope
|
|
9384
9377
|
* @param scope
|
|
9385
|
-
* @param
|
|
9378
|
+
* @param _newIsolateScopeDirective
|
|
9386
9379
|
* @returns {any}
|
|
9387
9380
|
*/
|
|
9388
9381
|
function setupControllers(
|
|
9389
9382
|
$element,
|
|
9390
9383
|
attrs,
|
|
9391
9384
|
transcludeFn,
|
|
9392
|
-
|
|
9385
|
+
_controllerDirectives,
|
|
9393
9386
|
isolateScope,
|
|
9394
9387
|
scope,
|
|
9395
|
-
|
|
9388
|
+
_newIsolateScopeDirective,
|
|
9396
9389
|
) {
|
|
9397
9390
|
const elementControllers = Object.create(null);
|
|
9398
9391
|
|
|
9399
|
-
for (const controllerKey in
|
|
9400
|
-
const directive =
|
|
9392
|
+
for (const controllerKey in _controllerDirectives) {
|
|
9393
|
+
const directive = _controllerDirectives[controllerKey];
|
|
9401
9394
|
|
|
9402
9395
|
const locals = {
|
|
9403
9396
|
$scope:
|
|
9404
|
-
directive ===
|
|
9397
|
+
directive === _newIsolateScopeDirective ||
|
|
9405
9398
|
directive.$$isolateScope
|
|
9406
9399
|
? isolateScope
|
|
9407
9400
|
: scope,
|
|
@@ -9487,12 +9480,12 @@ class CompileProvider {
|
|
|
9487
9480
|
maxPriority > directive.priority) &&
|
|
9488
9481
|
directive.restrict.indexOf(location) !== -1
|
|
9489
9482
|
) {
|
|
9490
|
-
if (!directive
|
|
9491
|
-
const bindings = (directive
|
|
9483
|
+
if (!directive._bindings) {
|
|
9484
|
+
const bindings = (directive._bindings =
|
|
9492
9485
|
parseDirectiveBindings(directive, directive.name));
|
|
9493
9486
|
|
|
9494
9487
|
if (isObject(bindings.isolateScope)) {
|
|
9495
|
-
directive
|
|
9488
|
+
directive._isolateBindings = bindings.isolateScope;
|
|
9496
9489
|
}
|
|
9497
9490
|
}
|
|
9498
9491
|
tDirectives.push(directive);
|
|
@@ -9658,7 +9651,7 @@ class CompileProvider {
|
|
|
9658
9651
|
previousCompileContext.index,
|
|
9659
9652
|
);
|
|
9660
9653
|
|
|
9661
|
-
const
|
|
9654
|
+
const _templateDirectives = collectDirectives(
|
|
9662
9655
|
compileNode,
|
|
9663
9656
|
tempTemplateAttrs,
|
|
9664
9657
|
);
|
|
@@ -9666,9 +9659,9 @@ class CompileProvider {
|
|
|
9666
9659
|
if (isObject(origAsyncDirective.scope)) {
|
|
9667
9660
|
// the original directive that caused the template to be loaded async required
|
|
9668
9661
|
// an isolate scope
|
|
9669
|
-
markDirectiveScope(
|
|
9662
|
+
markDirectiveScope(_templateDirectives, true);
|
|
9670
9663
|
}
|
|
9671
|
-
directives =
|
|
9664
|
+
directives = _templateDirectives.concat(directives);
|
|
9672
9665
|
|
|
9673
9666
|
mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
|
|
9674
9667
|
} else {
|
|
@@ -9840,6 +9833,10 @@ class CompileProvider {
|
|
|
9840
9833
|
}
|
|
9841
9834
|
}
|
|
9842
9835
|
|
|
9836
|
+
/**
|
|
9837
|
+
* @param {ng.Directive[]} directives
|
|
9838
|
+
* @param {string} text
|
|
9839
|
+
*/
|
|
9843
9840
|
function addTextInterpolateDirective(directives, text) {
|
|
9844
9841
|
const interpolateFn = $interpolate(text, true);
|
|
9845
9842
|
|
|
@@ -10447,7 +10444,7 @@ class CompileProvider {
|
|
|
10447
10444
|
});
|
|
10448
10445
|
} else {
|
|
10449
10446
|
parentSet(scope.$target, (lastValue = val));
|
|
10450
|
-
scope.$handler.
|
|
10447
|
+
scope.$handler._watchers
|
|
10451
10448
|
.get(attrs[attrName])
|
|
10452
10449
|
?.forEach((watchFn) => {
|
|
10453
10450
|
watchFn.listenerFn(val, scope.$target);
|
|
@@ -10722,13 +10719,16 @@ class FormController {
|
|
|
10722
10719
|
];
|
|
10723
10720
|
|
|
10724
10721
|
/**
|
|
10725
|
-
* @param {
|
|
10722
|
+
* @param {HTMLFormElement} $element
|
|
10726
10723
|
* @param {ng.Attributes} $attrs
|
|
10727
10724
|
* @param {ng.Scope} $scope
|
|
10728
10725
|
* @param {ng.AnimateService} $animate
|
|
10729
10726
|
* @param {ng.InterpolateService} $interpolate
|
|
10730
10727
|
*/
|
|
10731
10728
|
constructor($element, $attrs, $scope, $animate, $interpolate) {
|
|
10729
|
+
/** @type {boolean} */
|
|
10730
|
+
this._isAnimated = hasAnimate($element);
|
|
10731
|
+
|
|
10732
10732
|
this._controls = [];
|
|
10733
10733
|
|
|
10734
10734
|
this.$name = $interpolate($attrs.name || $attrs.ngForm || "")($scope);
|
|
@@ -11092,16 +11092,6 @@ class FormController {
|
|
|
11092
11092
|
}
|
|
11093
11093
|
}
|
|
11094
11094
|
|
|
11095
|
-
function cachedToggleClass(ctrl, className, switchValue) {
|
|
11096
|
-
if (switchValue && !ctrl._classCache[className]) {
|
|
11097
|
-
ctrl._animate.addClass(ctrl._element, className);
|
|
11098
|
-
ctrl._classCache[className] = true;
|
|
11099
|
-
} else if (!switchValue && ctrl._classCache[className]) {
|
|
11100
|
-
ctrl._animate.removeClass(ctrl._element, className);
|
|
11101
|
-
ctrl._classCache[className] = false;
|
|
11102
|
-
}
|
|
11103
|
-
}
|
|
11104
|
-
|
|
11105
11095
|
function toggleValidationCss(ctrl, validationErrorKeyParam, isValid) {
|
|
11106
11096
|
validationErrorKeyParam = validationErrorKeyParam
|
|
11107
11097
|
? `-${snakeCase(validationErrorKeyParam, "-")}`
|
|
@@ -11325,6 +11315,29 @@ const formDirectiveFactory = function (isNgForm) {
|
|
|
11325
11315
|
const formDirective = formDirectiveFactory();
|
|
11326
11316
|
const ngFormDirective = formDirectiveFactory("ngForm");
|
|
11327
11317
|
|
|
11318
|
+
/**
|
|
11319
|
+
* @param {FormController|ng.NgModelController} ctrl
|
|
11320
|
+
* @param {string} className
|
|
11321
|
+
* @param {boolean} switchValue
|
|
11322
|
+
*/
|
|
11323
|
+
function cachedToggleClass(ctrl, className, switchValue) {
|
|
11324
|
+
if (switchValue && !ctrl._classCache[className]) {
|
|
11325
|
+
if (ctrl._isAnimated) {
|
|
11326
|
+
ctrl._animate.addClass(ctrl._element, className);
|
|
11327
|
+
} else {
|
|
11328
|
+
ctrl._element.classList.add(className);
|
|
11329
|
+
}
|
|
11330
|
+
ctrl._classCache[className] = true;
|
|
11331
|
+
} else if (!switchValue && ctrl._classCache[className]) {
|
|
11332
|
+
if (ctrl._isAnimated) {
|
|
11333
|
+
ctrl._animate.removeClass(ctrl._element, className);
|
|
11334
|
+
} else {
|
|
11335
|
+
ctrl._element.classList.remove(className);
|
|
11336
|
+
}
|
|
11337
|
+
ctrl._classCache[className] = false;
|
|
11338
|
+
}
|
|
11339
|
+
}
|
|
11340
|
+
|
|
11328
11341
|
const DEFAULT_REGEXP = /(\s+|^)default(\s+|$)/;
|
|
11329
11342
|
|
|
11330
11343
|
/**
|
|
@@ -11523,7 +11536,7 @@ class NgModelController {
|
|
|
11523
11536
|
* @param {ng.Scope} $scope
|
|
11524
11537
|
* @param {ng.ExceptionHandlerService} $exceptionHandler
|
|
11525
11538
|
* @param {ng.Attributes} $attr
|
|
11526
|
-
* @param {
|
|
11539
|
+
* @param {HTMLElement} $element
|
|
11527
11540
|
* @param {ng.ParseService} $parse
|
|
11528
11541
|
* @param {ng.AnimateService} $animate
|
|
11529
11542
|
* @param {ng.InterpolateService} $interpolate
|
|
@@ -11537,6 +11550,8 @@ class NgModelController {
|
|
|
11537
11550
|
$animate,
|
|
11538
11551
|
$interpolate,
|
|
11539
11552
|
) {
|
|
11553
|
+
/** @type {boolean} */
|
|
11554
|
+
this._isAnimated = hasAnimate($element);
|
|
11540
11555
|
/** @type {any} The actual value from the control's view */
|
|
11541
11556
|
this.$viewValue = Number.NaN;
|
|
11542
11557
|
|
|
@@ -11655,25 +11670,6 @@ class NgModelController {
|
|
|
11655
11670
|
}
|
|
11656
11671
|
}
|
|
11657
11672
|
|
|
11658
|
-
function cachedToggleClass(ctrl, className, switchValue) {
|
|
11659
|
-
if (switchValue && !ctrl._classCache[className]) {
|
|
11660
|
-
if (hasAnimate(ctrl._element)) {
|
|
11661
|
-
ctrl._animate.addClass(ctrl._element, className);
|
|
11662
|
-
} else {
|
|
11663
|
-
ctrl._element.classList.add(className);
|
|
11664
|
-
}
|
|
11665
|
-
|
|
11666
|
-
ctrl._classCache[className] = true;
|
|
11667
|
-
} else if (!switchValue && ctrl._classCache[className]) {
|
|
11668
|
-
if (hasAnimate(ctrl._element)) {
|
|
11669
|
-
ctrl._animate.removeClass(ctrl._element, className);
|
|
11670
|
-
} else {
|
|
11671
|
-
ctrl._element.classList.remove(className);
|
|
11672
|
-
}
|
|
11673
|
-
ctrl._classCache[className] = false;
|
|
11674
|
-
}
|
|
11675
|
-
}
|
|
11676
|
-
|
|
11677
11673
|
function toggleValidationCss(ctrl, validationErrorKeyParam, isValid) {
|
|
11678
11674
|
validationErrorKeyParam = validationErrorKeyParam
|
|
11679
11675
|
? `-${snakeCase(validationErrorKeyParam, "-")}`
|
|
@@ -12236,7 +12232,7 @@ class NgModelController {
|
|
|
12236
12232
|
|
|
12237
12233
|
if (isNumberNaN(this.$modelValue)) {
|
|
12238
12234
|
// this.$modelValue has not been touched yet...
|
|
12239
|
-
|
|
12235
|
+
|
|
12240
12236
|
this.$modelValue = this._ngModelGet(this._scope);
|
|
12241
12237
|
}
|
|
12242
12238
|
const prevModelValue = this.$modelValue;
|
|
@@ -12820,7 +12816,7 @@ function baseInputType(_, element, attr, ctrl) {
|
|
|
12820
12816
|
// control's value is the same empty value twice in a row.
|
|
12821
12817
|
if (
|
|
12822
12818
|
ctrl.$viewValue !== value ||
|
|
12823
|
-
(value === "" && ctrl
|
|
12819
|
+
(value === "" && ctrl._hasNativeValidators)
|
|
12824
12820
|
) {
|
|
12825
12821
|
ctrl.$target.$setViewValue(value, event);
|
|
12826
12822
|
}
|
|
@@ -12836,7 +12832,7 @@ function baseInputType(_, element, attr, ctrl) {
|
|
|
12836
12832
|
// check for validity changes on various DOM events.
|
|
12837
12833
|
if (
|
|
12838
12834
|
PARTIAL_VALIDATION_TYPES[type] &&
|
|
12839
|
-
ctrl
|
|
12835
|
+
ctrl._hasNativeValidators &&
|
|
12840
12836
|
type === attr.type
|
|
12841
12837
|
) {
|
|
12842
12838
|
element.addEventListener(PARTIAL_VALIDATION_EVENTS, (ev) => {
|
|
@@ -12926,7 +12922,7 @@ function createStringDateInputType(type, regexp) {
|
|
|
12926
12922
|
}
|
|
12927
12923
|
|
|
12928
12924
|
function badInputChecker(scope, element, attr, ctrl, parserName) {
|
|
12929
|
-
const nativeValidation = (ctrl
|
|
12925
|
+
const nativeValidation = (ctrl._hasNativeValidators = isObject(
|
|
12930
12926
|
element.validity,
|
|
12931
12927
|
));
|
|
12932
12928
|
|
|
@@ -13128,7 +13124,7 @@ function rangeInputType(scope, element, attr, ctrl) {
|
|
|
13128
13124
|
numberFormatterParser(ctrl);
|
|
13129
13125
|
baseInputType(scope, element, attr, ctrl);
|
|
13130
13126
|
|
|
13131
|
-
const supportsRange = ctrl
|
|
13127
|
+
const supportsRange = ctrl._hasNativeValidators && element.type === "range";
|
|
13132
13128
|
|
|
13133
13129
|
let minVal = supportsRange ? 0 : undefined;
|
|
13134
13130
|
|
|
@@ -13566,41 +13562,41 @@ class SelectController {
|
|
|
13566
13562
|
*/
|
|
13567
13563
|
constructor($element, $scope) {
|
|
13568
13564
|
/** @type {HTMLSelectElement} */
|
|
13569
|
-
this
|
|
13565
|
+
this._element = $element;
|
|
13570
13566
|
|
|
13571
13567
|
/** @type {ng.Scope} */
|
|
13572
|
-
this
|
|
13568
|
+
this._scope = $scope;
|
|
13573
13569
|
|
|
13574
13570
|
/** @type {Object<string, any>} */
|
|
13575
|
-
this.
|
|
13571
|
+
this._selectValueMap = {};
|
|
13576
13572
|
|
|
13577
13573
|
/** @type {any} */
|
|
13578
|
-
this.
|
|
13574
|
+
this._ngModelCtrl = {};
|
|
13579
13575
|
|
|
13580
13576
|
/** @type {boolean} */
|
|
13581
|
-
this.
|
|
13577
|
+
this._multiple = false;
|
|
13582
13578
|
|
|
13583
13579
|
/** @private @type {HTMLOptionElement} */
|
|
13584
13580
|
this._unknownOption = document.createElement("option");
|
|
13585
13581
|
|
|
13586
13582
|
/** @type {boolean} */
|
|
13587
|
-
this.
|
|
13583
|
+
this._hasEmptyOption = false;
|
|
13588
13584
|
|
|
13589
13585
|
/** @type {HTMLOptionElement|undefined} */
|
|
13590
|
-
this.
|
|
13586
|
+
this._emptyOption = undefined;
|
|
13591
13587
|
|
|
13592
13588
|
/** @type {Map<any, number>} */
|
|
13593
|
-
this.
|
|
13589
|
+
this._optionsMap = new Map();
|
|
13594
13590
|
|
|
13595
13591
|
/** @type {boolean} */
|
|
13596
|
-
this.
|
|
13592
|
+
this._renderScheduled = false;
|
|
13597
13593
|
|
|
13598
13594
|
/** @type {boolean} */
|
|
13599
|
-
this.
|
|
13595
|
+
this._updateScheduled = false;
|
|
13600
13596
|
|
|
13601
13597
|
$scope.$on("$destroy", () => {
|
|
13602
13598
|
// disable unknown option so that we don't do work when the whole select is being destroyed
|
|
13603
|
-
this.
|
|
13599
|
+
this._renderUnknownOption = () => {
|
|
13604
13600
|
/* empty */
|
|
13605
13601
|
};
|
|
13606
13602
|
});
|
|
@@ -13610,27 +13606,27 @@ class SelectController {
|
|
|
13610
13606
|
* Render the unknown option when the viewValue doesn't match any options.
|
|
13611
13607
|
* @param {*} val
|
|
13612
13608
|
*/
|
|
13613
|
-
|
|
13614
|
-
const unknownVal = this.
|
|
13609
|
+
_renderUnknownOption(val) {
|
|
13610
|
+
const unknownVal = this._generateUnknownOptionValue(val);
|
|
13615
13611
|
|
|
13616
13612
|
this._unknownOption.value = unknownVal;
|
|
13617
|
-
this
|
|
13613
|
+
this._element.prepend(this._unknownOption);
|
|
13618
13614
|
this._unknownOption.selected = true;
|
|
13619
13615
|
this._unknownOption.setAttribute("selected", "selected");
|
|
13620
|
-
this
|
|
13616
|
+
this._element.value = unknownVal;
|
|
13621
13617
|
}
|
|
13622
13618
|
|
|
13623
13619
|
/**
|
|
13624
13620
|
* Update the unknown option if it's already rendered.
|
|
13625
13621
|
* @param {*} val
|
|
13626
13622
|
*/
|
|
13627
|
-
|
|
13628
|
-
const unknownVal = this.
|
|
13623
|
+
_updateUnknownOption(val) {
|
|
13624
|
+
const unknownVal = this._generateUnknownOptionValue(val);
|
|
13629
13625
|
|
|
13630
13626
|
this._unknownOption.value = unknownVal;
|
|
13631
13627
|
this._unknownOption.selected = true;
|
|
13632
13628
|
this._unknownOption.setAttribute("selected", "selected");
|
|
13633
|
-
this
|
|
13629
|
+
this._element.value = unknownVal;
|
|
13634
13630
|
}
|
|
13635
13631
|
|
|
13636
13632
|
/**
|
|
@@ -13638,7 +13634,7 @@ class SelectController {
|
|
|
13638
13634
|
* @param {*} val
|
|
13639
13635
|
* @returns {string}
|
|
13640
13636
|
*/
|
|
13641
|
-
|
|
13637
|
+
_generateUnknownOptionValue(val) {
|
|
13642
13638
|
if (isUndefined(val)) {
|
|
13643
13639
|
return `? undefined:undefined ?`;
|
|
13644
13640
|
}
|
|
@@ -13649,27 +13645,27 @@ class SelectController {
|
|
|
13649
13645
|
/**
|
|
13650
13646
|
* Remove the unknown option from the select element if it exists.
|
|
13651
13647
|
*/
|
|
13652
|
-
|
|
13648
|
+
_removeUnknownOption() {
|
|
13653
13649
|
if (this._unknownOption.parentElement) this._unknownOption.remove();
|
|
13654
13650
|
}
|
|
13655
13651
|
|
|
13656
13652
|
/**
|
|
13657
13653
|
* Select the empty option (value="") if it exists.
|
|
13658
13654
|
*/
|
|
13659
|
-
|
|
13660
|
-
if (this.
|
|
13661
|
-
this
|
|
13662
|
-
this.
|
|
13663
|
-
this.
|
|
13655
|
+
_selectEmptyOption() {
|
|
13656
|
+
if (this._emptyOption) {
|
|
13657
|
+
this._element.value = "";
|
|
13658
|
+
this._emptyOption.selected = true;
|
|
13659
|
+
this._emptyOption.setAttribute("selected", "selected");
|
|
13664
13660
|
}
|
|
13665
13661
|
}
|
|
13666
13662
|
|
|
13667
13663
|
/**
|
|
13668
13664
|
* Unselect the empty option if present.
|
|
13669
13665
|
*/
|
|
13670
|
-
|
|
13671
|
-
if (this.
|
|
13672
|
-
this.
|
|
13666
|
+
_un_selectEmptyOption() {
|
|
13667
|
+
if (this._hasEmptyOption) {
|
|
13668
|
+
this._emptyOption.selected = false;
|
|
13673
13669
|
}
|
|
13674
13670
|
}
|
|
13675
13671
|
|
|
@@ -13677,40 +13673,41 @@ class SelectController {
|
|
|
13677
13673
|
* Read the current value from the select element.
|
|
13678
13674
|
* @returns {*|null}
|
|
13679
13675
|
*/
|
|
13680
|
-
|
|
13681
|
-
const val = this
|
|
13676
|
+
_readValue() {
|
|
13677
|
+
const val = this._element.value;
|
|
13682
13678
|
|
|
13683
|
-
const realVal =
|
|
13679
|
+
const realVal =
|
|
13680
|
+
val in this._selectValueMap ? this._selectValueMap[val] : val;
|
|
13684
13681
|
|
|
13685
|
-
return this.
|
|
13682
|
+
return this._hasOption(realVal) ? realVal : null;
|
|
13686
13683
|
}
|
|
13687
13684
|
|
|
13688
13685
|
/**
|
|
13689
13686
|
* Write a value to the select control.
|
|
13690
13687
|
* @param {*} value
|
|
13691
13688
|
*/
|
|
13692
|
-
|
|
13689
|
+
_writeValue(value) {
|
|
13693
13690
|
const currentlySelectedOption =
|
|
13694
|
-
this
|
|
13691
|
+
this._element.options[this._element.selectedIndex];
|
|
13695
13692
|
|
|
13696
13693
|
if (currentlySelectedOption) currentlySelectedOption.selected = false;
|
|
13697
13694
|
|
|
13698
|
-
if (this.
|
|
13699
|
-
this.
|
|
13695
|
+
if (this._hasOption(value)) {
|
|
13696
|
+
this._removeUnknownOption();
|
|
13700
13697
|
|
|
13701
13698
|
const hashedVal = hashKey(value);
|
|
13702
13699
|
|
|
13703
|
-
this
|
|
13704
|
-
hashedVal in this.
|
|
13705
|
-
const selectedOption = this
|
|
13700
|
+
this._element.value =
|
|
13701
|
+
hashedVal in this._selectValueMap ? hashedVal : value;
|
|
13702
|
+
const selectedOption = this._element.options[this._element.selectedIndex];
|
|
13706
13703
|
|
|
13707
13704
|
if (!selectedOption) {
|
|
13708
|
-
this.
|
|
13705
|
+
this._selectUnknownOrEmptyOption(value);
|
|
13709
13706
|
} else {
|
|
13710
13707
|
selectedOption.selected = true;
|
|
13711
13708
|
}
|
|
13712
13709
|
} else {
|
|
13713
|
-
this.
|
|
13710
|
+
this._selectUnknownOrEmptyOption(value);
|
|
13714
13711
|
}
|
|
13715
13712
|
}
|
|
13716
13713
|
|
|
@@ -13719,38 +13716,38 @@ class SelectController {
|
|
|
13719
13716
|
* @param {*} value
|
|
13720
13717
|
* @param {HTMLOptionElement} element
|
|
13721
13718
|
*/
|
|
13722
|
-
|
|
13719
|
+
_addOption(value, element) {
|
|
13723
13720
|
if (element.nodeType === NodeType._COMMENT_NODE) return;
|
|
13724
13721
|
|
|
13725
13722
|
assertNotHasOwnProperty(value, '"option value"');
|
|
13726
13723
|
|
|
13727
13724
|
if (value === "") {
|
|
13728
|
-
this.
|
|
13729
|
-
this.
|
|
13725
|
+
this._hasEmptyOption = true;
|
|
13726
|
+
this._emptyOption = element;
|
|
13730
13727
|
}
|
|
13731
|
-
const count = this.
|
|
13728
|
+
const count = this._optionsMap.get(value) || 0;
|
|
13732
13729
|
|
|
13733
|
-
this.
|
|
13734
|
-
this.
|
|
13730
|
+
this._optionsMap.set(value, count + 1);
|
|
13731
|
+
this._scheduleRender();
|
|
13735
13732
|
}
|
|
13736
13733
|
|
|
13737
13734
|
/**
|
|
13738
13735
|
* Remove an option from the controller.
|
|
13739
13736
|
* @param {*} value
|
|
13740
13737
|
*/
|
|
13741
|
-
|
|
13742
|
-
const count = this.
|
|
13738
|
+
_removeOption(value) {
|
|
13739
|
+
const count = this._optionsMap.get(value);
|
|
13743
13740
|
|
|
13744
13741
|
if (count) {
|
|
13745
13742
|
if (count === 1) {
|
|
13746
|
-
this.
|
|
13743
|
+
this._optionsMap.delete(value);
|
|
13747
13744
|
|
|
13748
13745
|
if (value === "") {
|
|
13749
|
-
this.
|
|
13750
|
-
this.
|
|
13746
|
+
this._hasEmptyOption = false;
|
|
13747
|
+
this._emptyOption = undefined;
|
|
13751
13748
|
}
|
|
13752
13749
|
} else {
|
|
13753
|
-
this.
|
|
13750
|
+
this._optionsMap.set(value, count - 1);
|
|
13754
13751
|
}
|
|
13755
13752
|
}
|
|
13756
13753
|
}
|
|
@@ -13760,22 +13757,22 @@ class SelectController {
|
|
|
13760
13757
|
* @param {*} value
|
|
13761
13758
|
* @returns {boolean}
|
|
13762
13759
|
*/
|
|
13763
|
-
|
|
13764
|
-
return !!this.
|
|
13760
|
+
_hasOption(value) {
|
|
13761
|
+
return !!this._optionsMap.get(value);
|
|
13765
13762
|
}
|
|
13766
13763
|
|
|
13767
13764
|
/**
|
|
13768
13765
|
* @returns {boolean} Whether the select element currently has an empty option.
|
|
13769
13766
|
*/
|
|
13770
13767
|
$hasEmptyOption() {
|
|
13771
|
-
return this.
|
|
13768
|
+
return this._hasEmptyOption;
|
|
13772
13769
|
}
|
|
13773
13770
|
|
|
13774
13771
|
/**
|
|
13775
13772
|
* @returns {boolean} Whether the unknown option is currently selected.
|
|
13776
13773
|
*/
|
|
13777
13774
|
$isUnknownOptionSelected() {
|
|
13778
|
-
return this
|
|
13775
|
+
return this._element.options[0] === this._unknownOption;
|
|
13779
13776
|
}
|
|
13780
13777
|
|
|
13781
13778
|
/**
|
|
@@ -13783,8 +13780,8 @@ class SelectController {
|
|
|
13783
13780
|
*/
|
|
13784
13781
|
$isEmptyOptionSelected() {
|
|
13785
13782
|
return (
|
|
13786
|
-
this.
|
|
13787
|
-
this
|
|
13783
|
+
this._hasEmptyOption &&
|
|
13784
|
+
this._element.options[this._element.selectedIndex] === this._emptyOption
|
|
13788
13785
|
);
|
|
13789
13786
|
}
|
|
13790
13787
|
|
|
@@ -13792,26 +13789,26 @@ class SelectController {
|
|
|
13792
13789
|
* Select unknown or empty option depending on the value.
|
|
13793
13790
|
* @param {*} value
|
|
13794
13791
|
*/
|
|
13795
|
-
|
|
13796
|
-
if (isNullOrUndefined(value) && this.
|
|
13797
|
-
this.
|
|
13798
|
-
this.
|
|
13792
|
+
_selectUnknownOrEmptyOption(value) {
|
|
13793
|
+
if (isNullOrUndefined(value) && this._emptyOption) {
|
|
13794
|
+
this._removeUnknownOption();
|
|
13795
|
+
this._selectEmptyOption();
|
|
13799
13796
|
} else if (this._unknownOption.parentElement) {
|
|
13800
|
-
this.
|
|
13797
|
+
this._updateUnknownOption(value);
|
|
13801
13798
|
} else {
|
|
13802
|
-
this.
|
|
13799
|
+
this._renderUnknownOption(value);
|
|
13803
13800
|
}
|
|
13804
13801
|
}
|
|
13805
13802
|
|
|
13806
13803
|
/**
|
|
13807
13804
|
* Schedule a render at the end of the digest cycle.
|
|
13808
13805
|
*/
|
|
13809
|
-
|
|
13810
|
-
if (this.
|
|
13811
|
-
this.
|
|
13812
|
-
this.$
|
|
13813
|
-
this.
|
|
13814
|
-
this.
|
|
13806
|
+
_scheduleRender() {
|
|
13807
|
+
if (this._renderScheduled) return;
|
|
13808
|
+
this._renderScheduled = true;
|
|
13809
|
+
this._scope.$postUpdate(() => {
|
|
13810
|
+
this._renderScheduled = false;
|
|
13811
|
+
this._ngModelCtrl.$render();
|
|
13815
13812
|
});
|
|
13816
13813
|
}
|
|
13817
13814
|
|
|
@@ -13819,18 +13816,18 @@ class SelectController {
|
|
|
13819
13816
|
* Schedule a view value update at the end of the digest cycle.
|
|
13820
13817
|
* @param {boolean} [renderAfter=false]
|
|
13821
13818
|
*/
|
|
13822
|
-
|
|
13823
|
-
if (this.
|
|
13819
|
+
_scheduleViewValueUpdate(renderAfter = false) {
|
|
13820
|
+
if (this._updateScheduled) return;
|
|
13824
13821
|
|
|
13825
|
-
this.
|
|
13822
|
+
this._updateScheduled = true;
|
|
13826
13823
|
|
|
13827
|
-
this.$
|
|
13828
|
-
if (this
|
|
13824
|
+
this._scope.$postUpdate(() => {
|
|
13825
|
+
if (this._scope._destroyed) return;
|
|
13829
13826
|
|
|
13830
|
-
this.
|
|
13831
|
-
this.
|
|
13827
|
+
this._updateScheduled = false;
|
|
13828
|
+
this._ngModelCtrl.$setViewValue(this._readValue());
|
|
13832
13829
|
|
|
13833
|
-
if (renderAfter) this.
|
|
13830
|
+
if (renderAfter) this._ngModelCtrl.$render();
|
|
13834
13831
|
});
|
|
13835
13832
|
}
|
|
13836
13833
|
|
|
@@ -13860,37 +13857,37 @@ class SelectController {
|
|
|
13860
13857
|
const previouslySelected = optionElement.selected;
|
|
13861
13858
|
|
|
13862
13859
|
if (isDefined(hashedVal)) {
|
|
13863
|
-
this.
|
|
13864
|
-
delete this.
|
|
13860
|
+
this._removeOption(oldVal);
|
|
13861
|
+
delete this._selectValueMap[hashedVal];
|
|
13865
13862
|
removal = true;
|
|
13866
13863
|
}
|
|
13867
13864
|
|
|
13868
13865
|
hashedVal = hashKey(newVal);
|
|
13869
13866
|
oldVal = newVal;
|
|
13870
|
-
this.
|
|
13871
|
-
this.
|
|
13867
|
+
this._selectValueMap[hashedVal] = newVal;
|
|
13868
|
+
this._addOption(newVal, optionElement);
|
|
13872
13869
|
optionElement.setAttribute("value", hashedVal);
|
|
13873
13870
|
|
|
13874
13871
|
if (removal && previouslySelected) {
|
|
13875
|
-
this.
|
|
13872
|
+
this._scheduleViewValueUpdate();
|
|
13876
13873
|
}
|
|
13877
13874
|
});
|
|
13878
13875
|
} else if (interpolateValueFn) {
|
|
13879
13876
|
optionAttrs.$observe("value", (newVal) => {
|
|
13880
|
-
this.
|
|
13877
|
+
this._readValue();
|
|
13881
13878
|
let removal;
|
|
13882
13879
|
|
|
13883
13880
|
const previouslySelected = optionElement.selected;
|
|
13884
13881
|
|
|
13885
13882
|
if (isDefined(oldVal)) {
|
|
13886
|
-
this.
|
|
13883
|
+
this._removeOption(oldVal);
|
|
13887
13884
|
removal = true;
|
|
13888
13885
|
}
|
|
13889
13886
|
oldVal = newVal;
|
|
13890
|
-
this.
|
|
13887
|
+
this._addOption(newVal, optionElement);
|
|
13891
13888
|
|
|
13892
13889
|
if (removal && previouslySelected) {
|
|
13893
|
-
this.
|
|
13890
|
+
this._scheduleViewValueUpdate();
|
|
13894
13891
|
}
|
|
13895
13892
|
});
|
|
13896
13893
|
} else if (interpolateTextFn) {
|
|
@@ -13898,7 +13895,7 @@ class SelectController {
|
|
|
13898
13895
|
|
|
13899
13896
|
if (!optionAttrs.value) {
|
|
13900
13897
|
optionAttrs.$set("value", optionScope.value);
|
|
13901
|
-
this.
|
|
13898
|
+
this._addOption(optionScope.value, optionElement);
|
|
13902
13899
|
}
|
|
13903
13900
|
|
|
13904
13901
|
optionScope.$watch("value", () => {
|
|
@@ -13910,45 +13907,45 @@ class SelectController {
|
|
|
13910
13907
|
const previouslySelected = optionElement.selected;
|
|
13911
13908
|
|
|
13912
13909
|
if (oldVal !== newVal) {
|
|
13913
|
-
this.
|
|
13910
|
+
this._removeOption(oldVal);
|
|
13914
13911
|
oldVal = newVal;
|
|
13915
13912
|
}
|
|
13916
|
-
this.
|
|
13913
|
+
this._addOption(newVal, optionElement);
|
|
13917
13914
|
|
|
13918
13915
|
if (oldVal && previouslySelected) {
|
|
13919
|
-
this.
|
|
13916
|
+
this._scheduleViewValueUpdate();
|
|
13920
13917
|
}
|
|
13921
13918
|
});
|
|
13922
13919
|
} else {
|
|
13923
|
-
this.
|
|
13920
|
+
this._addOption(optionAttrs.value, optionElement);
|
|
13924
13921
|
}
|
|
13925
13922
|
|
|
13926
13923
|
optionAttrs.$observe("disabled", (newVal) => {
|
|
13927
13924
|
if (newVal === "true" || (newVal && optionElement.selected)) {
|
|
13928
|
-
if (this.
|
|
13929
|
-
this.
|
|
13925
|
+
if (this._multiple) {
|
|
13926
|
+
this._scheduleViewValueUpdate(true);
|
|
13930
13927
|
} else {
|
|
13931
|
-
this.
|
|
13932
|
-
this.
|
|
13928
|
+
this._ngModelCtrl.$setViewValue(null);
|
|
13929
|
+
this._ngModelCtrl.$render();
|
|
13933
13930
|
}
|
|
13934
13931
|
}
|
|
13935
13932
|
});
|
|
13936
13933
|
|
|
13937
13934
|
optionElement.addEventListener("$destroy", () => {
|
|
13938
|
-
const currentValue = this.
|
|
13935
|
+
const currentValue = this._readValue();
|
|
13939
13936
|
|
|
13940
13937
|
const removeValue = optionAttrs.value;
|
|
13941
13938
|
|
|
13942
|
-
this.
|
|
13943
|
-
this.
|
|
13939
|
+
this._removeOption(removeValue);
|
|
13940
|
+
this._scheduleRender();
|
|
13944
13941
|
|
|
13945
13942
|
if (
|
|
13946
|
-
(this.
|
|
13943
|
+
(this._multiple &&
|
|
13947
13944
|
currentValue &&
|
|
13948
13945
|
currentValue.indexOf(removeValue) !== -1) ||
|
|
13949
13946
|
currentValue === removeValue
|
|
13950
13947
|
) {
|
|
13951
|
-
this.
|
|
13948
|
+
this._scheduleViewValueUpdate(true);
|
|
13952
13949
|
}
|
|
13953
13950
|
});
|
|
13954
13951
|
}
|
|
@@ -13985,14 +13982,14 @@ function selectDirective() {
|
|
|
13985
13982
|
|
|
13986
13983
|
return;
|
|
13987
13984
|
}
|
|
13988
|
-
selectCtrl.
|
|
13985
|
+
selectCtrl._ngModelCtrl = ngModelCtrl;
|
|
13989
13986
|
|
|
13990
13987
|
// When the selected item(s) changes we delegate getting the value of the select control
|
|
13991
|
-
// to the `
|
|
13988
|
+
// to the `_readValue` method, which can be changed if the select can have multiple
|
|
13992
13989
|
// selected values or if the options are being generated by `ngOptions`
|
|
13993
13990
|
element.addEventListener("change", () => {
|
|
13994
|
-
selectCtrl.
|
|
13995
|
-
const viewValue = selectCtrl.
|
|
13991
|
+
selectCtrl._removeUnknownOption();
|
|
13992
|
+
const viewValue = selectCtrl._readValue();
|
|
13996
13993
|
|
|
13997
13994
|
ngModelCtrl.$setViewValue(viewValue);
|
|
13998
13995
|
});
|
|
@@ -14002,10 +13999,10 @@ function selectDirective() {
|
|
|
14002
13999
|
// we have to add an extra watch since ngModel doesn't work well with arrays - it
|
|
14003
14000
|
// doesn't trigger rendering if only an item in the array changes.
|
|
14004
14001
|
if (attr.multiple) {
|
|
14005
|
-
selectCtrl.
|
|
14002
|
+
selectCtrl._multiple = true;
|
|
14006
14003
|
|
|
14007
14004
|
// Read value now needs to check each option to see if it is selected
|
|
14008
|
-
selectCtrl.
|
|
14005
|
+
selectCtrl._readValue = function () {
|
|
14009
14006
|
const array = [];
|
|
14010
14007
|
|
|
14011
14008
|
/**
|
|
@@ -14022,8 +14019,8 @@ function selectDirective() {
|
|
|
14022
14019
|
const val = option.value;
|
|
14023
14020
|
|
|
14024
14021
|
array.push(
|
|
14025
|
-
val in selectCtrl.
|
|
14026
|
-
? selectCtrl.
|
|
14022
|
+
val in selectCtrl._selectValueMap
|
|
14023
|
+
? selectCtrl._selectValueMap[val]
|
|
14027
14024
|
: val,
|
|
14028
14025
|
);
|
|
14029
14026
|
}
|
|
@@ -14034,7 +14031,7 @@ function selectDirective() {
|
|
|
14034
14031
|
};
|
|
14035
14032
|
|
|
14036
14033
|
// Write value now needs to set the selected property of each matching option
|
|
14037
|
-
selectCtrl.
|
|
14034
|
+
selectCtrl._writeValue = function (value) {
|
|
14038
14035
|
/**
|
|
14039
14036
|
* @type {HTMLCollection}
|
|
14040
14037
|
*/
|
|
@@ -14048,7 +14045,7 @@ function selectDirective() {
|
|
|
14048
14045
|
const shouldBeSelected =
|
|
14049
14046
|
!!value &&
|
|
14050
14047
|
(includes(value, option.value) ||
|
|
14051
|
-
includes(value, selectCtrl.
|
|
14048
|
+
includes(value, selectCtrl._selectValueMap[option.value]));
|
|
14052
14049
|
|
|
14053
14050
|
const currentlySelected = option.selected;
|
|
14054
14051
|
|
|
@@ -14097,13 +14094,13 @@ function selectDirective() {
|
|
|
14097
14094
|
|
|
14098
14095
|
const selectCtrl = ctrls[0];
|
|
14099
14096
|
|
|
14100
|
-
// We delegate rendering to the `
|
|
14097
|
+
// We delegate rendering to the `_writeValue` method, which can be changed
|
|
14101
14098
|
// if the select can have multiple selected values or if the options are being
|
|
14102
14099
|
// generated by `ngOptions`.
|
|
14103
14100
|
// This must be done in the postLink fn to prevent $render to be called before
|
|
14104
14101
|
// all nodes have been linked correctly.
|
|
14105
14102
|
ngModelCtrl.$render = function () {
|
|
14106
|
-
selectCtrl.
|
|
14103
|
+
selectCtrl._writeValue(ngModelCtrl.$viewValue);
|
|
14107
14104
|
};
|
|
14108
14105
|
}
|
|
14109
14106
|
}
|
|
@@ -15006,7 +15003,14 @@ function ngRepeatDirective($animate) {
|
|
|
15006
15003
|
}
|
|
15007
15004
|
});
|
|
15008
15005
|
|
|
15009
|
-
|
|
15006
|
+
/**
|
|
15007
|
+
* @param {ng.Scope} $scope
|
|
15008
|
+
* @param {HTMLElement} $element
|
|
15009
|
+
* @param {ng.Attributes} attr
|
|
15010
|
+
* @param ctrl
|
|
15011
|
+
* @param $transclude
|
|
15012
|
+
*/
|
|
15013
|
+
function ngRepeatLink($scope, $element, attr, ctrl, $transclude) {
|
|
15010
15014
|
// Store a list of elements from previous run. This is a hash where key is the item from the
|
|
15011
15015
|
// iterator, and the value is objects with following properties.
|
|
15012
15016
|
// - scope: bound scope
|
|
@@ -15155,7 +15159,7 @@ function ngRepeatDirective($animate) {
|
|
|
15155
15159
|
$transclude(
|
|
15156
15160
|
/**
|
|
15157
15161
|
* Clone attach function
|
|
15158
|
-
* @param {
|
|
15162
|
+
* @param {HTMLElement} clone
|
|
15159
15163
|
* @param {ng.Scope} scope
|
|
15160
15164
|
*/
|
|
15161
15165
|
|
|
@@ -15166,11 +15170,9 @@ function ngRepeatDirective($animate) {
|
|
|
15166
15170
|
if (hasAnimate) {
|
|
15167
15171
|
$animate.enter(clone, null, previousNode);
|
|
15168
15172
|
} else {
|
|
15169
|
-
// @ts-ignore
|
|
15170
15173
|
previousNode.after(clone);
|
|
15171
15174
|
}
|
|
15172
15175
|
|
|
15173
|
-
// @ts-ignore
|
|
15174
15176
|
previousNode = endNode;
|
|
15175
15177
|
// Note: We only need the first/last node of the cloned nodes.
|
|
15176
15178
|
// However, we need to keep the reference to the dom wrapper as it might be changed later
|
|
@@ -15194,7 +15196,9 @@ function ngRepeatDirective($animate) {
|
|
|
15194
15196
|
},
|
|
15195
15197
|
isDefined(attr.lazy),
|
|
15196
15198
|
);
|
|
15197
|
-
}
|
|
15199
|
+
}
|
|
15200
|
+
|
|
15201
|
+
return ngRepeatLink;
|
|
15198
15202
|
},
|
|
15199
15203
|
};
|
|
15200
15204
|
}
|
|
@@ -15640,11 +15644,11 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15640
15644
|
const listFragment = document.createDocumentFragment();
|
|
15641
15645
|
|
|
15642
15646
|
// Overwrite the implementation. ngOptions doesn't use hashes
|
|
15643
|
-
selectCtrl.
|
|
15647
|
+
selectCtrl._generateUnknownOptionValue = () => "?";
|
|
15644
15648
|
|
|
15645
15649
|
// Update the controller methods for multiple selectable options
|
|
15646
15650
|
if (!multiple) {
|
|
15647
|
-
selectCtrl.
|
|
15651
|
+
selectCtrl._writeValue = function writeNgOptionsValue(value) {
|
|
15648
15652
|
// The options might not be defined yet when ngModel tries to render
|
|
15649
15653
|
if (!options) return;
|
|
15650
15654
|
|
|
@@ -15664,7 +15668,7 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15664
15668
|
// set always
|
|
15665
15669
|
|
|
15666
15670
|
if (selectElement.value !== option.selectValue) {
|
|
15667
|
-
selectCtrl.
|
|
15671
|
+
selectCtrl._removeUnknownOption();
|
|
15668
15672
|
|
|
15669
15673
|
selectElement.value = option.selectValue;
|
|
15670
15674
|
option.element.selected = true;
|
|
@@ -15672,16 +15676,16 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15672
15676
|
|
|
15673
15677
|
option.element.setAttribute("selected", "selected");
|
|
15674
15678
|
} else {
|
|
15675
|
-
selectCtrl.
|
|
15679
|
+
selectCtrl._selectUnknownOrEmptyOption(value);
|
|
15676
15680
|
}
|
|
15677
15681
|
};
|
|
15678
15682
|
|
|
15679
|
-
selectCtrl.
|
|
15683
|
+
selectCtrl._readValue = function readNgOptionsValue() {
|
|
15680
15684
|
const selectedOption = options.selectValueMap[selectElement.value];
|
|
15681
15685
|
|
|
15682
15686
|
if (selectedOption && !selectedOption.disabled) {
|
|
15683
|
-
selectCtrl.
|
|
15684
|
-
selectCtrl.
|
|
15687
|
+
selectCtrl._un_selectEmptyOption();
|
|
15688
|
+
selectCtrl._removeUnknownOption();
|
|
15685
15689
|
|
|
15686
15690
|
return options.getViewValueFromOption(selectedOption);
|
|
15687
15691
|
}
|
|
@@ -15698,7 +15702,7 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15698
15702
|
});
|
|
15699
15703
|
}
|
|
15700
15704
|
} else {
|
|
15701
|
-
selectCtrl.
|
|
15705
|
+
selectCtrl._writeValue = function writeNgOptionsMultiple(values) {
|
|
15702
15706
|
// The options might not be defined yet when ngModel tries to render
|
|
15703
15707
|
if (!options) return;
|
|
15704
15708
|
|
|
@@ -15714,18 +15718,22 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15714
15718
|
});
|
|
15715
15719
|
};
|
|
15716
15720
|
|
|
15717
|
-
selectCtrl.
|
|
15718
|
-
const selectedValues = selectElement.value || [];
|
|
15719
|
-
|
|
15721
|
+
selectCtrl._readValue = function readNgOptionsMultiple() {
|
|
15720
15722
|
const selections = [];
|
|
15721
15723
|
|
|
15722
|
-
|
|
15723
|
-
selectedValues.forEach((value) => {
|
|
15724
|
-
const option = options.selectValueMap[value];
|
|
15724
|
+
const optionsEls = selectElement.options;
|
|
15725
15725
|
|
|
15726
|
-
|
|
15727
|
-
|
|
15728
|
-
|
|
15726
|
+
for (let i = 0; i < optionsEls.length; i++) {
|
|
15727
|
+
const optionEl = optionsEls[i];
|
|
15728
|
+
|
|
15729
|
+
if (optionEl.selected) {
|
|
15730
|
+
const option = options.selectValueMap[optionEl.value];
|
|
15731
|
+
|
|
15732
|
+
if (option && !option.disabled) {
|
|
15733
|
+
selections.push(options.getViewValueFromOption(option));
|
|
15734
|
+
}
|
|
15735
|
+
}
|
|
15736
|
+
}
|
|
15729
15737
|
|
|
15730
15738
|
return selections;
|
|
15731
15739
|
};
|
|
@@ -15789,18 +15797,19 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15789
15797
|
// watchables.forEach((i) => {
|
|
15790
15798
|
// scope.$watch(i, updateOptions);
|
|
15791
15799
|
// });
|
|
15792
|
-
|
|
15800
|
+
const prop = /** @type {string} */ (
|
|
15793
15801
|
/** @type {import('../../core/parse/ast/ast-node.ts').LiteralNode} */ (
|
|
15794
15802
|
/** @type {import('../../core/parse/ast/ast-node.ts').ExpressionNode} */ (
|
|
15795
15803
|
ngOptions.getWatchables._decoratedNode.body[0]
|
|
15796
15804
|
).expression
|
|
15797
|
-
)
|
|
15798
|
-
updateOptions,
|
|
15805
|
+
)?.name
|
|
15799
15806
|
);
|
|
15800
15807
|
|
|
15808
|
+
scope.$watch(prop, updateOptions);
|
|
15809
|
+
|
|
15801
15810
|
// ------------------------------------------------------------------ //
|
|
15802
15811
|
|
|
15803
|
-
function
|
|
15812
|
+
function _addOptionElement(option, parent) {
|
|
15804
15813
|
/**
|
|
15805
15814
|
* @type {HTMLOptionElement}
|
|
15806
15815
|
*/
|
|
@@ -15840,7 +15849,7 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15840
15849
|
}
|
|
15841
15850
|
|
|
15842
15851
|
function updateOptions() {
|
|
15843
|
-
const previousValue = options && selectCtrl.
|
|
15852
|
+
const previousValue = options && selectCtrl._readValue();
|
|
15844
15853
|
|
|
15845
15854
|
// We must remove all current options, but cannot simply set innerHTML = null
|
|
15846
15855
|
// since the providedEmptyOption might have an ngIf on it that inserts comments which we
|
|
@@ -15885,10 +15894,10 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15885
15894
|
groupElementMap[option.group] = groupElement;
|
|
15886
15895
|
}
|
|
15887
15896
|
|
|
15888
|
-
|
|
15897
|
+
_addOptionElement(option, groupElement);
|
|
15889
15898
|
} else {
|
|
15890
15899
|
// This option is not in a group
|
|
15891
|
-
|
|
15900
|
+
_addOptionElement(option, listFragment);
|
|
15892
15901
|
}
|
|
15893
15902
|
});
|
|
15894
15903
|
|
|
@@ -15898,7 +15907,7 @@ function ngOptionsDirective($compile, $parse) {
|
|
|
15898
15907
|
|
|
15899
15908
|
// Check to see if the value has changed due to the update to the options
|
|
15900
15909
|
if (!ngModelCtrl.$isEmpty(previousValue)) {
|
|
15901
|
-
const nextValue = selectCtrl.
|
|
15910
|
+
const nextValue = selectCtrl._readValue();
|
|
15902
15911
|
|
|
15903
15912
|
const isNotPrimitive = ngOptions.trackBy || multiple;
|
|
15904
15913
|
|
|
@@ -16030,7 +16039,6 @@ function ngTranscludeDirective($compile) {
|
|
|
16030
16039
|
$scope,
|
|
16031
16040
|
|
|
16032
16041
|
(clone) => {
|
|
16033
|
-
// @ts-ignore
|
|
16034
16042
|
$element.append(clone);
|
|
16035
16043
|
},
|
|
16036
16044
|
);
|
|
@@ -16067,6 +16075,11 @@ BOOLEAN_ATTR.forEach((i) => {
|
|
|
16067
16075
|
// binding to multiple is not supported
|
|
16068
16076
|
if (i === "multiple") return;
|
|
16069
16077
|
|
|
16078
|
+
/**
|
|
16079
|
+
* @param {ng.Scope} scope
|
|
16080
|
+
* @param {Element} _element
|
|
16081
|
+
* @param {ng.Attributes} attr
|
|
16082
|
+
*/
|
|
16070
16083
|
function defaultLinkFn(scope, _element, attr) {
|
|
16071
16084
|
scope.$watch(attr[normalized], (value) => {
|
|
16072
16085
|
attr.$set(i, !!value);
|
|
@@ -16730,7 +16743,7 @@ function prepareAnimationOptions(options) {
|
|
|
16730
16743
|
});
|
|
16731
16744
|
|
|
16732
16745
|
animateOptions.domOperation = function () {
|
|
16733
|
-
animateOptions
|
|
16746
|
+
animateOptions._domOperationFired = true;
|
|
16734
16747
|
domOperation();
|
|
16735
16748
|
domOperation = () => {
|
|
16736
16749
|
/* empty */
|
|
@@ -17551,8 +17564,6 @@ function filterFilter() {
|
|
|
17551
17564
|
anyPropertyKey = anyPropertyKey || "$";
|
|
17552
17565
|
let predicateFn;
|
|
17553
17566
|
|
|
17554
|
-
let matchAgainstAnyProp = false;
|
|
17555
|
-
|
|
17556
17567
|
switch (getTypeForFilter(expression)) {
|
|
17557
17568
|
case "function":
|
|
17558
17569
|
predicateFn = expression;
|
|
@@ -17561,38 +17572,78 @@ function filterFilter() {
|
|
|
17561
17572
|
case "null":
|
|
17562
17573
|
case "number":
|
|
17563
17574
|
case "string":
|
|
17564
|
-
|
|
17565
|
-
|
|
17575
|
+
predicateFn = createPredicateFn(
|
|
17576
|
+
expression,
|
|
17577
|
+
comparator,
|
|
17578
|
+
anyPropertyKey,
|
|
17579
|
+
true,
|
|
17580
|
+
);
|
|
17581
|
+
break;
|
|
17582
|
+
|
|
17566
17583
|
case "object":
|
|
17567
17584
|
predicateFn = createPredicateFn(
|
|
17568
17585
|
expression,
|
|
17569
17586
|
comparator,
|
|
17570
17587
|
anyPropertyKey,
|
|
17571
|
-
|
|
17588
|
+
false,
|
|
17572
17589
|
);
|
|
17573
17590
|
break;
|
|
17591
|
+
|
|
17574
17592
|
default:
|
|
17575
17593
|
return array;
|
|
17576
17594
|
}
|
|
17577
17595
|
|
|
17578
|
-
return Array.
|
|
17596
|
+
return Array.from(array).filter(
|
|
17597
|
+
/** @type {(item: any) => boolean} */ (predicateFn),
|
|
17598
|
+
);
|
|
17579
17599
|
};
|
|
17580
17600
|
}
|
|
17581
17601
|
|
|
17582
17602
|
// Helper functions for `filterFilter`
|
|
17603
|
+
/**
|
|
17604
|
+
* Creates a predicate function that can be used with `Array.prototype.filter`
|
|
17605
|
+
* to match items against a given filter expression.
|
|
17606
|
+
*
|
|
17607
|
+
* @param {string | Object & Record<string, any> | null} expression
|
|
17608
|
+
* The filter expression to match items against. Can be:
|
|
17609
|
+
* - `string`: matched as a case-insensitive substring
|
|
17610
|
+
* - `object`: matched by property values (supports special `anyPropertyKey`)
|
|
17611
|
+
* - `null`: treated as a literal match
|
|
17612
|
+
*
|
|
17613
|
+
* @param {boolean | ((actual: any, expected: any) => boolean)} [comparator=false]
|
|
17614
|
+
* Comparator to determine equality between actual array values and expected values:
|
|
17615
|
+
* - `true` → uses strict equality (angular.equals)
|
|
17616
|
+
* - `false` (default) → performs case-insensitive substring match for primitives
|
|
17617
|
+
* - `function(actual, expected)` → custom comparator returning boolean
|
|
17618
|
+
*
|
|
17619
|
+
* @param {string} [anyPropertyKey="$"]
|
|
17620
|
+
* Special property key that allows matching against any property of an object.
|
|
17621
|
+
* Defaults to `$`.
|
|
17622
|
+
*
|
|
17623
|
+
* @param {boolean} [matchAgainstAnyProp=false]
|
|
17624
|
+
* If true, allows matching against any property in the object.
|
|
17625
|
+
* Typically true when filtering with primitive expressions.
|
|
17626
|
+
*
|
|
17627
|
+
* @returns {(item: any) => boolean}
|
|
17628
|
+
* Predicate function that returns `true` if `item` matches the expression.
|
|
17629
|
+
*/
|
|
17583
17630
|
function createPredicateFn(
|
|
17584
17631
|
expression,
|
|
17585
17632
|
comparator,
|
|
17586
17633
|
anyPropertyKey,
|
|
17587
17634
|
matchAgainstAnyProp,
|
|
17588
17635
|
) {
|
|
17636
|
+
anyPropertyKey = anyPropertyKey ?? "$";
|
|
17589
17637
|
const shouldMatchPrimitives =
|
|
17590
17638
|
isObject(expression) && anyPropertyKey in expression;
|
|
17591
17639
|
|
|
17592
17640
|
if (comparator === true) {
|
|
17593
17641
|
comparator = equals$1;
|
|
17594
17642
|
} else if (!isFunction(comparator)) {
|
|
17595
|
-
comparator = function (
|
|
17643
|
+
comparator = function (
|
|
17644
|
+
/** @type {string | any[] | null} */ actual,
|
|
17645
|
+
/** @type {string | null} */ expected,
|
|
17646
|
+
) {
|
|
17596
17647
|
if (isUndefined(actual)) {
|
|
17597
17648
|
// No substring matching against `undefined`
|
|
17598
17649
|
return false;
|
|
@@ -17618,7 +17669,7 @@ function createPredicateFn(
|
|
|
17618
17669
|
};
|
|
17619
17670
|
}
|
|
17620
17671
|
|
|
17621
|
-
const predicateFn = function (item) {
|
|
17672
|
+
const predicateFn = function (/** @type {string | Object | null} */ item) {
|
|
17622
17673
|
if (shouldMatchPrimitives && !isObject(item)) {
|
|
17623
17674
|
return deepCompare(
|
|
17624
17675
|
item,
|
|
@@ -17634,13 +17685,22 @@ function createPredicateFn(
|
|
|
17634
17685
|
expression,
|
|
17635
17686
|
comparator,
|
|
17636
17687
|
anyPropertyKey,
|
|
17637
|
-
matchAgainstAnyProp,
|
|
17688
|
+
!!matchAgainstAnyProp, // coerce undefined → false
|
|
17638
17689
|
);
|
|
17639
17690
|
};
|
|
17640
17691
|
|
|
17641
17692
|
return predicateFn;
|
|
17642
17693
|
}
|
|
17643
17694
|
|
|
17695
|
+
/**
|
|
17696
|
+
* @param {string | Object | null} actual
|
|
17697
|
+
* @param {string | Object | null} expected
|
|
17698
|
+
* @param {(arg0: any, arg1: any) => any} comparator
|
|
17699
|
+
* @param {string} anyPropertyKey
|
|
17700
|
+
* @param {boolean} matchAgainstAnyProp
|
|
17701
|
+
* @param {boolean | undefined} [dontMatchWholeObject]
|
|
17702
|
+
* @returns {boolean}
|
|
17703
|
+
*/
|
|
17644
17704
|
function deepCompare(
|
|
17645
17705
|
actual,
|
|
17646
17706
|
expected,
|
|
@@ -17653,10 +17713,13 @@ function deepCompare(
|
|
|
17653
17713
|
|
|
17654
17714
|
const expectedType = getTypeForFilter(expected);
|
|
17655
17715
|
|
|
17656
|
-
if (
|
|
17716
|
+
if (
|
|
17717
|
+
expectedType === "string" &&
|
|
17718
|
+
/** @type {string} */ (expected).charAt(0) === "!"
|
|
17719
|
+
) {
|
|
17657
17720
|
return !deepCompare(
|
|
17658
17721
|
actual,
|
|
17659
|
-
expected.substring(1),
|
|
17722
|
+
/** @type {string} */ (expected).substring(1),
|
|
17660
17723
|
comparator,
|
|
17661
17724
|
anyPropertyKey,
|
|
17662
17725
|
matchAgainstAnyProp,
|
|
@@ -17680,13 +17743,19 @@ function deepCompare(
|
|
|
17680
17743
|
switch (actualType) {
|
|
17681
17744
|
case "object":
|
|
17682
17745
|
if (matchAgainstAnyProp) {
|
|
17683
|
-
for (const key in actual) {
|
|
17746
|
+
for (const key in /** @type {Record<string, any>} */ (actual)) {
|
|
17684
17747
|
// Under certain, rare, circumstances, key may not be a string and `charAt` will be undefined
|
|
17685
17748
|
// See: https://github.com/angular/angular.js/issues/15644
|
|
17686
17749
|
if (
|
|
17687
17750
|
key.charAt &&
|
|
17688
17751
|
key.charAt(0) !== "$" &&
|
|
17689
|
-
deepCompare(
|
|
17752
|
+
deepCompare(
|
|
17753
|
+
/** @type {Record<string, any>} */ (actual)[key],
|
|
17754
|
+
expected,
|
|
17755
|
+
comparator,
|
|
17756
|
+
anyPropertyKey,
|
|
17757
|
+
true,
|
|
17758
|
+
)
|
|
17690
17759
|
) {
|
|
17691
17760
|
return true;
|
|
17692
17761
|
}
|
|
@@ -17698,8 +17767,10 @@ function deepCompare(
|
|
|
17698
17767
|
}
|
|
17699
17768
|
|
|
17700
17769
|
if (expectedType === "object") {
|
|
17701
|
-
for (const key in expected) {
|
|
17702
|
-
const expectedVal = expected[
|
|
17770
|
+
for (const key in /** @type {Record<string, any>} */ (expected)) {
|
|
17771
|
+
const expectedVal = /** @type {Record<string, any>} */ (expected)[
|
|
17772
|
+
key
|
|
17773
|
+
];
|
|
17703
17774
|
|
|
17704
17775
|
if (isFunction(expectedVal) || isUndefined(expectedVal)) {
|
|
17705
17776
|
continue;
|
|
@@ -17707,7 +17778,9 @@ function deepCompare(
|
|
|
17707
17778
|
|
|
17708
17779
|
const matchAnyProperty = key === anyPropertyKey;
|
|
17709
17780
|
|
|
17710
|
-
const actualVal = matchAnyProperty
|
|
17781
|
+
const actualVal = matchAnyProperty
|
|
17782
|
+
? actual
|
|
17783
|
+
: /** @type {Record<string, any>} */ (actual)[key];
|
|
17711
17784
|
|
|
17712
17785
|
if (
|
|
17713
17786
|
!deepCompare(
|
|
@@ -17736,6 +17809,10 @@ function deepCompare(
|
|
|
17736
17809
|
}
|
|
17737
17810
|
|
|
17738
17811
|
// Used for easily differentiating between `null` and actual `object`
|
|
17812
|
+
/**
|
|
17813
|
+
* @param {string | Object | null} val
|
|
17814
|
+
* @return {string}
|
|
17815
|
+
*/
|
|
17739
17816
|
function getTypeForFilter(val) {
|
|
17740
17817
|
return val === null ? "null" : typeof val;
|
|
17741
17818
|
}
|
|
@@ -17758,9 +17835,21 @@ function jsonFilter() {
|
|
|
17758
17835
|
*/
|
|
17759
17836
|
function limitToFilter() {
|
|
17760
17837
|
/**
|
|
17761
|
-
*
|
|
17762
|
-
*
|
|
17763
|
-
*
|
|
17838
|
+
* Limits the size of an array, array-like object, string, or number.
|
|
17839
|
+
*
|
|
17840
|
+
* - If `input` is a function, it will be invoked and its return value used.
|
|
17841
|
+
* - If `input` is a number, it will be converted to a string.
|
|
17842
|
+
* - Non–array-like values are returned unchanged.
|
|
17843
|
+
*
|
|
17844
|
+
* @param {Array<any>|ArrayLike<any>|string|number} input
|
|
17845
|
+
* The value to limit.
|
|
17846
|
+
* @param {string|number} limit
|
|
17847
|
+
* The maximum length of the returned value. Negative values limit from the end.
|
|
17848
|
+
* @param {string|number} [begin]
|
|
17849
|
+
* Index at which to begin the limitation. A negative value is an offset from the end.
|
|
17850
|
+
* Defaults to `0`.
|
|
17851
|
+
* @returns {Array<any>|ArrayLike<any>|string|number}
|
|
17852
|
+
* A limited array or string, or the original input if it cannot be limited.
|
|
17764
17853
|
*/
|
|
17765
17854
|
return function (input, limit, begin) {
|
|
17766
17855
|
if (isFunction(input)) {
|
|
@@ -17798,12 +17887,34 @@ function limitToFilter() {
|
|
|
17798
17887
|
};
|
|
17799
17888
|
}
|
|
17800
17889
|
|
|
17890
|
+
/**
|
|
17891
|
+
* Returns a shallow copy of a portion of an array-like or string.
|
|
17892
|
+
*
|
|
17893
|
+
* - For strings, this delegates to `String.prototype.slice`
|
|
17894
|
+
* - For array-like objects, this delegates to `Array.prototype.slice`
|
|
17895
|
+
*
|
|
17896
|
+
* @param {string|ArrayLike<any>} input
|
|
17897
|
+
* The value to slice. Must be a string or array-like object.
|
|
17898
|
+
* @param {number} [begin]
|
|
17899
|
+
* Zero-based index at which to begin extraction.
|
|
17900
|
+
* @param {number} [end]
|
|
17901
|
+
* Zero-based index before which to end extraction.
|
|
17902
|
+
* @returns {string|Array<any>}
|
|
17903
|
+
* A sliced string if input is a string, otherwise an array.
|
|
17904
|
+
*/
|
|
17801
17905
|
function sliceFn(input, begin, end) {
|
|
17802
17906
|
if (isString(input)) return input.slice(begin, end);
|
|
17803
17907
|
|
|
17804
17908
|
return [].slice.call(input, begin, end);
|
|
17805
17909
|
}
|
|
17806
17910
|
|
|
17911
|
+
/**
|
|
17912
|
+
* @typedef {Object} ComparisonObject
|
|
17913
|
+
* @property {*} value
|
|
17914
|
+
* @property {{ value: number, type: string, index: number }} tieBreaker
|
|
17915
|
+
* @property {Array<{ value: any, type: string, index: number }>} predicateValues
|
|
17916
|
+
*/
|
|
17917
|
+
|
|
17807
17918
|
orderByFilter.$inject = [$injectTokens._parse];
|
|
17808
17919
|
|
|
17809
17920
|
/**
|
|
@@ -17811,6 +17922,32 @@ orderByFilter.$inject = [$injectTokens._parse];
|
|
|
17811
17922
|
* @returns {ng.FilterFn}
|
|
17812
17923
|
*/
|
|
17813
17924
|
function orderByFilter($parse) {
|
|
17925
|
+
/**
|
|
17926
|
+
* Sorts an array or array-like collection based on one or more predicates.
|
|
17927
|
+
*
|
|
17928
|
+
* The collection can be:
|
|
17929
|
+
* - An array
|
|
17930
|
+
* - An array-like object
|
|
17931
|
+
* - A function returning an array
|
|
17932
|
+
*
|
|
17933
|
+
* Predicates can be:
|
|
17934
|
+
* - Property names (strings)
|
|
17935
|
+
* - Getter functions
|
|
17936
|
+
* - Strings with "+" or "-" prefix to indicate ascending/descending order
|
|
17937
|
+
*
|
|
17938
|
+
* @param {Array<any>|ArrayLike<any>|Function} array
|
|
17939
|
+
* The collection to be sorted.
|
|
17940
|
+
* @param {string|Function|Array<string|Function>} [sortPredicate]
|
|
17941
|
+
* A single predicate or array of predicates used for sorting.
|
|
17942
|
+
* @param {boolean} [reverseOrder=false]
|
|
17943
|
+
* If true, reverses the sort order.
|
|
17944
|
+
* @param {Function} [compareFn]
|
|
17945
|
+
* Optional comparator function. Defaults to a type-aware comparison function.
|
|
17946
|
+
* @returns {Array<any>|ArrayLike<any>}
|
|
17947
|
+
* A new array containing the sorted values.
|
|
17948
|
+
*
|
|
17949
|
+
* @throws {Error} Throws if `array` is not array-like.
|
|
17950
|
+
*/
|
|
17814
17951
|
return function (array, sortPredicate, reverseOrder, compareFn) {
|
|
17815
17952
|
if (isNullOrUndefined(array)) return array;
|
|
17816
17953
|
|
|
@@ -17825,7 +17962,7 @@ function orderByFilter($parse) {
|
|
|
17825
17962
|
}
|
|
17826
17963
|
|
|
17827
17964
|
if (!isArray(sortPredicate)) {
|
|
17828
|
-
sortPredicate = [sortPredicate];
|
|
17965
|
+
sortPredicate = [sortPredicate ?? "+"]; // if undefined, default to "+"
|
|
17829
17966
|
}
|
|
17830
17967
|
|
|
17831
17968
|
if (sortPredicate.length === 0) {
|
|
@@ -17842,13 +17979,31 @@ function orderByFilter($parse) {
|
|
|
17842
17979
|
// The next three lines are a version of a Swartzian Transform idiom from Perl
|
|
17843
17980
|
// (sometimes called the Decorate-Sort-Undecorate idiom)
|
|
17844
17981
|
// See https://en.wikipedia.org/wiki/Schwartzian_transform
|
|
17845
|
-
const compareValues =
|
|
17982
|
+
const compareValues = /** @type {ComparisonObject[]} */ (
|
|
17983
|
+
Array.prototype.map.call(array, getComparisonObject)
|
|
17984
|
+
);
|
|
17846
17985
|
|
|
17847
17986
|
compareValues.sort(doComparison);
|
|
17848
17987
|
array = compareValues.map((item) => item.value);
|
|
17849
17988
|
|
|
17850
17989
|
return array;
|
|
17851
17990
|
|
|
17991
|
+
/**
|
|
17992
|
+
* Creates a comparison object for a given value in the array.
|
|
17993
|
+
* This object is used to perform stable sorting with multiple predicates.
|
|
17994
|
+
*
|
|
17995
|
+
* @param {*} value - The value from the array to wrap for comparison.
|
|
17996
|
+
* @param {number} index - The index of the value in the original array.
|
|
17997
|
+
* @returns {{
|
|
17998
|
+
* value: *,
|
|
17999
|
+
* tieBreaker: { value: number, type: string, index: number },
|
|
18000
|
+
* predicateValues: Array<{ value: *, type: string, index: number }>
|
|
18001
|
+
* }}
|
|
18002
|
+
* An object containing:
|
|
18003
|
+
* - `value`: the original value,
|
|
18004
|
+
* - `tieBreaker`: a stable sort fallback using the original index,
|
|
18005
|
+
* - `predicateValues`: an array of values derived from each sort predicate.
|
|
18006
|
+
*/
|
|
17852
18007
|
function getComparisonObject(value, index) {
|
|
17853
18008
|
// NOTE: We are adding an extra `tieBreaker` value based on the element's index.
|
|
17854
18009
|
// This will be used to keep the sort stable when none of the input predicates can
|
|
@@ -17862,6 +18017,20 @@ function orderByFilter($parse) {
|
|
|
17862
18017
|
};
|
|
17863
18018
|
}
|
|
17864
18019
|
|
|
18020
|
+
/**
|
|
18021
|
+
* Comparator used to sort decorated collection items.
|
|
18022
|
+
*
|
|
18023
|
+
* Iterates over all sort predicates and compares their corresponding
|
|
18024
|
+
* predicate values. The first non-zero comparison result determines
|
|
18025
|
+
* the ordering.
|
|
18026
|
+
*
|
|
18027
|
+
* If all predicate comparisons are equal, a tie-breaker based on the
|
|
18028
|
+
* original index is used to guarantee a stable sort.
|
|
18029
|
+
*
|
|
18030
|
+
* @param {ComparisonObject} v1 First decorated comparison object
|
|
18031
|
+
* @param {ComparisonObject} v2 Second decorated comparison object
|
|
18032
|
+
* @returns {number} -1 if v1 < v2, 1 if v1 > v2, 0 if equivalent
|
|
18033
|
+
*/
|
|
17865
18034
|
function doComparison(v1, v2) {
|
|
17866
18035
|
for (let i = 0, ii = predicates.length; i < ii; i++) {
|
|
17867
18036
|
const result = compare(v1.predicateValues[i], v2.predicateValues[i]);
|
|
@@ -17878,14 +18047,31 @@ function orderByFilter($parse) {
|
|
|
17878
18047
|
}
|
|
17879
18048
|
};
|
|
17880
18049
|
|
|
18050
|
+
/**
|
|
18051
|
+
* Processes an array of sort predicates into getter functions and sort directions.
|
|
18052
|
+
*
|
|
18053
|
+
* Each predicate can be:
|
|
18054
|
+
* - A function: used directly to extract values for comparison.
|
|
18055
|
+
* - A string starting with `+` or `-` to indicate ascending or descending order.
|
|
18056
|
+
* The remainder of the string is interpreted as a property path.
|
|
18057
|
+
*
|
|
18058
|
+
* @param {(string|Function)[]} sortPredicates - Array of predicates to process. Each predicate
|
|
18059
|
+
* can be a string (property name, optionally prefixed with "+" or "-") or a function.
|
|
18060
|
+
* @return {Array<{get: Function, descending: number}>} Array of objects, each containing:
|
|
18061
|
+
* - `get`: Function to extract the value from an item.
|
|
18062
|
+
* - `descending`: `1` for ascending, `-1` for descending.
|
|
18063
|
+
*/
|
|
17881
18064
|
function processPredicates(sortPredicates) {
|
|
17882
18065
|
return sortPredicates.map((predicate) => {
|
|
17883
18066
|
let descending = 1;
|
|
17884
18067
|
|
|
18068
|
+
/**
|
|
18069
|
+
* @type {function(*): *}
|
|
18070
|
+
*/
|
|
17885
18071
|
let get = (x) => x;
|
|
17886
18072
|
|
|
17887
18073
|
if (isFunction(predicate)) {
|
|
17888
|
-
get = predicate;
|
|
18074
|
+
get = /** @type {function(*): *} */ (predicate);
|
|
17889
18075
|
} else if (isString(predicate)) {
|
|
17890
18076
|
if (predicate.charAt(0) === "+" || predicate.charAt(0) === "-") {
|
|
17891
18077
|
descending = predicate.charAt(0) === "-" ? -1 : 1;
|
|
@@ -17898,7 +18084,8 @@ function orderByFilter($parse) {
|
|
|
17898
18084
|
if (parsed.constant) {
|
|
17899
18085
|
const key = parsed();
|
|
17900
18086
|
|
|
17901
|
-
get = (value) =>
|
|
18087
|
+
get = /** @type {Record<string, any>} value */ (value) =>
|
|
18088
|
+
value[key];
|
|
17902
18089
|
} else {
|
|
17903
18090
|
get = parsed;
|
|
17904
18091
|
}
|
|
@@ -17909,6 +18096,10 @@ function orderByFilter($parse) {
|
|
|
17909
18096
|
});
|
|
17910
18097
|
}
|
|
17911
18098
|
|
|
18099
|
+
/**
|
|
18100
|
+
* @param {any} value
|
|
18101
|
+
* @return {boolean}
|
|
18102
|
+
*/
|
|
17912
18103
|
function isPrimitive(value) {
|
|
17913
18104
|
switch (typeof value) {
|
|
17914
18105
|
case "number": /* falls through */
|
|
@@ -17920,6 +18111,16 @@ function orderByFilter($parse) {
|
|
|
17920
18111
|
}
|
|
17921
18112
|
}
|
|
17922
18113
|
|
|
18114
|
+
/**
|
|
18115
|
+
* Converts an object to a primitive value for comparison purposes.
|
|
18116
|
+
*
|
|
18117
|
+
* - If the object has a valid `valueOf()` method that returns a primitive, it uses that.
|
|
18118
|
+
* - Otherwise, if the object has a custom `toString()` method, it uses that.
|
|
18119
|
+
* - If neither yields a primitive, returns the original object.
|
|
18120
|
+
*
|
|
18121
|
+
* @param {*} value - The object to convert.
|
|
18122
|
+
* @returns {*} The primitive representation of the object if possible; otherwise, the original object.
|
|
18123
|
+
*/
|
|
17923
18124
|
function objectValue(value) {
|
|
17924
18125
|
// If `valueOf` is a valid function use that
|
|
17925
18126
|
if (isFunction(value.valueOf)) {
|
|
@@ -17938,6 +18139,22 @@ function orderByFilter($parse) {
|
|
|
17938
18139
|
return value;
|
|
17939
18140
|
}
|
|
17940
18141
|
|
|
18142
|
+
/**
|
|
18143
|
+
* Normalizes a value for sorting by determining its type and
|
|
18144
|
+
* converting objects to primitive representations when possible.
|
|
18145
|
+
*
|
|
18146
|
+
* @param {*} value - The value to normalize for comparison.
|
|
18147
|
+
* @param {number} index - The original index of the value in the array.
|
|
18148
|
+
* @returns {{
|
|
18149
|
+
* value: *,
|
|
18150
|
+
* type: string,
|
|
18151
|
+
* index: number
|
|
18152
|
+
* }}
|
|
18153
|
+
* An object containing:
|
|
18154
|
+
* - `value`: the normalized value (primitive if possible),
|
|
18155
|
+
* - `type`: a string representing the type of the value (`number`, `string`, `boolean`, `null`, etc.),
|
|
18156
|
+
* - `index`: the original index to maintain stable sorting.
|
|
18157
|
+
*/
|
|
17941
18158
|
function getPredicateValue(value, index) {
|
|
17942
18159
|
/** @type {String} */ let type = typeof value;
|
|
17943
18160
|
|
|
@@ -17950,6 +18167,23 @@ function orderByFilter($parse) {
|
|
|
17950
18167
|
return { value, type, index };
|
|
17951
18168
|
}
|
|
17952
18169
|
|
|
18170
|
+
/**
|
|
18171
|
+
* Default comparison function used by the `orderBy` filter.
|
|
18172
|
+
*
|
|
18173
|
+
* Compares two wrapped predicate values and returns a sort order indicator.
|
|
18174
|
+
* Comparison rules:
|
|
18175
|
+
* - Values of the same type are compared directly
|
|
18176
|
+
* - Strings are compared case-insensitively
|
|
18177
|
+
* - Objects fall back to their original index to preserve stability
|
|
18178
|
+
* - `undefined` and `null` are ordered last
|
|
18179
|
+
*
|
|
18180
|
+
* @param {{ value: any, type: string, index: number }} v1
|
|
18181
|
+
* First comparison object.
|
|
18182
|
+
* @param {{ value: any, type: string, index: number }} v2
|
|
18183
|
+
* Second comparison object.
|
|
18184
|
+
* @returns {number}
|
|
18185
|
+
* Returns `-1` if `v1 < v2`, `1` if `v1 > v2`, or `0` if equal.
|
|
18186
|
+
*/
|
|
17953
18187
|
function defaultCompare(v1, v2) {
|
|
17954
18188
|
let result = 0;
|
|
17955
18189
|
|
|
@@ -18054,6 +18288,9 @@ class FilterProvider {
|
|
|
18054
18288
|
|
|
18055
18289
|
const $interpolateMinErr = minErr("$interpolate");
|
|
18056
18290
|
|
|
18291
|
+
/**
|
|
18292
|
+
* @param {string} text
|
|
18293
|
+
*/
|
|
18057
18294
|
function throwNoconcat(text) {
|
|
18058
18295
|
throw $interpolateMinErr(
|
|
18059
18296
|
"noconcat",
|
|
@@ -18064,6 +18301,10 @@ function throwNoconcat(text) {
|
|
|
18064
18301
|
);
|
|
18065
18302
|
}
|
|
18066
18303
|
|
|
18304
|
+
/**
|
|
18305
|
+
* @param {string} text
|
|
18306
|
+
* @param {Error} err
|
|
18307
|
+
*/
|
|
18067
18308
|
function interr(text, err) {
|
|
18068
18309
|
throw $interpolateMinErr(
|
|
18069
18310
|
"interr",
|
|
@@ -18111,9 +18352,9 @@ class InterpolateProvider {
|
|
|
18111
18352
|
/** @type {InterpolateProvider} */
|
|
18112
18353
|
const provider = this;
|
|
18113
18354
|
|
|
18114
|
-
const startSymbolLength =
|
|
18355
|
+
const startSymbolLength = this.startSymbol.length;
|
|
18115
18356
|
|
|
18116
|
-
const endSymbolLength =
|
|
18357
|
+
const endSymbolLength = this.endSymbol.length;
|
|
18117
18358
|
|
|
18118
18359
|
const escapedStartRegexp = new RegExp(
|
|
18119
18360
|
provider.startSymbol.replace(/./g, escape),
|
|
@@ -18125,10 +18366,16 @@ class InterpolateProvider {
|
|
|
18125
18366
|
"g",
|
|
18126
18367
|
);
|
|
18127
18368
|
|
|
18369
|
+
/**
|
|
18370
|
+
* @param {any} ch
|
|
18371
|
+
*/
|
|
18128
18372
|
function escape(ch) {
|
|
18129
18373
|
return `\\\\\\${ch}`;
|
|
18130
18374
|
}
|
|
18131
18375
|
|
|
18376
|
+
/**
|
|
18377
|
+
* @param {string} text
|
|
18378
|
+
*/
|
|
18132
18379
|
function unescapeText(text) {
|
|
18133
18380
|
return text
|
|
18134
18381
|
.replace(escapedStartRegexp, provider.startSymbol)
|
|
@@ -18240,7 +18487,7 @@ class InterpolateProvider {
|
|
|
18240
18487
|
* provides Strict Contextual Escaping for details.
|
|
18241
18488
|
* @param {boolean=} allOrNothing if `true`, then the returned function returns undefined
|
|
18242
18489
|
* unless all embedded expressions evaluate to a value other than `undefined`.
|
|
18243
|
-
* @returns {
|
|
18490
|
+
* @returns {import("./interface.js").InterpolationFunction | undefined} an interpolation function which is used to compute the
|
|
18244
18491
|
* interpolated string. The function has these parameters:
|
|
18245
18492
|
*
|
|
18246
18493
|
* - `context`: evaluation context for all expressions embedded in the interpolated text
|
|
@@ -18282,14 +18529,23 @@ class InterpolateProvider {
|
|
|
18282
18529
|
|
|
18283
18530
|
let index = 0;
|
|
18284
18531
|
|
|
18532
|
+
/**
|
|
18533
|
+
* @type {string[]}
|
|
18534
|
+
*/
|
|
18285
18535
|
const expressions = [];
|
|
18286
18536
|
|
|
18287
18537
|
const textLength = text.length;
|
|
18288
18538
|
|
|
18289
18539
|
let exp;
|
|
18290
18540
|
|
|
18541
|
+
/**
|
|
18542
|
+
* @type {any[]}
|
|
18543
|
+
*/
|
|
18291
18544
|
const concat = [];
|
|
18292
18545
|
|
|
18546
|
+
/**
|
|
18547
|
+
* @type {number[]}
|
|
18548
|
+
*/
|
|
18293
18549
|
const expressionPositions = [];
|
|
18294
18550
|
|
|
18295
18551
|
while (index < textLength) {
|
|
@@ -18344,7 +18600,7 @@ class InterpolateProvider {
|
|
|
18344
18600
|
// only used in srcdoc attributes, this would not be very useful.
|
|
18345
18601
|
|
|
18346
18602
|
if (!mustHaveExpression || expressions.length) {
|
|
18347
|
-
const compute = function (values) {
|
|
18603
|
+
const compute = function (/** @type {any[]} */ values) {
|
|
18348
18604
|
for (let i = 0, ii = expressions.length; i < ii; i++) {
|
|
18349
18605
|
if (allOrNothing && isUndefined(values[i])) return undefined;
|
|
18350
18606
|
concat[expressionPositions[i]] = values[i];
|
|
@@ -18367,68 +18623,54 @@ class InterpolateProvider {
|
|
|
18367
18623
|
return concat.join("");
|
|
18368
18624
|
};
|
|
18369
18625
|
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18626
|
+
/**
|
|
18627
|
+
* @type {import("./interface.ts").InterpolationFunction}
|
|
18628
|
+
*/
|
|
18629
|
+
const fn = (
|
|
18630
|
+
/** @type {ng.Scope} */ context,
|
|
18631
|
+
/** @type {(val: any) => void=} */ cb,
|
|
18632
|
+
) => {
|
|
18633
|
+
const ii = expressions.length;
|
|
18373
18634
|
|
|
18374
|
-
|
|
18635
|
+
const values = new Array(ii);
|
|
18375
18636
|
|
|
18376
|
-
|
|
18637
|
+
try {
|
|
18638
|
+
for (let i = 0; i < ii; i++) {
|
|
18639
|
+
if (cb) {
|
|
18640
|
+
const watchProp = expressions[i].trim();
|
|
18377
18641
|
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
if (cb) {
|
|
18381
|
-
const watchProp = expressions[i].trim();
|
|
18642
|
+
context.$watch(watchProp, () => {
|
|
18643
|
+
const vals = new Array(ii);
|
|
18382
18644
|
|
|
18383
|
-
|
|
18384
|
-
|
|
18645
|
+
for (let j = 0; j < ii; j++) {
|
|
18646
|
+
vals[j] = parseFns[j](context);
|
|
18647
|
+
}
|
|
18385
18648
|
|
|
18386
|
-
|
|
18649
|
+
cb(compute(vals));
|
|
18650
|
+
});
|
|
18651
|
+
}
|
|
18387
18652
|
|
|
18388
|
-
|
|
18389
|
-
|
|
18653
|
+
values[i] = parseFns[i](context);
|
|
18654
|
+
}
|
|
18390
18655
|
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18656
|
+
return compute(values);
|
|
18657
|
+
} catch (err) {
|
|
18658
|
+
return interr(text, /** @type {Error} */ (err));
|
|
18659
|
+
}
|
|
18660
|
+
};
|
|
18396
18661
|
|
|
18397
|
-
|
|
18398
|
-
|
|
18662
|
+
// Attach required properties so TS sees them
|
|
18663
|
+
/** @type {string} */
|
|
18664
|
+
fn.exp = text;
|
|
18665
|
+
/** @type {any[]} */
|
|
18666
|
+
fn.expressions = expressions;
|
|
18399
18667
|
|
|
18400
|
-
|
|
18401
|
-
} catch (err) {
|
|
18402
|
-
return interr(text, err);
|
|
18403
|
-
}
|
|
18404
|
-
},
|
|
18405
|
-
{
|
|
18406
|
-
// Most likely we would need to register watches during interpolation
|
|
18407
|
-
// all of these properties are undocumented for now
|
|
18408
|
-
exp: text, // just for compatibility with regular watchers created via $watch
|
|
18409
|
-
expressions,
|
|
18410
|
-
_watchDelegate(scope, listener) {
|
|
18411
|
-
let lastValue;
|
|
18412
|
-
|
|
18413
|
-
return scope.$watch(
|
|
18414
|
-
parseFns,
|
|
18415
|
-
function interpolateFnWatcher(values, oldValues) {
|
|
18416
|
-
const currValue = compute(values);
|
|
18417
|
-
|
|
18418
|
-
listener.call(
|
|
18419
|
-
provider,
|
|
18420
|
-
currValue,
|
|
18421
|
-
values !== oldValues ? lastValue : currValue,
|
|
18422
|
-
scope,
|
|
18423
|
-
);
|
|
18424
|
-
lastValue = currValue;
|
|
18425
|
-
},
|
|
18426
|
-
);
|
|
18427
|
-
},
|
|
18428
|
-
},
|
|
18429
|
-
);
|
|
18668
|
+
return fn;
|
|
18430
18669
|
}
|
|
18431
18670
|
|
|
18671
|
+
/**
|
|
18672
|
+
* @param {string} value
|
|
18673
|
+
*/
|
|
18432
18674
|
function parseStringifyInterceptor(value) {
|
|
18433
18675
|
try {
|
|
18434
18676
|
// In concatenable contexts, getTrusted comes at the end, to avoid sanitizing individual
|
|
@@ -18442,7 +18684,7 @@ class InterpolateProvider {
|
|
|
18442
18684
|
|
|
18443
18685
|
return allOrNothing && !isDefined(value) ? value : stringify$1(value);
|
|
18444
18686
|
} catch (err) {
|
|
18445
|
-
return interr(text, err);
|
|
18687
|
+
return interr(text, /** @type {Error} */ (err));
|
|
18446
18688
|
}
|
|
18447
18689
|
}
|
|
18448
18690
|
|
|
@@ -18473,7 +18715,6 @@ class InterpolateProvider {
|
|
|
18473
18715
|
return provider.endSymbol;
|
|
18474
18716
|
};
|
|
18475
18717
|
|
|
18476
|
-
// @ts-ignore
|
|
18477
18718
|
return $interpolate;
|
|
18478
18719
|
},
|
|
18479
18720
|
];
|
|
@@ -18493,7 +18734,7 @@ let urlUpdatedByLocation = false;
|
|
|
18493
18734
|
let _path;
|
|
18494
18735
|
|
|
18495
18736
|
/**
|
|
18496
|
-
* @type {Object.<string,boolean|Array<
|
|
18737
|
+
* @type {Object.<string, string|number|boolean|Array<string|number|boolean>>}
|
|
18497
18738
|
*/
|
|
18498
18739
|
let _search;
|
|
18499
18740
|
|
|
@@ -18657,7 +18898,6 @@ class Location {
|
|
|
18657
18898
|
if (isUndefined(paramValue) || paramValue === null) {
|
|
18658
18899
|
delete _search[search];
|
|
18659
18900
|
} else {
|
|
18660
|
-
// @ts-ignore
|
|
18661
18901
|
_search[search] = paramValue;
|
|
18662
18902
|
}
|
|
18663
18903
|
}
|
|
@@ -19087,12 +19327,12 @@ class LocationProvider {
|
|
|
19087
19327
|
) {
|
|
19088
19328
|
return;
|
|
19089
19329
|
}
|
|
19090
|
-
let elm = /** @type {
|
|
19330
|
+
let elm = /** @type {HTMLElement} */ (event.target);
|
|
19091
19331
|
|
|
19092
19332
|
// traverse the DOM up to find first A tag
|
|
19093
19333
|
while (elm.nodeName.toLowerCase() !== "a") {
|
|
19094
19334
|
// ignore rewriting if no A tag (reached root element, or no parent - removed from document)
|
|
19095
|
-
|
|
19335
|
+
|
|
19096
19336
|
if (elm === $rootElement || !(elm = elm.parentElement)) return;
|
|
19097
19337
|
}
|
|
19098
19338
|
|
|
@@ -19103,7 +19343,7 @@ class LocationProvider {
|
|
|
19103
19343
|
return;
|
|
19104
19344
|
}
|
|
19105
19345
|
|
|
19106
|
-
let absHref = elm.href;
|
|
19346
|
+
let absHref = /** @type {HTMLAnchorElement} */ (elm).href;
|
|
19107
19347
|
|
|
19108
19348
|
// get the actual href attribute - see
|
|
19109
19349
|
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
|
|
@@ -20019,7 +20259,6 @@ class ASTInterpreter {
|
|
|
20019
20259
|
|
|
20020
20260
|
const { body } = /** @type {BodyNode} */ (decoratedNode);
|
|
20021
20261
|
|
|
20022
|
-
/** @type {ASTNode} */
|
|
20023
20262
|
const assignable = assignableAST(/** @type {BodyNode} */ (decoratedNode));
|
|
20024
20263
|
|
|
20025
20264
|
/** @type {import("./interface.ts").CompiledExpression} */
|
|
@@ -20060,27 +20299,25 @@ class ASTInterpreter {
|
|
|
20060
20299
|
},
|
|
20061
20300
|
);
|
|
20062
20301
|
|
|
20063
|
-
|
|
20064
|
-
// @ts-ignore
|
|
20065
|
-
const fn =
|
|
20302
|
+
const fnRaw =
|
|
20066
20303
|
body.length === 0
|
|
20067
20304
|
? () => {
|
|
20068
20305
|
/* empty */
|
|
20069
20306
|
}
|
|
20070
20307
|
: body.length === 1
|
|
20071
|
-
? /** @type {
|
|
20072
|
-
expressions[0]
|
|
20073
|
-
)
|
|
20308
|
+
? /** @type {CompiledExpression} */ (expressions[0])
|
|
20074
20309
|
: function (scope, locals) {
|
|
20075
20310
|
let lastValue;
|
|
20076
20311
|
|
|
20077
|
-
for (let i = 0
|
|
20312
|
+
for (let i = 0; i < expressions.length; i++) {
|
|
20078
20313
|
lastValue = expressions[i](scope, locals);
|
|
20079
20314
|
}
|
|
20080
20315
|
|
|
20081
20316
|
return lastValue;
|
|
20082
20317
|
};
|
|
20083
20318
|
|
|
20319
|
+
const fn = /** @type {CompiledExpression} */ (fnRaw);
|
|
20320
|
+
|
|
20084
20321
|
if (assign) {
|
|
20085
20322
|
fn._assign = (scope, value, locals) => assign(scope, locals, value);
|
|
20086
20323
|
}
|
|
@@ -20088,6 +20325,7 @@ class ASTInterpreter {
|
|
|
20088
20325
|
if (inputs) {
|
|
20089
20326
|
fn._inputs = inputs;
|
|
20090
20327
|
}
|
|
20328
|
+
|
|
20091
20329
|
fn._decoratedNode = /** @type {BodyNode} */ (decoratedNode);
|
|
20092
20330
|
|
|
20093
20331
|
return fn;
|
|
@@ -22036,43 +22274,34 @@ class Scope {
|
|
|
22036
22274
|
* @param {Scope} [parent] - Custom parent.
|
|
22037
22275
|
*/
|
|
22038
22276
|
constructor(context, parent) {
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
? context.context
|
|
22042
|
-
: context
|
|
22043
|
-
: undefined;
|
|
22044
|
-
|
|
22045
|
-
/** @type {Map<string, Array<import('./interface.ts').Listener>>} Watch listeners */
|
|
22046
|
-
this.watchers = context ? context.watchers : new Map();
|
|
22277
|
+
/** @ignore @type {Map<string, Array<import('./interface.ts').Listener>>} Watch listeners */
|
|
22278
|
+
this._watchers = context?._watchers ?? new Map();
|
|
22047
22279
|
|
|
22048
22280
|
/** @private @type {Map<String, Function[]>} Event listeners */
|
|
22049
22281
|
this._listeners = new Map();
|
|
22050
22282
|
|
|
22051
22283
|
/** @private @type {Map<string, Array<import('./interface.ts').Listener>>} Watch listeners from other proxies */
|
|
22052
|
-
this._foreignListeners = context
|
|
22284
|
+
this._foreignListeners = context?._foreignListeners ?? new Map();
|
|
22053
22285
|
|
|
22054
22286
|
/** @private @type {Set<Proxy<ng.Scope>>} */
|
|
22055
|
-
this._foreignProxies = context
|
|
22287
|
+
this._foreignProxies = context?._foreignProxies ?? new Set();
|
|
22056
22288
|
|
|
22057
22289
|
/** @private @type {WeakMap<Object, Array<string>>} */
|
|
22058
|
-
this._objectListeners = context
|
|
22290
|
+
this._objectListeners = context?._objectListeners ?? new WeakMap();
|
|
22059
22291
|
|
|
22060
22292
|
/** @type {Proxy<Scope>} Current proxy being operated on */
|
|
22061
|
-
this.$proxy
|
|
22293
|
+
this.$proxy;
|
|
22062
22294
|
|
|
22063
|
-
/** @type {Scope}
|
|
22295
|
+
/** @type {Scope} This is the reference to the Scope object with acts as the actual proxy */
|
|
22064
22296
|
this.$handler = /** @type {Scope} */ (this);
|
|
22065
22297
|
|
|
22066
22298
|
/** @type {*} Current target being called on */
|
|
22067
22299
|
this.$target = null;
|
|
22068
22300
|
|
|
22069
|
-
/** @type {*} Value wrapped by the proxy */
|
|
22070
|
-
this.$value = null;
|
|
22071
|
-
|
|
22072
22301
|
/**
|
|
22073
|
-
* @type {Scope[]}
|
|
22302
|
+
* @ignore @type {Scope[]}
|
|
22074
22303
|
*/
|
|
22075
|
-
this
|
|
22304
|
+
this._children = [];
|
|
22076
22305
|
|
|
22077
22306
|
/**
|
|
22078
22307
|
* @type {number} Unique model ID (monotonically increasing) useful for debugging.
|
|
@@ -22080,15 +22309,14 @@ class Scope {
|
|
|
22080
22309
|
this.$id = nextId();
|
|
22081
22310
|
|
|
22082
22311
|
/**
|
|
22083
|
-
* @type {
|
|
22312
|
+
* @type {ng.RootScopeService}
|
|
22084
22313
|
*/
|
|
22085
|
-
this.$root = context ? context.$root :
|
|
22314
|
+
this.$root = context ? context.$root : this;
|
|
22086
22315
|
|
|
22087
|
-
|
|
22088
|
-
|
|
22089
|
-
|
|
22090
|
-
|
|
22091
|
-
: context;
|
|
22316
|
+
/**
|
|
22317
|
+
* @type {Scope | undefined}
|
|
22318
|
+
*/
|
|
22319
|
+
this.$parent = parent || (this.$root === this ? undefined : context);
|
|
22092
22320
|
|
|
22093
22321
|
/** @ignore @type {boolean} */
|
|
22094
22322
|
this._destroyed = false;
|
|
@@ -22103,7 +22331,7 @@ class Scope {
|
|
|
22103
22331
|
this.propertyMap = {
|
|
22104
22332
|
$apply: this.$apply.bind(this),
|
|
22105
22333
|
$broadcast: this.$broadcast.bind(this),
|
|
22106
|
-
|
|
22334
|
+
_children: this._children,
|
|
22107
22335
|
$destroy: this.$destroy.bind(this),
|
|
22108
22336
|
$emit: this.$emit.bind(this),
|
|
22109
22337
|
$eval: this.$eval.bind(this),
|
|
@@ -22131,7 +22359,7 @@ class Scope {
|
|
|
22131
22359
|
* Intercepts and handles property assignments on the target object. If a new value is
|
|
22132
22360
|
* an object, it will be recursively proxied.
|
|
22133
22361
|
*
|
|
22134
|
-
* @param {Object} target - The target object.
|
|
22362
|
+
* @param {Object & Record<string, any>} target - The target object.
|
|
22135
22363
|
* @param {string} property - The name of the property being set.
|
|
22136
22364
|
* @param {*} value - The new value being assigned to the property.
|
|
22137
22365
|
* @param {Proxy<Scope>} proxy - The proxy intercepting property access
|
|
@@ -22148,14 +22376,9 @@ class Scope {
|
|
|
22148
22376
|
return true;
|
|
22149
22377
|
}
|
|
22150
22378
|
|
|
22151
|
-
|
|
22152
|
-
|
|
22153
|
-
|
|
22154
|
-
target.constructor.$nonscope.includes(property)) ||
|
|
22155
|
-
(target.$nonscope &&
|
|
22156
|
-
isArray(target.$nonscope) &&
|
|
22157
|
-
target.$nonscope.includes(property))
|
|
22158
|
-
) {
|
|
22379
|
+
const nonscopeProps = target.constructor?.$nonscope ?? target.$nonscope;
|
|
22380
|
+
|
|
22381
|
+
if (isArray(nonscopeProps) && nonscopeProps.includes(property)) {
|
|
22159
22382
|
target[property] = value;
|
|
22160
22383
|
|
|
22161
22384
|
return true;
|
|
@@ -22177,7 +22400,7 @@ class Scope {
|
|
|
22177
22400
|
if (oldValue && oldValue[isProxySymbol]) {
|
|
22178
22401
|
if (isArray(value)) {
|
|
22179
22402
|
if (oldValue !== value) {
|
|
22180
|
-
const listeners = this.
|
|
22403
|
+
const listeners = this._watchers.get(property);
|
|
22181
22404
|
|
|
22182
22405
|
if (listeners) {
|
|
22183
22406
|
this.#scheduleListener(listeners);
|
|
@@ -22209,7 +22432,7 @@ class Scope {
|
|
|
22209
22432
|
}
|
|
22210
22433
|
|
|
22211
22434
|
if (oldValue !== value) {
|
|
22212
|
-
const listeners = this.
|
|
22435
|
+
const listeners = this._watchers.get(property);
|
|
22213
22436
|
|
|
22214
22437
|
if (listeners) {
|
|
22215
22438
|
this.#scheduleListener(listeners);
|
|
@@ -22252,7 +22475,7 @@ class Scope {
|
|
|
22252
22475
|
target[property] = undefined;
|
|
22253
22476
|
|
|
22254
22477
|
if (!called) {
|
|
22255
|
-
const listeners = this.
|
|
22478
|
+
const listeners = this._watchers.get(property);
|
|
22256
22479
|
|
|
22257
22480
|
if (listeners) {
|
|
22258
22481
|
this.#scheduleListener(listeners);
|
|
@@ -22264,7 +22487,7 @@ class Scope {
|
|
|
22264
22487
|
|
|
22265
22488
|
if (isDefined(value)) {
|
|
22266
22489
|
target[property] = value;
|
|
22267
|
-
const listeners = this.
|
|
22490
|
+
const listeners = this._watchers.get(property);
|
|
22268
22491
|
|
|
22269
22492
|
if (listeners) {
|
|
22270
22493
|
this.#scheduleListener(listeners);
|
|
@@ -22272,10 +22495,12 @@ class Scope {
|
|
|
22272
22495
|
|
|
22273
22496
|
if (isArray(target)) {
|
|
22274
22497
|
if (this._objectListeners.has(proxy) && property !== "length") {
|
|
22275
|
-
const keyList =
|
|
22498
|
+
const keyList = /** @type {string[]} */ (
|
|
22499
|
+
this._objectListeners.get(proxy)
|
|
22500
|
+
);
|
|
22276
22501
|
|
|
22277
22502
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22278
|
-
const currentListeners = this.
|
|
22503
|
+
const currentListeners = this._watchers.get(keyList[i]);
|
|
22279
22504
|
|
|
22280
22505
|
if (currentListeners) this.#scheduleListener(currentListeners);
|
|
22281
22506
|
}
|
|
@@ -22291,7 +22516,7 @@ class Scope {
|
|
|
22291
22516
|
this._foreignProxies.add(/** @type {Proxy<ng.Scope>} */ (value));
|
|
22292
22517
|
target[property] = value;
|
|
22293
22518
|
|
|
22294
|
-
if (!this.
|
|
22519
|
+
if (!this._watchers.has(property)) {
|
|
22295
22520
|
return true;
|
|
22296
22521
|
}
|
|
22297
22522
|
}
|
|
@@ -22317,7 +22542,7 @@ class Scope {
|
|
|
22317
22542
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22318
22543
|
const key = keyList[i];
|
|
22319
22544
|
|
|
22320
|
-
const keyListeners = this.
|
|
22545
|
+
const keyListeners = this._watchers.get(key);
|
|
22321
22546
|
|
|
22322
22547
|
if (keyListeners) {
|
|
22323
22548
|
for (let j = 0, jl = keyListeners.length; j < jl; j++) {
|
|
@@ -22329,7 +22554,7 @@ class Scope {
|
|
|
22329
22554
|
}
|
|
22330
22555
|
|
|
22331
22556
|
if (isArray(target)) {
|
|
22332
|
-
const lengthListeners = this.
|
|
22557
|
+
const lengthListeners = this._watchers.get("length");
|
|
22333
22558
|
|
|
22334
22559
|
if (lengthListeners) {
|
|
22335
22560
|
for (let i = 0, l = lengthListeners.length; i < l; i++) {
|
|
@@ -22338,7 +22563,7 @@ class Scope {
|
|
|
22338
22563
|
}
|
|
22339
22564
|
}
|
|
22340
22565
|
|
|
22341
|
-
const propListeners = this.
|
|
22566
|
+
const propListeners = this._watchers.get(property);
|
|
22342
22567
|
|
|
22343
22568
|
if (propListeners) {
|
|
22344
22569
|
for (let i = 0, l = propListeners.length; i < l; i++) {
|
|
@@ -22360,9 +22585,7 @@ class Scope {
|
|
|
22360
22585
|
|
|
22361
22586
|
const wrapperExpr = x.watchProp.split(".").slice(0, -1).join(".");
|
|
22362
22587
|
|
|
22363
|
-
const expectedHandler = $parse(wrapperExpr)(
|
|
22364
|
-
x.originalTarget,
|
|
22365
|
-
)?.$handler;
|
|
22588
|
+
const expectedHandler = $parse(wrapperExpr)(x.originalTarget);
|
|
22366
22589
|
|
|
22367
22590
|
if (expectedTarget === expectedHandler?.$target) {
|
|
22368
22591
|
scheduled.push(x);
|
|
@@ -22404,12 +22627,14 @@ class Scope {
|
|
|
22404
22627
|
}
|
|
22405
22628
|
|
|
22406
22629
|
if (this._objectListeners.has(proxy) && property !== "length") {
|
|
22407
|
-
const keyList =
|
|
22630
|
+
const keyList = /** @type {string[]} */ (
|
|
22631
|
+
this._objectListeners.get(proxy)
|
|
22632
|
+
);
|
|
22408
22633
|
|
|
22409
22634
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22410
22635
|
const key = keyList[i];
|
|
22411
22636
|
|
|
22412
|
-
const listeners = this.
|
|
22637
|
+
const listeners = this._watchers.get(key);
|
|
22413
22638
|
|
|
22414
22639
|
if (listeners && this._scheduled !== listeners) {
|
|
22415
22640
|
this.#scheduleListener(listeners);
|
|
@@ -22426,7 +22651,7 @@ class Scope {
|
|
|
22426
22651
|
* properties (`watch` and `sync`) and binds their methods. For other properties,
|
|
22427
22652
|
* it returns the value directly.
|
|
22428
22653
|
*
|
|
22429
|
-
* @param {Object} target - The target object.
|
|
22654
|
+
* @param {Object & Record<string, any>} target - The target object.
|
|
22430
22655
|
* @param {string|number|symbol} property - The name of the property being accessed.
|
|
22431
22656
|
* @param {Proxy<Scope>} proxy - The proxy object being invoked
|
|
22432
22657
|
* @returns {*} - The value of the property or a method if accessing `watch` or `sync`.
|
|
@@ -22438,8 +22663,10 @@ class Scope {
|
|
|
22438
22663
|
|
|
22439
22664
|
if (property === isProxySymbol) return true;
|
|
22440
22665
|
|
|
22441
|
-
|
|
22442
|
-
|
|
22666
|
+
const targetProp = target[/** @type {string} */ (property)];
|
|
22667
|
+
|
|
22668
|
+
if (isProxy(targetProp)) {
|
|
22669
|
+
this.$proxy = /** @type {Proxy<Scope>} */ (targetProp);
|
|
22443
22670
|
} else {
|
|
22444
22671
|
this.$proxy = proxy;
|
|
22445
22672
|
}
|
|
@@ -22452,12 +22679,14 @@ class Scope {
|
|
|
22452
22679
|
["pop", "shift", "unshift"].includes(/** @type { string } */ (property))
|
|
22453
22680
|
) {
|
|
22454
22681
|
if (this._objectListeners.has(proxy)) {
|
|
22455
|
-
const keyList =
|
|
22682
|
+
const keyList = /** @type {string []} */ (
|
|
22683
|
+
this._objectListeners.get(proxy)
|
|
22684
|
+
);
|
|
22456
22685
|
|
|
22457
22686
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22458
22687
|
const key = keyList[i];
|
|
22459
22688
|
|
|
22460
|
-
const listeners = this.
|
|
22689
|
+
const listeners = this._watchers.get(key);
|
|
22461
22690
|
|
|
22462
22691
|
if (listeners) {
|
|
22463
22692
|
this._scheduled = listeners;
|
|
@@ -22476,28 +22705,34 @@ class Scope {
|
|
|
22476
22705
|
return this.propertyMap[/** @type {string} */ (property)];
|
|
22477
22706
|
} else {
|
|
22478
22707
|
// we are a simple getter
|
|
22479
|
-
return
|
|
22708
|
+
return targetProp;
|
|
22480
22709
|
}
|
|
22481
22710
|
}
|
|
22482
22711
|
|
|
22712
|
+
/**
|
|
22713
|
+
* @param {Object & Record<string, any>} target - The target object.
|
|
22714
|
+
* @param {string} property - The name of the property being deleted
|
|
22715
|
+
*/
|
|
22483
22716
|
deleteProperty(target, property) {
|
|
22484
22717
|
// Currently deletes $model
|
|
22485
22718
|
if (target[property] && target[property][isProxySymbol]) {
|
|
22486
22719
|
target[property] = undefined;
|
|
22487
22720
|
|
|
22488
|
-
const listeners = this.
|
|
22721
|
+
const listeners = this._watchers.get(property);
|
|
22489
22722
|
|
|
22490
22723
|
if (listeners) {
|
|
22491
22724
|
this.#scheduleListener(listeners);
|
|
22492
22725
|
}
|
|
22493
22726
|
|
|
22494
22727
|
if (this._objectListeners.has(this.$proxy)) {
|
|
22495
|
-
const keyList =
|
|
22728
|
+
const keyList = /** @type {string[]} */ (
|
|
22729
|
+
this._objectListeners.get(this.$proxy)
|
|
22730
|
+
);
|
|
22496
22731
|
|
|
22497
22732
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22498
22733
|
const key = keyList[i];
|
|
22499
22734
|
|
|
22500
|
-
const currentListeners = this.
|
|
22735
|
+
const currentListeners = this._watchers.get(key);
|
|
22501
22736
|
|
|
22502
22737
|
if (currentListeners) this.#scheduleListener(currentListeners);
|
|
22503
22738
|
}
|
|
@@ -22514,17 +22749,19 @@ class Scope {
|
|
|
22514
22749
|
delete target[property];
|
|
22515
22750
|
|
|
22516
22751
|
if (this._objectListeners.has(this.$proxy)) {
|
|
22517
|
-
const keyList =
|
|
22752
|
+
const keyList = /** @type {string[]} */ (
|
|
22753
|
+
this._objectListeners.get(this.$proxy)
|
|
22754
|
+
);
|
|
22518
22755
|
|
|
22519
22756
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22520
22757
|
const key = keyList[i];
|
|
22521
22758
|
|
|
22522
|
-
const listeners = this.
|
|
22759
|
+
const listeners = this._watchers.get(key);
|
|
22523
22760
|
|
|
22524
22761
|
if (listeners) this.#scheduleListener(listeners);
|
|
22525
22762
|
}
|
|
22526
22763
|
} else {
|
|
22527
|
-
const listeners = this.
|
|
22764
|
+
const listeners = this._watchers.get(property);
|
|
22528
22765
|
|
|
22529
22766
|
if (listeners) {
|
|
22530
22767
|
this.#scheduleListener(listeners, target[property]);
|
|
@@ -22534,13 +22771,15 @@ class Scope {
|
|
|
22534
22771
|
return true;
|
|
22535
22772
|
}
|
|
22536
22773
|
|
|
22537
|
-
/**
|
|
22774
|
+
/**
|
|
22775
|
+
* @param {Object & Record<string, any>} value
|
|
22776
|
+
*/
|
|
22538
22777
|
#checkeListenersForAllKeys(value) {
|
|
22539
22778
|
if (isUndefined(value)) {
|
|
22540
22779
|
return;
|
|
22541
22780
|
}
|
|
22542
22781
|
keys(value).forEach((k) => {
|
|
22543
|
-
const listeners = this.
|
|
22782
|
+
const listeners = this._watchers.get(k);
|
|
22544
22783
|
|
|
22545
22784
|
if (listeners) {
|
|
22546
22785
|
this.#scheduleListener(listeners);
|
|
@@ -22554,7 +22793,7 @@ class Scope {
|
|
|
22554
22793
|
|
|
22555
22794
|
/**
|
|
22556
22795
|
* @param {import('./interface.ts').Listener[]} listeners
|
|
22557
|
-
* @param {
|
|
22796
|
+
* @param {(listeners: import('./interface').Listener[]) => import('./interface').Listener[]} filter
|
|
22558
22797
|
*/
|
|
22559
22798
|
#scheduleListener(listeners, filter = (val) => val) {
|
|
22560
22799
|
queueMicrotask(() => {
|
|
@@ -22565,11 +22804,8 @@ class Scope {
|
|
|
22565
22804
|
while (index < filteredListeners.length) {
|
|
22566
22805
|
const listener = filteredListeners[index];
|
|
22567
22806
|
|
|
22568
|
-
|
|
22569
|
-
|
|
22570
|
-
} else {
|
|
22571
|
-
this.#notifyListener(listener, this.$target);
|
|
22572
|
-
}
|
|
22807
|
+
this.#notifyListener(listener, this.$target);
|
|
22808
|
+
|
|
22573
22809
|
index++;
|
|
22574
22810
|
}
|
|
22575
22811
|
});
|
|
@@ -22606,9 +22842,20 @@ class Scope {
|
|
|
22606
22842
|
};
|
|
22607
22843
|
}
|
|
22608
22844
|
|
|
22609
|
-
const expr = /** @type {
|
|
22610
|
-
get._decoratedNode.body[0]
|
|
22611
|
-
|
|
22845
|
+
const expr = /** @type {import("../parse/ast/ast-node.ts").ASTNode} */ (
|
|
22846
|
+
/** @type {ExpressionNode & BodyNode} */ (get._decoratedNode.body[0])
|
|
22847
|
+
.expression
|
|
22848
|
+
);
|
|
22849
|
+
|
|
22850
|
+
if (!listenerFn) {
|
|
22851
|
+
let res = get(this.$target);
|
|
22852
|
+
|
|
22853
|
+
while (isFunction(res)) {
|
|
22854
|
+
res = res(this.$target);
|
|
22855
|
+
}
|
|
22856
|
+
|
|
22857
|
+
return undefined;
|
|
22858
|
+
}
|
|
22612
22859
|
|
|
22613
22860
|
/** @type {ng.Listener} */
|
|
22614
22861
|
const listener = {
|
|
@@ -22623,6 +22870,9 @@ class Scope {
|
|
|
22623
22870
|
// simplest case
|
|
22624
22871
|
let key = /** @type {LiteralNode} */ (expr).name;
|
|
22625
22872
|
|
|
22873
|
+
/**
|
|
22874
|
+
* @type {string[]}
|
|
22875
|
+
*/
|
|
22626
22876
|
const keySet = [];
|
|
22627
22877
|
|
|
22628
22878
|
const { type } = expr;
|
|
@@ -22631,15 +22881,6 @@ class Scope {
|
|
|
22631
22881
|
// 3
|
|
22632
22882
|
case ASTType._AssignmentExpression:
|
|
22633
22883
|
// assignment calls without listener functions
|
|
22634
|
-
if (!listenerFn) {
|
|
22635
|
-
let res = get(this.$target);
|
|
22636
|
-
|
|
22637
|
-
while (isFunction(res)) {
|
|
22638
|
-
res = res(this.$target);
|
|
22639
|
-
}
|
|
22640
|
-
|
|
22641
|
-
return undefined;
|
|
22642
|
-
}
|
|
22643
22884
|
key = /** @type {LiteralNode} */ (
|
|
22644
22885
|
/** @type {ExpressionNode} */ (expr).left
|
|
22645
22886
|
)?.name;
|
|
@@ -22651,7 +22892,7 @@ class Scope {
|
|
|
22651
22892
|
/** @type {BodyNode} */ (expr).toWatch[0]
|
|
22652
22893
|
)?.test
|
|
22653
22894
|
)?.name;
|
|
22654
|
-
listener.property.push(key);
|
|
22895
|
+
listener.property.push(/** @type {string} */ (key));
|
|
22655
22896
|
break;
|
|
22656
22897
|
}
|
|
22657
22898
|
// 5
|
|
@@ -22677,7 +22918,10 @@ class Scope {
|
|
|
22677
22918
|
for (let i = 0, l = keyList.length; i < l; i++) {
|
|
22678
22919
|
const deregisterKey = keyList[i];
|
|
22679
22920
|
|
|
22680
|
-
this.#deregisterKey(
|
|
22921
|
+
this.#deregisterKey(
|
|
22922
|
+
/** @type {string} */ (deregisterKey),
|
|
22923
|
+
listener.id,
|
|
22924
|
+
);
|
|
22681
22925
|
}
|
|
22682
22926
|
};
|
|
22683
22927
|
}
|
|
@@ -22726,7 +22970,10 @@ class Scope {
|
|
|
22726
22970
|
).name
|
|
22727
22971
|
: /** @type {LiteralNode} */ (x).name;
|
|
22728
22972
|
|
|
22729
|
-
this.#deregisterKey(
|
|
22973
|
+
this.#deregisterKey(
|
|
22974
|
+
/** @type {string} */ (deregisterKey),
|
|
22975
|
+
listener.id,
|
|
22976
|
+
);
|
|
22730
22977
|
}
|
|
22731
22978
|
};
|
|
22732
22979
|
}
|
|
@@ -22757,7 +23004,10 @@ class Scope {
|
|
|
22757
23004
|
const x = toWatch[i];
|
|
22758
23005
|
|
|
22759
23006
|
if (!isDefined(x)) continue;
|
|
22760
|
-
this.#registerKey(
|
|
23007
|
+
this.#registerKey(
|
|
23008
|
+
/** @type {string} */ (/** @type {LiteralNode} */ (x).name),
|
|
23009
|
+
listener,
|
|
23010
|
+
);
|
|
22761
23011
|
this.#scheduleListener([listener]);
|
|
22762
23012
|
}
|
|
22763
23013
|
|
|
@@ -22767,7 +23017,7 @@ class Scope {
|
|
|
22767
23017
|
|
|
22768
23018
|
if (!isDefined(x)) continue;
|
|
22769
23019
|
this.#deregisterKey(
|
|
22770
|
-
/** @type {LiteralNode} */ (x).name,
|
|
23020
|
+
/** @type {string} */ (/** @type {LiteralNode} */ (x).name),
|
|
22771
23021
|
listener.id,
|
|
22772
23022
|
);
|
|
22773
23023
|
}
|
|
@@ -22787,7 +23037,7 @@ class Scope {
|
|
|
22787
23037
|
).name;
|
|
22788
23038
|
}
|
|
22789
23039
|
|
|
22790
|
-
listener.property.push(key);
|
|
23040
|
+
listener.property.push(/** @type {string} */ (key));
|
|
22791
23041
|
|
|
22792
23042
|
if (watchProp !== key) {
|
|
22793
23043
|
// Handle nested expression call
|
|
@@ -22798,10 +23048,12 @@ class Scope {
|
|
|
22798
23048
|
)(/** @type {Scope} */ (listener.originalTarget));
|
|
22799
23049
|
|
|
22800
23050
|
if (potentialProxy && this._foreignProxies.has(potentialProxy)) {
|
|
22801
|
-
potentialProxy.$handler
|
|
23051
|
+
potentialProxy.$handler._registerForeignKey(key, listener);
|
|
22802
23052
|
potentialProxy.$handler.#scheduleListener([listener]);
|
|
22803
23053
|
|
|
22804
23054
|
return () => {
|
|
23055
|
+
potentialProxy.$handler._deregisterForeignKey(key, listener.id);
|
|
23056
|
+
|
|
22805
23057
|
return potentialProxy.$handler.#deregisterKey(key, listener.id);
|
|
22806
23058
|
};
|
|
22807
23059
|
}
|
|
@@ -22811,7 +23063,9 @@ class Scope {
|
|
|
22811
23063
|
|
|
22812
23064
|
// 10
|
|
22813
23065
|
case ASTType._Identifier: {
|
|
22814
|
-
listener.property.push(
|
|
23066
|
+
listener.property.push(
|
|
23067
|
+
/** @type {string} */ (/** @type {LiteralNode} */ (expr).name),
|
|
23068
|
+
);
|
|
22815
23069
|
break;
|
|
22816
23070
|
}
|
|
22817
23071
|
|
|
@@ -22892,7 +23146,7 @@ class Scope {
|
|
|
22892
23146
|
const listenerObject = listener.watchFn(this.$target);
|
|
22893
23147
|
|
|
22894
23148
|
if (isObject(listenerObject)) {
|
|
22895
|
-
this._objectListeners.set(listenerObject, [key]);
|
|
23149
|
+
this._objectListeners.set(listenerObject, [/** @type {string} */ (key)]);
|
|
22896
23150
|
}
|
|
22897
23151
|
|
|
22898
23152
|
if (keySet.length > 0) {
|
|
@@ -22900,7 +23154,7 @@ class Scope {
|
|
|
22900
23154
|
this.#registerKey(keySet[i], listener);
|
|
22901
23155
|
}
|
|
22902
23156
|
} else {
|
|
22903
|
-
this.#registerKey(key, listener);
|
|
23157
|
+
this.#registerKey(/** @type {string} */ (key), listener);
|
|
22904
23158
|
}
|
|
22905
23159
|
|
|
22906
23160
|
if (!lazy) {
|
|
@@ -22921,26 +23175,27 @@ class Scope {
|
|
|
22921
23175
|
|
|
22922
23176
|
return res;
|
|
22923
23177
|
} else {
|
|
22924
|
-
return this.#deregisterKey(key, listener.id);
|
|
23178
|
+
return this.#deregisterKey(/** @type {string} */ (key), listener.id);
|
|
22925
23179
|
}
|
|
22926
23180
|
};
|
|
22927
23181
|
}
|
|
22928
23182
|
|
|
23183
|
+
/**
|
|
23184
|
+
* @param {ng.Scope} [childInstance]
|
|
23185
|
+
* @returns {Proxy<ng.Scope> & ng.Scope}
|
|
23186
|
+
*/
|
|
22929
23187
|
$new(childInstance) {
|
|
22930
23188
|
let child;
|
|
22931
23189
|
|
|
22932
23190
|
if (childInstance) {
|
|
22933
|
-
|
|
23191
|
+
const proto = Object.getPrototypeOf(childInstance);
|
|
23192
|
+
|
|
23193
|
+
// If child is plain object, or already inherits from target, set prototype to target
|
|
23194
|
+
if (proto === Object.prototype || proto === this.$target) {
|
|
22934
23195
|
Object.setPrototypeOf(childInstance, this.$target);
|
|
22935
23196
|
} else {
|
|
22936
|
-
|
|
22937
|
-
|
|
22938
|
-
} else {
|
|
22939
|
-
Object.setPrototypeOf(
|
|
22940
|
-
Object.getPrototypeOf(childInstance) || childInstance,
|
|
22941
|
-
this.$target,
|
|
22942
|
-
);
|
|
22943
|
-
}
|
|
23197
|
+
// If child has some other prototype, preserve it but link to this.$target
|
|
23198
|
+
Object.setPrototypeOf(proto || childInstance, this.$target);
|
|
22944
23199
|
}
|
|
22945
23200
|
|
|
22946
23201
|
child = childInstance;
|
|
@@ -22950,51 +23205,73 @@ class Scope {
|
|
|
22950
23205
|
|
|
22951
23206
|
const proxy = new Proxy(child, new Scope(this));
|
|
22952
23207
|
|
|
22953
|
-
this
|
|
23208
|
+
this._children.push(proxy);
|
|
22954
23209
|
|
|
22955
23210
|
return proxy;
|
|
22956
23211
|
}
|
|
22957
23212
|
|
|
23213
|
+
/**
|
|
23214
|
+
* @param {ng.Scope} [instance]
|
|
23215
|
+
* @returns {Proxy<ng.Scope> & ng.Scope}
|
|
23216
|
+
*/
|
|
22958
23217
|
$newIsolate(instance) {
|
|
22959
23218
|
const child = instance ? Object.create(instance) : Object.create(null);
|
|
22960
23219
|
|
|
22961
23220
|
const proxy = new Proxy(child, new Scope(this, this.$root));
|
|
22962
23221
|
|
|
22963
|
-
this
|
|
23222
|
+
this._children.push(proxy);
|
|
22964
23223
|
|
|
22965
23224
|
return proxy;
|
|
22966
23225
|
}
|
|
22967
23226
|
|
|
23227
|
+
/**
|
|
23228
|
+
* @param {ng.Scope} parentInstance
|
|
23229
|
+
* @returns {Proxy<ng.Scope> & ng.Scope}
|
|
23230
|
+
*/
|
|
22968
23231
|
$transcluded(parentInstance) {
|
|
22969
23232
|
const child = Object.create(this.$target);
|
|
22970
23233
|
|
|
22971
23234
|
const proxy = new Proxy(child, new Scope(this, parentInstance));
|
|
22972
23235
|
|
|
22973
|
-
this
|
|
23236
|
+
this._children.push(proxy);
|
|
22974
23237
|
|
|
22975
23238
|
return proxy;
|
|
22976
23239
|
}
|
|
22977
23240
|
|
|
22978
|
-
/**
|
|
23241
|
+
/**
|
|
23242
|
+
* @param {string} key
|
|
23243
|
+
* @param {import("./interface.ts").Listener} listener
|
|
23244
|
+
*/
|
|
22979
23245
|
#registerKey(key, listener) {
|
|
22980
|
-
if (this.
|
|
22981
|
-
|
|
23246
|
+
if (this._watchers.has(key)) {
|
|
23247
|
+
/** @type {import("./interface.ts").Listener[]} */ (
|
|
23248
|
+
this._watchers.get(key)
|
|
23249
|
+
).push(listener);
|
|
22982
23250
|
} else {
|
|
22983
|
-
this.
|
|
23251
|
+
this._watchers.set(key, [listener]);
|
|
22984
23252
|
}
|
|
22985
23253
|
}
|
|
22986
23254
|
|
|
22987
|
-
/**
|
|
22988
|
-
|
|
23255
|
+
/**
|
|
23256
|
+
* @param {string} key
|
|
23257
|
+
* @param {import("./interface.ts").Listener} listener
|
|
23258
|
+
*/
|
|
23259
|
+
_registerForeignKey(key, listener) {
|
|
22989
23260
|
if (this._foreignListeners.has(key)) {
|
|
22990
|
-
|
|
23261
|
+
/** @type {import("./interface.ts").Listener[]} */ (
|
|
23262
|
+
this._foreignListeners.get(key)
|
|
23263
|
+
).push(listener);
|
|
22991
23264
|
} else {
|
|
22992
23265
|
this._foreignListeners.set(key, [listener]);
|
|
22993
23266
|
}
|
|
22994
23267
|
}
|
|
22995
23268
|
|
|
23269
|
+
/**
|
|
23270
|
+
* @param {string} key
|
|
23271
|
+
* @param {number} id
|
|
23272
|
+
*/
|
|
22996
23273
|
#deregisterKey(key, id) {
|
|
22997
|
-
const listenerList = this.
|
|
23274
|
+
const listenerList = this._watchers.get(key);
|
|
22998
23275
|
|
|
22999
23276
|
if (!listenerList) return false;
|
|
23000
23277
|
|
|
@@ -23005,30 +23282,45 @@ class Scope {
|
|
|
23005
23282
|
listenerList.splice(index, 1);
|
|
23006
23283
|
|
|
23007
23284
|
if (listenerList.length) {
|
|
23008
|
-
this.
|
|
23285
|
+
this._watchers.set(key, listenerList);
|
|
23009
23286
|
} else {
|
|
23010
|
-
this.
|
|
23287
|
+
this._watchers.delete(key);
|
|
23011
23288
|
}
|
|
23012
23289
|
|
|
23013
23290
|
return true;
|
|
23014
23291
|
}
|
|
23015
23292
|
|
|
23016
|
-
|
|
23017
|
-
|
|
23018
|
-
|
|
23293
|
+
/**
|
|
23294
|
+
* @param {string} key
|
|
23295
|
+
* @param {number} id
|
|
23296
|
+
*/
|
|
23297
|
+
_deregisterForeignKey(key, id) {
|
|
23298
|
+
const listenerList = this._foreignListeners.get(key);
|
|
23019
23299
|
|
|
23020
|
-
|
|
23021
|
-
// if (index === -1) return false;
|
|
23300
|
+
if (!listenerList) return false;
|
|
23022
23301
|
|
|
23023
|
-
|
|
23024
|
-
|
|
23025
|
-
|
|
23026
|
-
|
|
23027
|
-
|
|
23028
|
-
|
|
23029
|
-
|
|
23030
|
-
|
|
23302
|
+
const index = listenerList.findIndex((x) => x.id === id);
|
|
23303
|
+
|
|
23304
|
+
if (index === -1) return false;
|
|
23305
|
+
|
|
23306
|
+
listenerList.splice(index, 1);
|
|
23307
|
+
|
|
23308
|
+
if (listenerList.length) {
|
|
23309
|
+
this._foreignListeners.set(key, listenerList);
|
|
23310
|
+
} else {
|
|
23311
|
+
this._foreignListeners.delete(key);
|
|
23312
|
+
}
|
|
23313
|
+
|
|
23314
|
+
return true;
|
|
23315
|
+
}
|
|
23031
23316
|
|
|
23317
|
+
/**
|
|
23318
|
+
* Evaluates an Angular expression in the context of this scope.
|
|
23319
|
+
*
|
|
23320
|
+
* @param {string} expr - Angular expression to evaluate
|
|
23321
|
+
* @param {Record<string, any>} [locals] - Optional local variables
|
|
23322
|
+
* @returns {any}
|
|
23323
|
+
*/
|
|
23032
23324
|
$eval(expr, locals) {
|
|
23033
23325
|
const fn = $parse(expr);
|
|
23034
23326
|
|
|
@@ -23108,7 +23400,7 @@ class Scope {
|
|
|
23108
23400
|
/**
|
|
23109
23401
|
* @param {string} name
|
|
23110
23402
|
* @param {...any} args
|
|
23111
|
-
* @returns {
|
|
23403
|
+
* @returns {ng.ScopeEvent | undefined}
|
|
23112
23404
|
*/
|
|
23113
23405
|
$emit(name, ...args) {
|
|
23114
23406
|
return this.#eventHelper(
|
|
@@ -23130,8 +23422,10 @@ class Scope {
|
|
|
23130
23422
|
}
|
|
23131
23423
|
|
|
23132
23424
|
/**
|
|
23133
|
-
*
|
|
23134
|
-
* @
|
|
23425
|
+
* Internal event propagation helper
|
|
23426
|
+
* @param {{ name: string, event?: ng.ScopeEvent, broadcast: boolean }} param0 - Event info
|
|
23427
|
+
* @param {...any} args - Additional arguments passed to listeners
|
|
23428
|
+
* @returns {ng.ScopeEvent|undefined}
|
|
23135
23429
|
*/
|
|
23136
23430
|
#eventHelper({ name, event, broadcast }, ...args) {
|
|
23137
23431
|
if (!broadcast) {
|
|
@@ -23148,18 +23442,18 @@ class Scope {
|
|
|
23148
23442
|
}
|
|
23149
23443
|
|
|
23150
23444
|
if (event) {
|
|
23151
|
-
event.currentScope = this.$
|
|
23445
|
+
event.currentScope = this.$proxy;
|
|
23152
23446
|
} else {
|
|
23153
23447
|
event = event || {
|
|
23154
23448
|
name,
|
|
23155
|
-
targetScope: this.$
|
|
23156
|
-
currentScope: this.$
|
|
23449
|
+
targetScope: this.$proxy,
|
|
23450
|
+
currentScope: this.$proxy,
|
|
23157
23451
|
stopped: false,
|
|
23158
23452
|
stopPropagation() {
|
|
23159
|
-
event.stopped = true;
|
|
23453
|
+
/** @type {ng.ScopeEvent} */ (event).stopped = true;
|
|
23160
23454
|
},
|
|
23161
23455
|
preventDefault() {
|
|
23162
|
-
event.defaultPrevented = true;
|
|
23456
|
+
/** @type {ng.ScopeEvent} */ (event).defaultPrevented = true;
|
|
23163
23457
|
},
|
|
23164
23458
|
defaultPrevented: false,
|
|
23165
23459
|
};
|
|
@@ -23199,8 +23493,8 @@ class Scope {
|
|
|
23199
23493
|
}
|
|
23200
23494
|
|
|
23201
23495
|
if (broadcast) {
|
|
23202
|
-
if (this
|
|
23203
|
-
this
|
|
23496
|
+
if (this._children.length > 0) {
|
|
23497
|
+
this._children.forEach((child) => {
|
|
23204
23498
|
event = child.$handler.#eventHelper(
|
|
23205
23499
|
{ name, event, broadcast },
|
|
23206
23500
|
...args,
|
|
@@ -23238,7 +23532,7 @@ class Scope {
|
|
|
23238
23532
|
|
|
23239
23533
|
this.$broadcast("$destroy");
|
|
23240
23534
|
|
|
23241
|
-
for (const [key, val] of this.
|
|
23535
|
+
for (const [key, val] of this._watchers) {
|
|
23242
23536
|
for (let i = val.length - 1; i >= 0; i--) {
|
|
23243
23537
|
if (val[i].scopeId === this.$id) {
|
|
23244
23538
|
val.splice(i, 1);
|
|
@@ -23246,16 +23540,16 @@ class Scope {
|
|
|
23246
23540
|
}
|
|
23247
23541
|
|
|
23248
23542
|
if (val.length === 0) {
|
|
23249
|
-
this.
|
|
23543
|
+
this._watchers.delete(key);
|
|
23250
23544
|
} else {
|
|
23251
|
-
this.
|
|
23545
|
+
this._watchers.set(key, val);
|
|
23252
23546
|
}
|
|
23253
23547
|
}
|
|
23254
23548
|
|
|
23255
23549
|
if (this.#isRoot()) {
|
|
23256
|
-
this.
|
|
23550
|
+
this._watchers.clear();
|
|
23257
23551
|
} else {
|
|
23258
|
-
const children = this.$parent
|
|
23552
|
+
const children = /** @type {Scope} */ (this.$parent)._children;
|
|
23259
23553
|
|
|
23260
23554
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
23261
23555
|
if (children[i].$id === this.$id) {
|
|
@@ -23272,6 +23566,7 @@ class Scope {
|
|
|
23272
23566
|
/**
|
|
23273
23567
|
* @internal
|
|
23274
23568
|
* @param {import('./interface.ts').Listener} listener - The property path that was changed.
|
|
23569
|
+
* @param {Scope | typeof Proxy<Scope> | undefined} target
|
|
23275
23570
|
*/
|
|
23276
23571
|
#notifyListener(listener, target) {
|
|
23277
23572
|
const { originalTarget, listenerFn, watchFn } = listener;
|
|
@@ -23298,7 +23593,7 @@ class Scope {
|
|
|
23298
23593
|
listenerFn(newVal, originalTarget);
|
|
23299
23594
|
|
|
23300
23595
|
while ($postUpdateQueue.length) {
|
|
23301
|
-
const fn = $postUpdateQueue.shift();
|
|
23596
|
+
const fn = /** @type {Function} */ ($postUpdateQueue.shift());
|
|
23302
23597
|
|
|
23303
23598
|
fn();
|
|
23304
23599
|
}
|
|
@@ -23310,7 +23605,7 @@ class Scope {
|
|
|
23310
23605
|
/* @ignore */
|
|
23311
23606
|
$flushQueue() {
|
|
23312
23607
|
while ($postUpdateQueue.length) {
|
|
23313
|
-
$postUpdateQueue.shift()();
|
|
23608
|
+
/** @type {Function} */ ($postUpdateQueue.shift())();
|
|
23314
23609
|
}
|
|
23315
23610
|
}
|
|
23316
23611
|
|
|
@@ -23330,7 +23625,7 @@ class Scope {
|
|
|
23330
23625
|
} else {
|
|
23331
23626
|
let res = undefined;
|
|
23332
23627
|
|
|
23333
|
-
for (const child of this
|
|
23628
|
+
for (const child of this._children) {
|
|
23334
23629
|
const found = child.$getById(id);
|
|
23335
23630
|
|
|
23336
23631
|
if (found) {
|
|
@@ -23351,15 +23646,15 @@ class Scope {
|
|
|
23351
23646
|
const stack = [this.$root];
|
|
23352
23647
|
|
|
23353
23648
|
while (stack.length) {
|
|
23354
|
-
const scope = stack.pop();
|
|
23649
|
+
const scope = /** @type {Scope} */ (stack.pop());
|
|
23355
23650
|
|
|
23356
23651
|
if (scope.$scopename === name) {
|
|
23357
23652
|
return scope;
|
|
23358
23653
|
}
|
|
23359
23654
|
|
|
23360
|
-
if (scope
|
|
23361
|
-
for (let i = scope
|
|
23362
|
-
stack.push(scope
|
|
23655
|
+
if (scope._children?.length) {
|
|
23656
|
+
for (let i = scope._children.length - 1; i >= 0; i--) {
|
|
23657
|
+
stack.push(scope._children[i]);
|
|
23363
23658
|
}
|
|
23364
23659
|
}
|
|
23365
23660
|
}
|
|
@@ -23379,7 +23674,7 @@ function calculateWatcherCount(model) {
|
|
|
23379
23674
|
|
|
23380
23675
|
let count = 0;
|
|
23381
23676
|
|
|
23382
|
-
for (const watchers of model.
|
|
23677
|
+
for (const watchers of model._watchers.values()) {
|
|
23383
23678
|
for (let i = 0, l = watchers.length; i < l; i++) {
|
|
23384
23679
|
if (childIds.has(watchers[i].scopeId)) {
|
|
23385
23680
|
count++;
|
|
@@ -23400,14 +23695,14 @@ function collectChildIds(child) {
|
|
|
23400
23695
|
const stack = [child];
|
|
23401
23696
|
|
|
23402
23697
|
while (stack.length) {
|
|
23403
|
-
const node = stack.pop();
|
|
23698
|
+
const node = /** @type {Scope} */ (stack.pop());
|
|
23404
23699
|
|
|
23405
23700
|
if (!ids.has(node.$id)) {
|
|
23406
23701
|
ids.add(node.$id);
|
|
23407
23702
|
|
|
23408
|
-
if (node
|
|
23409
|
-
for (let i = 0, l = node
|
|
23410
|
-
stack.push(node
|
|
23703
|
+
if (node._children) {
|
|
23704
|
+
for (let i = 0, l = node._children.length; i < l; i++) {
|
|
23705
|
+
stack.push(node._children[i]);
|
|
23411
23706
|
}
|
|
23412
23707
|
}
|
|
23413
23708
|
}
|
|
@@ -23693,7 +23988,7 @@ class NgMessageCtrl {
|
|
|
23693
23988
|
message: messageCtrl,
|
|
23694
23989
|
};
|
|
23695
23990
|
this.insertMessageNode(this.$element, comment, nextKey);
|
|
23696
|
-
comment
|
|
23991
|
+
comment._ngMessageNode = nextKey;
|
|
23697
23992
|
this.latestKey++;
|
|
23698
23993
|
}
|
|
23699
23994
|
|
|
@@ -23704,9 +23999,9 @@ class NgMessageCtrl {
|
|
|
23704
23999
|
if (isDefault) {
|
|
23705
24000
|
delete this.default;
|
|
23706
24001
|
} else {
|
|
23707
|
-
const key = comment
|
|
24002
|
+
const key = comment._ngMessageNode;
|
|
23708
24003
|
|
|
23709
|
-
delete comment
|
|
24004
|
+
delete comment._ngMessageNode;
|
|
23710
24005
|
this.removeMessageNode(this.$element, comment, key);
|
|
23711
24006
|
delete this.messages[key];
|
|
23712
24007
|
}
|
|
@@ -23719,7 +24014,7 @@ class NgMessageCtrl {
|
|
|
23719
24014
|
const parentLookup = [];
|
|
23720
24015
|
|
|
23721
24016
|
while (prevNode && prevNode !== parent) {
|
|
23722
|
-
const prevKey = prevNode
|
|
24017
|
+
const prevKey = prevNode._ngMessageNode;
|
|
23723
24018
|
|
|
23724
24019
|
if (prevKey && prevKey.length) {
|
|
23725
24020
|
return this.messages[prevKey];
|
|
@@ -24657,6 +24952,223 @@ class AnimateRunner {
|
|
|
24657
24952
|
}
|
|
24658
24953
|
}
|
|
24659
24954
|
|
|
24955
|
+
const KEY = "$animId";
|
|
24956
|
+
|
|
24957
|
+
/**
|
|
24958
|
+
* Animation cache responsible for:
|
|
24959
|
+
* - Generating stable animation cache keys
|
|
24960
|
+
* - Tracking cached animation results
|
|
24961
|
+
* - Avoiding repeated animation work
|
|
24962
|
+
*
|
|
24963
|
+
* Cache keys are scoped per parent node to prevent collisions between
|
|
24964
|
+
* structurally identical nodes in different DOM subtrees.
|
|
24965
|
+
*
|
|
24966
|
+
* @internal
|
|
24967
|
+
*/
|
|
24968
|
+
class AnimateCache {
|
|
24969
|
+
/** @type {Map<string, import("./interface.ts").CacheEntry>} */
|
|
24970
|
+
#cache = new Map();
|
|
24971
|
+
|
|
24972
|
+
/**
|
|
24973
|
+
* Monotonically increasing counter used to assign synthetic parent IDs.
|
|
24974
|
+
* IDs are stored directly on parent nodes under `$animId`.
|
|
24975
|
+
*
|
|
24976
|
+
*/
|
|
24977
|
+
#parentCounter = 0;
|
|
24978
|
+
|
|
24979
|
+
/**
|
|
24980
|
+
* Generates a stable cache key for an animation invocation.
|
|
24981
|
+
*
|
|
24982
|
+
* The key is derived from:
|
|
24983
|
+
* - The node's parent (used as a cache namespace)
|
|
24984
|
+
* - The animation method (e.g. enter, leave, addClass)
|
|
24985
|
+
* - The node's current CSS class state
|
|
24986
|
+
* - Any classes being added or removed
|
|
24987
|
+
*
|
|
24988
|
+
* If the node is not attached to the DOM, the node itself is used
|
|
24989
|
+
* as the parent scope to avoid key collisions.
|
|
24990
|
+
*
|
|
24991
|
+
* @param {HTMLElement} node
|
|
24992
|
+
* Target element being animated.
|
|
24993
|
+
* @param {string} method
|
|
24994
|
+
* Animation method name.
|
|
24995
|
+
* @param {string} [addClass]
|
|
24996
|
+
* CSS class scheduled to be added during the animation.
|
|
24997
|
+
* @param {string} [removeClass]
|
|
24998
|
+
* CSS class scheduled to be removed during the animation.
|
|
24999
|
+
*
|
|
25000
|
+
* @returns {string}
|
|
25001
|
+
* A unique, deterministic cache key.
|
|
25002
|
+
*/
|
|
25003
|
+
_cacheKey(node, method, addClass, removeClass) {
|
|
25004
|
+
const parent = /** @type {HTMLElement & Record<string, number>} */ (
|
|
25005
|
+
node.parentNode ?? node
|
|
25006
|
+
);
|
|
25007
|
+
|
|
25008
|
+
const parentID = parent[KEY] ?? (parent[KEY] = ++this.#parentCounter);
|
|
25009
|
+
|
|
25010
|
+
const parts = [parentID, method, node.getAttribute("class")];
|
|
25011
|
+
|
|
25012
|
+
if (addClass) parts.push(addClass);
|
|
25013
|
+
|
|
25014
|
+
if (removeClass) parts.push(removeClass);
|
|
25015
|
+
|
|
25016
|
+
return parts.join(" ");
|
|
25017
|
+
}
|
|
25018
|
+
|
|
25019
|
+
/**
|
|
25020
|
+
* Determines whether a cache entry exists but is marked as invalid.
|
|
25021
|
+
*
|
|
25022
|
+
* This is typically used to detect animations that were previously
|
|
25023
|
+
* cached but resolved without a duration.
|
|
25024
|
+
*
|
|
25025
|
+
* @param {string} key
|
|
25026
|
+
* Cache key to test.
|
|
25027
|
+
* @returns {boolean}
|
|
25028
|
+
* True if an invalid cache entry exists, false otherwise.
|
|
25029
|
+
*/
|
|
25030
|
+
_containsCachedAnimationWithoutDuration(key) {
|
|
25031
|
+
const entry = this.#cache.get(key);
|
|
25032
|
+
|
|
25033
|
+
return !!entry && !entry.isValid;
|
|
25034
|
+
}
|
|
25035
|
+
|
|
25036
|
+
/**
|
|
25037
|
+
* Clears all cached animation entries.
|
|
25038
|
+
*
|
|
25039
|
+
* Does not reset parent IDs.
|
|
25040
|
+
*
|
|
25041
|
+
* @returns {void}
|
|
25042
|
+
*/
|
|
25043
|
+
_flush() {
|
|
25044
|
+
this.#cache.clear();
|
|
25045
|
+
}
|
|
25046
|
+
|
|
25047
|
+
/**
|
|
25048
|
+
* Returns the number of times a cache entry has been used.
|
|
25049
|
+
*
|
|
25050
|
+
* @param {string} key
|
|
25051
|
+
* Cache key to query.
|
|
25052
|
+
* @returns {number}
|
|
25053
|
+
* Usage count, or 0 if the entry does not exist.
|
|
25054
|
+
*/
|
|
25055
|
+
_count(key) {
|
|
25056
|
+
return this.#cache.get(key)?.total ?? 0;
|
|
25057
|
+
}
|
|
25058
|
+
|
|
25059
|
+
/**
|
|
25060
|
+
* Retrieves the cached value associated with a cache key.
|
|
25061
|
+
*
|
|
25062
|
+
* @param {string} key
|
|
25063
|
+
* Cache key to retrieve.
|
|
25064
|
+
* @returns {any}
|
|
25065
|
+
* Cached value, or undefined if not present.
|
|
25066
|
+
*/
|
|
25067
|
+
_get(key) {
|
|
25068
|
+
return this.#cache.get(key)?.value;
|
|
25069
|
+
}
|
|
25070
|
+
|
|
25071
|
+
/**
|
|
25072
|
+
* Inserts or updates a cache entry.
|
|
25073
|
+
*
|
|
25074
|
+
* Existing entries will have their usage count incremented
|
|
25075
|
+
* and their value replaced.
|
|
25076
|
+
*
|
|
25077
|
+
* @param {string} key
|
|
25078
|
+
* Cache key.
|
|
25079
|
+
* @param {any} value
|
|
25080
|
+
* Value to cache.
|
|
25081
|
+
* @param {boolean} isValid
|
|
25082
|
+
* Whether the cached value is considered valid.
|
|
25083
|
+
*
|
|
25084
|
+
* @returns {void}
|
|
25085
|
+
*/
|
|
25086
|
+
_put(key, value, isValid) {
|
|
25087
|
+
const entry = this.#cache.get(key);
|
|
25088
|
+
|
|
25089
|
+
if (entry) {
|
|
25090
|
+
entry.total++;
|
|
25091
|
+
entry.value = value;
|
|
25092
|
+
} else {
|
|
25093
|
+
this.#cache.set(key, { total: 1, value, isValid });
|
|
25094
|
+
}
|
|
25095
|
+
}
|
|
25096
|
+
}
|
|
25097
|
+
|
|
25098
|
+
const animateCache = new AnimateCache();
|
|
25099
|
+
|
|
25100
|
+
/**
|
|
25101
|
+
* A requestAnimationFrame-based scheduler.
|
|
25102
|
+
*/
|
|
25103
|
+
class RafScheduler {
|
|
25104
|
+
constructor() {
|
|
25105
|
+
/**
|
|
25106
|
+
* Internal task queue, where each item is an array of functions to run.
|
|
25107
|
+
* @type {Array<() => void>}
|
|
25108
|
+
*/
|
|
25109
|
+
this._queue = [];
|
|
25110
|
+
|
|
25111
|
+
/**
|
|
25112
|
+
* ID of the currently scheduled animation frame (if any).
|
|
25113
|
+
* Used for cancellation and tracking.
|
|
25114
|
+
* @type {number|null}
|
|
25115
|
+
*/
|
|
25116
|
+
this._cancelFn = null;
|
|
25117
|
+
}
|
|
25118
|
+
|
|
25119
|
+
/**
|
|
25120
|
+
* Processes the next batch of tasks in the animation frame.
|
|
25121
|
+
* Executes the first group of functions in the queue, then
|
|
25122
|
+
* schedules the next frame if needed.
|
|
25123
|
+
*/
|
|
25124
|
+
_nextTick() {
|
|
25125
|
+
if (!this._queue.length) return;
|
|
25126
|
+
|
|
25127
|
+
while (this._queue.length) {
|
|
25128
|
+
/** @type {() => void} */ (this._queue.shift())();
|
|
25129
|
+
}
|
|
25130
|
+
|
|
25131
|
+
if (!this._cancelFn) {
|
|
25132
|
+
this._cancelFn = window.requestAnimationFrame(() => {
|
|
25133
|
+
this._cancelFn = null;
|
|
25134
|
+
this._nextTick();
|
|
25135
|
+
});
|
|
25136
|
+
}
|
|
25137
|
+
}
|
|
25138
|
+
|
|
25139
|
+
/**
|
|
25140
|
+
* The main scheduler function.
|
|
25141
|
+
* Accepts an array of functions and schedules them to run in the next available frame(s).
|
|
25142
|
+
*
|
|
25143
|
+
* @param {Array<() => void>} tasks
|
|
25144
|
+
*/
|
|
25145
|
+
_schedule(tasks) {
|
|
25146
|
+
this._queue.push(...tasks);
|
|
25147
|
+
this._nextTick();
|
|
25148
|
+
}
|
|
25149
|
+
|
|
25150
|
+
/**
|
|
25151
|
+
* Cancels any pending frame and runs the given function once the frame is idle.
|
|
25152
|
+
* Useful for debounced updates.
|
|
25153
|
+
*
|
|
25154
|
+
* @param {Function} fn - Function to run when the animation frame is quiet.
|
|
25155
|
+
*/
|
|
25156
|
+
_waitUntilQuiet(fn) {
|
|
25157
|
+
if (this._cancelFn !== null) {
|
|
25158
|
+
window.cancelAnimationFrame(this._cancelFn);
|
|
25159
|
+
this._cancelFn = null;
|
|
25160
|
+
}
|
|
25161
|
+
|
|
25162
|
+
this._cancelFn = window.requestAnimationFrame(() => {
|
|
25163
|
+
this._cancelFn = null;
|
|
25164
|
+
fn();
|
|
25165
|
+
this._nextTick();
|
|
25166
|
+
});
|
|
25167
|
+
}
|
|
25168
|
+
}
|
|
25169
|
+
|
|
25170
|
+
const rafScheduler = new RafScheduler();
|
|
25171
|
+
|
|
24660
25172
|
const ANIMATE_TIMER_KEY = $injectTokens._animateCss;
|
|
24661
25173
|
|
|
24662
25174
|
const ONE_SECOND = 1000;
|
|
@@ -24777,16 +25289,11 @@ function AnimateCssProvider() {
|
|
|
24777
25289
|
let activeClasses;
|
|
24778
25290
|
|
|
24779
25291
|
this.$get = [
|
|
24780
|
-
$injectTokens._animateCache,
|
|
24781
|
-
$injectTokens._rAFScheduler,
|
|
24782
|
-
|
|
24783
25292
|
/**
|
|
24784
25293
|
*
|
|
24785
|
-
* @param {*} $$animateCache
|
|
24786
|
-
* @param {import("./raf-scheduler").RafScheduler} $$rAFScheduler
|
|
24787
25294
|
* @returns
|
|
24788
25295
|
*/
|
|
24789
|
-
function (
|
|
25296
|
+
function () {
|
|
24790
25297
|
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
24791
25298
|
|
|
24792
25299
|
// TODO add types
|
|
@@ -24796,7 +25303,7 @@ function AnimateCssProvider() {
|
|
|
24796
25303
|
allowNoDuration,
|
|
24797
25304
|
properties,
|
|
24798
25305
|
) {
|
|
24799
|
-
let timings =
|
|
25306
|
+
let timings = animateCache._get(cacheKey);
|
|
24800
25307
|
|
|
24801
25308
|
if (!timings) {
|
|
24802
25309
|
timings = computeCssStyles(node, properties);
|
|
@@ -24815,7 +25322,7 @@ function AnimateCssProvider() {
|
|
|
24815
25322
|
|
|
24816
25323
|
// we keep putting this in multiple times even though the value and the cacheKey are the same
|
|
24817
25324
|
// because we're keeping an internal tally of how many duplicate animations are detected.
|
|
24818
|
-
|
|
25325
|
+
animateCache._put(cacheKey, timings, hasDuration);
|
|
24819
25326
|
|
|
24820
25327
|
return timings;
|
|
24821
25328
|
}
|
|
@@ -24833,8 +25340,8 @@ function AnimateCssProvider() {
|
|
|
24833
25340
|
// if we have one or more existing matches of matching elements
|
|
24834
25341
|
// containing the same parent + CSS styles (which is how cacheKey works)
|
|
24835
25342
|
// then staggering is possible
|
|
24836
|
-
if (
|
|
24837
|
-
stagger =
|
|
25343
|
+
if (animateCache._count(cacheKey) > 0) {
|
|
25344
|
+
stagger = animateCache._get(staggerCacheKey);
|
|
24838
25345
|
|
|
24839
25346
|
if (!stagger) {
|
|
24840
25347
|
const staggerClassName = pendClasses(className, "-stagger");
|
|
@@ -24851,7 +25358,7 @@ function AnimateCssProvider() {
|
|
|
24851
25358
|
|
|
24852
25359
|
node.classList.remove(staggerClassName);
|
|
24853
25360
|
|
|
24854
|
-
|
|
25361
|
+
animateCache._put(staggerCacheKey, stagger, true);
|
|
24855
25362
|
}
|
|
24856
25363
|
}
|
|
24857
25364
|
|
|
@@ -24862,25 +25369,17 @@ function AnimateCssProvider() {
|
|
|
24862
25369
|
|
|
24863
25370
|
function waitUntilQuiet(callback) {
|
|
24864
25371
|
rafWaitQueue.push(callback);
|
|
24865
|
-
|
|
24866
|
-
|
|
24867
|
-
|
|
24868
|
-
// DO NOT REMOVE THIS LINE OR REFACTOR OUT THE `pageWidth` variable.
|
|
24869
|
-
// the line below will force the browser to perform a repaint so
|
|
24870
|
-
// that all the animated elements within the animation frame will
|
|
24871
|
-
// be properly updated and drawn on screen. This is required to
|
|
24872
|
-
// ensure that the preparation animation is properly flushed so that
|
|
24873
|
-
// the active state picks up from there. DO NOT REMOVE THIS LINE.
|
|
24874
|
-
// DO NOT OPTIMIZE THIS LINE. THE MINIFIER WILL REMOVE IT OTHERWISE WHICH
|
|
24875
|
-
// WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND
|
|
24876
|
-
// WILL TAKE YEARS AWAY FROM YOUR LIFE.
|
|
25372
|
+
rafScheduler._waitUntilQuiet(() => {
|
|
25373
|
+
animateCache._flush();
|
|
24877
25374
|
|
|
24878
|
-
|
|
25375
|
+
// Forces synchronous style & layout flush.
|
|
25376
|
+
// Required to commit animation prep state before activation.
|
|
25377
|
+
document.documentElement.getBoundingClientRect();
|
|
24879
25378
|
|
|
24880
25379
|
// we use a for loop to ensure that if the queue is changed
|
|
24881
25380
|
// during this looping then it will consider new requests
|
|
24882
25381
|
for (let i = 0; i < rafWaitQueue.length; i++) {
|
|
24883
|
-
rafWaitQueue[i](
|
|
25382
|
+
rafWaitQueue[i]();
|
|
24884
25383
|
}
|
|
24885
25384
|
rafWaitQueue.length = 0;
|
|
24886
25385
|
});
|
|
@@ -24907,6 +25406,10 @@ function AnimateCssProvider() {
|
|
|
24907
25406
|
return timings;
|
|
24908
25407
|
}
|
|
24909
25408
|
|
|
25409
|
+
/**
|
|
25410
|
+
* @param {HTMLElement} element
|
|
25411
|
+
* @param {ng.AnimationOptions} initialOptions
|
|
25412
|
+
*/
|
|
24910
25413
|
return function init(element, initialOptions) {
|
|
24911
25414
|
// all of the animation functions should create
|
|
24912
25415
|
// a copy of the options data, however, if a
|
|
@@ -24914,9 +25417,11 @@ function AnimateCssProvider() {
|
|
|
24914
25417
|
let delayStyle;
|
|
24915
25418
|
|
|
24916
25419
|
// we should stick to using that
|
|
24917
|
-
let options =
|
|
24918
|
-
|
|
24919
|
-
|
|
25420
|
+
let options =
|
|
25421
|
+
initialOptions ||
|
|
25422
|
+
/** @type {ng.AnimationOptions}}*/ ({
|
|
25423
|
+
$$skipPreparationClasses: false,
|
|
25424
|
+
});
|
|
24920
25425
|
|
|
24921
25426
|
if (!options.$$prepared) {
|
|
24922
25427
|
options = prepareAnimationOptions(structuredClone(options));
|
|
@@ -24962,10 +25467,11 @@ function AnimateCssProvider() {
|
|
|
24962
25467
|
return closeAndReturnNoopAnimator();
|
|
24963
25468
|
}
|
|
24964
25469
|
|
|
24965
|
-
const method =
|
|
25470
|
+
const method = /** @type {string} */ (
|
|
24966
25471
|
options.event && isArray(options.event)
|
|
24967
25472
|
? options.event.join(" ")
|
|
24968
|
-
: options.event
|
|
25473
|
+
: options.event
|
|
25474
|
+
);
|
|
24969
25475
|
|
|
24970
25476
|
const isStructural = method && options.structural;
|
|
24971
25477
|
|
|
@@ -25021,21 +25527,23 @@ function AnimateCssProvider() {
|
|
|
25021
25527
|
|
|
25022
25528
|
let stagger;
|
|
25023
25529
|
|
|
25024
|
-
let cacheKey =
|
|
25530
|
+
let cacheKey = animateCache._cacheKey(
|
|
25025
25531
|
node,
|
|
25026
25532
|
method,
|
|
25027
25533
|
options.addClass,
|
|
25028
25534
|
options.removeClass,
|
|
25029
25535
|
);
|
|
25030
25536
|
|
|
25031
|
-
if (
|
|
25537
|
+
if (animateCache._containsCachedAnimationWithoutDuration(cacheKey)) {
|
|
25032
25538
|
preparationClasses = null;
|
|
25033
25539
|
|
|
25034
25540
|
return closeAndReturnNoopAnimator();
|
|
25035
25541
|
}
|
|
25036
25542
|
|
|
25037
|
-
if (options.stagger > 0) {
|
|
25038
|
-
const staggerVal = parseFloat(
|
|
25543
|
+
if (/** @type {number} */ (options.stagger) > 0) {
|
|
25544
|
+
const staggerVal = parseFloat(
|
|
25545
|
+
/** @type {string} */ (options.stagger),
|
|
25546
|
+
);
|
|
25039
25547
|
|
|
25040
25548
|
stagger = {
|
|
25041
25549
|
transitionDelay: staggerVal,
|
|
@@ -25067,7 +25575,7 @@ function AnimateCssProvider() {
|
|
|
25067
25575
|
temporaryStyles.push(transitionStyle);
|
|
25068
25576
|
}
|
|
25069
25577
|
|
|
25070
|
-
if (options.duration >= 0) {
|
|
25578
|
+
if (/** @type {number} */ (options.duration) >= 0) {
|
|
25071
25579
|
applyOnlyDuration = node.style.transition.length > 0;
|
|
25072
25580
|
const durationStyle = getCssTransitionDurationStyle(
|
|
25073
25581
|
options.duration,
|
|
@@ -25090,7 +25598,7 @@ function AnimateCssProvider() {
|
|
|
25090
25598
|
const itemIndex = stagger
|
|
25091
25599
|
? options.staggerIndex >= 0
|
|
25092
25600
|
? options.staggerIndex
|
|
25093
|
-
:
|
|
25601
|
+
: animateCache._count(cacheKey)
|
|
25094
25602
|
: 0;
|
|
25095
25603
|
|
|
25096
25604
|
const isFirst = itemIndex === 0;
|
|
@@ -25101,7 +25609,7 @@ function AnimateCssProvider() {
|
|
|
25101
25609
|
// transition delay to allow for the transition to naturally do it's thing. The beauty here is
|
|
25102
25610
|
// that if there is no transition defined then nothing will happen and this will also allow
|
|
25103
25611
|
// other transitions to be stacked on top of each other without any chopping them out.
|
|
25104
|
-
if (isFirst
|
|
25612
|
+
if (isFirst) {
|
|
25105
25613
|
blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
|
|
25106
25614
|
}
|
|
25107
25615
|
|
|
@@ -25133,7 +25641,7 @@ function AnimateCssProvider() {
|
|
|
25133
25641
|
|
|
25134
25642
|
if (flags.applyTransitionDuration || flags.applyAnimationDuration) {
|
|
25135
25643
|
maxDuration = options.duration
|
|
25136
|
-
? parseFloat(options.duration)
|
|
25644
|
+
? parseFloat(/** @type {string} */ (options.duration))
|
|
25137
25645
|
: maxDuration;
|
|
25138
25646
|
|
|
25139
25647
|
if (flags.applyTransitionDuration) {
|
|
@@ -25188,13 +25696,11 @@ function AnimateCssProvider() {
|
|
|
25188
25696
|
maxDelayTime = maxDelay * ONE_SECOND;
|
|
25189
25697
|
maxDurationTime = maxDuration * ONE_SECOND;
|
|
25190
25698
|
|
|
25191
|
-
|
|
25192
|
-
|
|
25193
|
-
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
stagger.animationDuration === 0;
|
|
25197
|
-
}
|
|
25699
|
+
flags.blockTransition = timings.transitionDuration > 0;
|
|
25700
|
+
flags.blockKeyframeAnimation =
|
|
25701
|
+
timings.animationDuration > 0 &&
|
|
25702
|
+
stagger.animationDelay > 0 &&
|
|
25703
|
+
stagger.animationDuration === 0;
|
|
25198
25704
|
|
|
25199
25705
|
if (options.from) {
|
|
25200
25706
|
if (options.cleanupStyles) {
|
|
@@ -25469,7 +25975,7 @@ function AnimateCssProvider() {
|
|
|
25469
25975
|
);
|
|
25470
25976
|
|
|
25471
25977
|
if (flags.recalculateTimingStyles) {
|
|
25472
|
-
cacheKey =
|
|
25978
|
+
cacheKey = animateCache._cacheKey(
|
|
25473
25979
|
node,
|
|
25474
25980
|
method,
|
|
25475
25981
|
options.addClass,
|
|
@@ -25936,8 +26442,7 @@ function AnimateQueueProvider($animateProvider) {
|
|
|
25936
26442
|
// strip comments
|
|
25937
26443
|
|
|
25938
26444
|
let element = isArray(originalElement)
|
|
25939
|
-
?
|
|
25940
|
-
originalElement.filter((x) => x.nodeName !== "#comment")[0]
|
|
26445
|
+
? originalElement.filter((x) => x.nodeName !== "#comment")[0]
|
|
25941
26446
|
: originalElement;
|
|
25942
26447
|
|
|
25943
26448
|
const node = element;
|
|
@@ -26444,6 +26949,9 @@ function AnimateJsProvider($animateProvider) {
|
|
|
26444
26949
|
function ($injector) {
|
|
26445
26950
|
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
26446
26951
|
|
|
26952
|
+
/**
|
|
26953
|
+
*
|
|
26954
|
+
*/
|
|
26447
26955
|
return function animateJs(element, event, classes, options) {
|
|
26448
26956
|
// Optional arguments
|
|
26449
26957
|
if (arguments.length === 3 && isObject(classes)) {
|
|
@@ -26645,16 +27153,29 @@ const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
|
|
|
26645
27153
|
function AnimationProvider() {
|
|
26646
27154
|
const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
|
|
26647
27155
|
|
|
27156
|
+
/**
|
|
27157
|
+
* @type {string[]}
|
|
27158
|
+
*/
|
|
26648
27159
|
const drivers = (this.drivers = []);
|
|
26649
27160
|
|
|
27161
|
+
/**
|
|
27162
|
+
* @param {Element | Node} element
|
|
27163
|
+
* @param {AnimateRunner} runner
|
|
27164
|
+
*/
|
|
26650
27165
|
function setRunner(element, runner) {
|
|
26651
27166
|
setCacheData(element, RUNNER_STORAGE_KEY, runner);
|
|
26652
27167
|
}
|
|
26653
27168
|
|
|
27169
|
+
/**
|
|
27170
|
+
* @param {Element} element
|
|
27171
|
+
*/
|
|
26654
27172
|
function removeRunner(element) {
|
|
26655
27173
|
deleteCacheData(element, RUNNER_STORAGE_KEY);
|
|
26656
27174
|
}
|
|
26657
27175
|
|
|
27176
|
+
/**
|
|
27177
|
+
* @param {Element} element
|
|
27178
|
+
*/
|
|
26658
27179
|
function getRunner(element) {
|
|
26659
27180
|
return getCacheData(element, RUNNER_STORAGE_KEY);
|
|
26660
27181
|
}
|
|
@@ -26662,17 +27183,19 @@ function AnimationProvider() {
|
|
|
26662
27183
|
this.$get = [
|
|
26663
27184
|
$injectTokens._rootScope,
|
|
26664
27185
|
$injectTokens._injector,
|
|
26665
|
-
$injectTokens._rAFScheduler,
|
|
26666
|
-
$injectTokens._animateCache,
|
|
26667
27186
|
/**
|
|
26668
27187
|
*
|
|
26669
27188
|
* @param {ng.RootScopeService} $rootScope
|
|
26670
27189
|
* @param {ng.InjectorService} $injector
|
|
26671
|
-
* @param {import("./raf-scheduler.js").RafScheduler} $$rAFScheduler
|
|
26672
|
-
* @param {*} $$animateCache
|
|
26673
27190
|
* @returns
|
|
26674
27191
|
*/
|
|
26675
|
-
function ($rootScope, $injector
|
|
27192
|
+
function ($rootScope, $injector) {
|
|
27193
|
+
/**
|
|
27194
|
+
* @type {{
|
|
27195
|
+
// this data is used by the postDigest code and passed into
|
|
27196
|
+
// the driver step function
|
|
27197
|
+
element: any; classes: string; event: any; structural: boolean; options: any; beforeStart: () => void; close: (rejected: any) => void; }[]}
|
|
27198
|
+
*/
|
|
26676
27199
|
const animationQueue = [];
|
|
26677
27200
|
|
|
26678
27201
|
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
@@ -26871,7 +27394,7 @@ function AnimationProvider() {
|
|
|
26871
27394
|
|
|
26872
27395
|
extraClasses =
|
|
26873
27396
|
(extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
|
|
26874
|
-
const cacheKey =
|
|
27397
|
+
const cacheKey = animateCache._cacheKey(
|
|
26875
27398
|
fromElement,
|
|
26876
27399
|
animationEntry.event,
|
|
26877
27400
|
extraClasses,
|
|
@@ -26890,9 +27413,7 @@ function AnimationProvider() {
|
|
|
26890
27413
|
// and it's in fact an invalid animation (something that has duration = 0)
|
|
26891
27414
|
// then we should skip all the heavy work from here on
|
|
26892
27415
|
if (
|
|
26893
|
-
|
|
26894
|
-
cacheKey,
|
|
26895
|
-
)
|
|
27416
|
+
animateCache._containsCachedAnimationWithoutDuration(cacheKey)
|
|
26896
27417
|
) {
|
|
26897
27418
|
closeFn();
|
|
26898
27419
|
|
|
@@ -26966,8 +27487,10 @@ function AnimationProvider() {
|
|
|
26966
27487
|
}
|
|
26967
27488
|
}
|
|
26968
27489
|
}
|
|
26969
|
-
|
|
26970
|
-
|
|
27490
|
+
|
|
27491
|
+
const flatFinalAnimations = finalAnimations.flat();
|
|
27492
|
+
|
|
27493
|
+
rafScheduler._schedule(flatFinalAnimations);
|
|
26971
27494
|
});
|
|
26972
27495
|
|
|
26973
27496
|
return runner;
|
|
@@ -27165,7 +27688,7 @@ function AnimationProvider() {
|
|
|
27165
27688
|
}
|
|
27166
27689
|
|
|
27167
27690
|
function handleDestroyedElement() {
|
|
27168
|
-
(event !== "leave" || !options
|
|
27691
|
+
(event !== "leave" || !options._domOperationFired) &&
|
|
27169
27692
|
getRunner(elementParam)?.end();
|
|
27170
27693
|
}
|
|
27171
27694
|
|
|
@@ -27189,191 +27712,6 @@ function AnimationProvider() {
|
|
|
27189
27712
|
];
|
|
27190
27713
|
}
|
|
27191
27714
|
|
|
27192
|
-
/**
|
|
27193
|
-
* @typedef {import('./interface.ts').RafScheduler} RafScheduler
|
|
27194
|
-
*/
|
|
27195
|
-
|
|
27196
|
-
/**
|
|
27197
|
-
* Service provider that creates a requestAnimationFrame-based scheduler.
|
|
27198
|
-
* @type {ng.ServiceProvider}
|
|
27199
|
-
*/
|
|
27200
|
-
class RafSchedulerProvider {
|
|
27201
|
-
constructor() {
|
|
27202
|
-
/**
|
|
27203
|
-
* Internal task queue, where each item is an array of functions to run.
|
|
27204
|
-
* @type {Array<Array<() => void>>}
|
|
27205
|
-
*/
|
|
27206
|
-
this._queue = [];
|
|
27207
|
-
|
|
27208
|
-
/**
|
|
27209
|
-
* ID of the currently scheduled animation frame (if any).
|
|
27210
|
-
* Used for cancellation and tracking.
|
|
27211
|
-
* @type {number|null}
|
|
27212
|
-
*/
|
|
27213
|
-
this._cancelFn = null;
|
|
27214
|
-
}
|
|
27215
|
-
|
|
27216
|
-
/**
|
|
27217
|
-
* Processes the next batch of tasks in the animation frame.
|
|
27218
|
-
* Executes the first group of functions in the queue, then
|
|
27219
|
-
* schedules the next frame if needed.
|
|
27220
|
-
*/
|
|
27221
|
-
_nextTick() {
|
|
27222
|
-
if (!this._queue.length) return;
|
|
27223
|
-
|
|
27224
|
-
const items = /** @type{Array<() => void>} */ (this._queue.shift());
|
|
27225
|
-
|
|
27226
|
-
items.forEach((fn) => fn());
|
|
27227
|
-
|
|
27228
|
-
if (!this._cancelFn) {
|
|
27229
|
-
this._cancelFn = window.requestAnimationFrame(() => {
|
|
27230
|
-
this._cancelFn = null;
|
|
27231
|
-
this._nextTick();
|
|
27232
|
-
});
|
|
27233
|
-
}
|
|
27234
|
-
}
|
|
27235
|
-
|
|
27236
|
-
/**
|
|
27237
|
-
* Returns the scheduler function.
|
|
27238
|
-
* This function allows tasks to be queued for execution on future animation frames.
|
|
27239
|
-
* It also has helper methods and state attached.
|
|
27240
|
-
*
|
|
27241
|
-
* @returns {RafScheduler} The scheduler function with `queue` and `waitUntilQuiet`.
|
|
27242
|
-
*/
|
|
27243
|
-
$get() {
|
|
27244
|
-
/**
|
|
27245
|
-
* The main scheduler function.
|
|
27246
|
-
* Accepts an array of functions and schedules them to run in the next available frame(s).
|
|
27247
|
-
*
|
|
27248
|
-
* @type {RafScheduler}
|
|
27249
|
-
*/
|
|
27250
|
-
const scheduler = (tasks) => {
|
|
27251
|
-
// Clone the input array to avoid mutating the original.
|
|
27252
|
-
this._queue = this._queue.concat(tasks);
|
|
27253
|
-
this._nextTick();
|
|
27254
|
-
};
|
|
27255
|
-
|
|
27256
|
-
/**
|
|
27257
|
-
* Exposes the internal queue to consumers (read-only use preferred).
|
|
27258
|
-
* This matches the type signature for RafScheduler.
|
|
27259
|
-
*/
|
|
27260
|
-
scheduler._queue = this._queue;
|
|
27261
|
-
|
|
27262
|
-
/**
|
|
27263
|
-
* Cancels any pending frame and runs the given function once the frame is idle.
|
|
27264
|
-
* Useful for debounced updates.
|
|
27265
|
-
*
|
|
27266
|
-
* @param {Function} fn - Function to run when the animation frame is quiet.
|
|
27267
|
-
*/
|
|
27268
|
-
scheduler._waitUntilQuiet = (fn) => {
|
|
27269
|
-
if (this._cancelFn !== null) {
|
|
27270
|
-
window.cancelAnimationFrame(this._cancelFn);
|
|
27271
|
-
this._cancelFn = null;
|
|
27272
|
-
}
|
|
27273
|
-
|
|
27274
|
-
this._cancelFn = window.requestAnimationFrame(() => {
|
|
27275
|
-
this._cancelFn = null;
|
|
27276
|
-
fn();
|
|
27277
|
-
this._nextTick();
|
|
27278
|
-
});
|
|
27279
|
-
};
|
|
27280
|
-
|
|
27281
|
-
return scheduler;
|
|
27282
|
-
}
|
|
27283
|
-
}
|
|
27284
|
-
|
|
27285
|
-
const KEY = "$animId";
|
|
27286
|
-
|
|
27287
|
-
let parentCounter = 0;
|
|
27288
|
-
|
|
27289
|
-
const cache = new Map();
|
|
27290
|
-
|
|
27291
|
-
function animateCache() {
|
|
27292
|
-
return {
|
|
27293
|
-
/**
|
|
27294
|
-
* Generates a unique cache key based on the node's parent and other parameters.
|
|
27295
|
-
* @param {HTMLElement} node - The DOM node to generate the cache key for.
|
|
27296
|
-
* @param {string} method - The animation method being applied.
|
|
27297
|
-
* @param {string} [addClass] - Class to add during the animation.
|
|
27298
|
-
* @param {string} [removeClass] - Class to remove during the animation.
|
|
27299
|
-
* @returns {string} - The generated cache key.
|
|
27300
|
-
*/
|
|
27301
|
-
cacheKey(node, method, addClass, removeClass) {
|
|
27302
|
-
const { parentNode } = node;
|
|
27303
|
-
|
|
27304
|
-
const parentID = parentNode[KEY] ?? (parentNode[KEY] = ++parentCounter);
|
|
27305
|
-
|
|
27306
|
-
const parts = [parentID, method, node.getAttribute("class")];
|
|
27307
|
-
|
|
27308
|
-
if (addClass) parts.push(addClass);
|
|
27309
|
-
|
|
27310
|
-
if (removeClass) parts.push(removeClass);
|
|
27311
|
-
|
|
27312
|
-
return parts.join(" ");
|
|
27313
|
-
},
|
|
27314
|
-
|
|
27315
|
-
/**
|
|
27316
|
-
* Checks if a cached animation without a duration exists.
|
|
27317
|
-
* @param {string} key - The cache key to check.
|
|
27318
|
-
* @returns {boolean} - True if an invalid animation is cached, false otherwise.
|
|
27319
|
-
*/
|
|
27320
|
-
containsCachedAnimationWithoutDuration(key) {
|
|
27321
|
-
const entry = cache.get(key);
|
|
27322
|
-
|
|
27323
|
-
return entry ? !entry.isValid : false;
|
|
27324
|
-
},
|
|
27325
|
-
|
|
27326
|
-
/**
|
|
27327
|
-
* Clears the cache.
|
|
27328
|
-
* @returns {void}
|
|
27329
|
-
*/
|
|
27330
|
-
flush() {
|
|
27331
|
-
cache.clear();
|
|
27332
|
-
},
|
|
27333
|
-
|
|
27334
|
-
/**
|
|
27335
|
-
* Gets the count of a specific cache entry.
|
|
27336
|
-
* @param {string} key - The cache key to count.
|
|
27337
|
-
* @returns {number} - The count of the cache entry.
|
|
27338
|
-
*/
|
|
27339
|
-
count(key) {
|
|
27340
|
-
return cache.get(key)?.total ?? 0;
|
|
27341
|
-
},
|
|
27342
|
-
|
|
27343
|
-
/**
|
|
27344
|
-
* Retrieves a value associated with a specific cache key.
|
|
27345
|
-
* @param {string} key - The cache key to retrieve.
|
|
27346
|
-
* @returns {any} - The value associated with the cache key.
|
|
27347
|
-
*/
|
|
27348
|
-
get(key) {
|
|
27349
|
-
return cache.get(key)?.value;
|
|
27350
|
-
},
|
|
27351
|
-
|
|
27352
|
-
/**
|
|
27353
|
-
* Adds or updates a cache entry.
|
|
27354
|
-
* @param {string} key - The cache key to add or update.
|
|
27355
|
-
* @param {any} value - The value to store.
|
|
27356
|
-
* @param {boolean} isValid - Whether the cache entry is valid.
|
|
27357
|
-
*/
|
|
27358
|
-
put(key, value, isValid) {
|
|
27359
|
-
const entry = cache.get(key);
|
|
27360
|
-
|
|
27361
|
-
if (entry) {
|
|
27362
|
-
entry.total++;
|
|
27363
|
-
entry.value = value;
|
|
27364
|
-
} else {
|
|
27365
|
-
cache.set(key, { total: 1, value, isValid });
|
|
27366
|
-
}
|
|
27367
|
-
},
|
|
27368
|
-
};
|
|
27369
|
-
}
|
|
27370
|
-
|
|
27371
|
-
class AnimateCacheProvider {
|
|
27372
|
-
$get() {
|
|
27373
|
-
return animateCache();
|
|
27374
|
-
}
|
|
27375
|
-
}
|
|
27376
|
-
|
|
27377
27715
|
const NG_ANIMATE_SHIM_CLASS_NAME = "ng-animate-shim";
|
|
27378
27716
|
|
|
27379
27717
|
const NG_ANIMATE_ANCHOR_CLASS_NAME = "ng-anchor";
|
|
@@ -27383,9 +27721,16 @@ const NG_OUT_ANCHOR_CLASS_NAME = "ng-anchor-out";
|
|
|
27383
27721
|
const NG_IN_ANCHOR_CLASS_NAME = "ng-anchor-in";
|
|
27384
27722
|
|
|
27385
27723
|
AnimateCssDriverProvider.$inject = provider([$injectTokens._animation]);
|
|
27724
|
+
|
|
27725
|
+
/**
|
|
27726
|
+
* @param {import("./animation.js").AnimationProvider} $$animationProvider
|
|
27727
|
+
*/
|
|
27386
27728
|
function AnimateCssDriverProvider($$animationProvider) {
|
|
27387
27729
|
$$animationProvider.drivers.push($injectTokens._animateCssDriver);
|
|
27388
27730
|
|
|
27731
|
+
/**
|
|
27732
|
+
* @param {Element} node
|
|
27733
|
+
*/
|
|
27389
27734
|
function isDocumentFragment(node) {
|
|
27390
27735
|
// eslint-disable-next-line no-magic-numbers
|
|
27391
27736
|
return node.parentNode && node.parentNode.nodeType === 11;
|
|
@@ -27791,7 +28136,7 @@ $$AnimateChildrenDirective.$inject = [$injectTokens._interpolate];
|
|
|
27791
28136
|
function $$AnimateChildrenDirective($interpolate) {
|
|
27792
28137
|
return {
|
|
27793
28138
|
link(scope, element, attrs) {
|
|
27794
|
-
const val = attrs.ngAnimateChildren;
|
|
28139
|
+
const val = /** @type {string} */ (attrs.ngAnimateChildren);
|
|
27795
28140
|
|
|
27796
28141
|
if (isString(val) && val.length === 0) {
|
|
27797
28142
|
// empty attribute
|
|
@@ -27799,13 +28144,21 @@ function $$AnimateChildrenDirective($interpolate) {
|
|
|
27799
28144
|
} else {
|
|
27800
28145
|
// Interpolate and set the value, so that it is available to
|
|
27801
28146
|
// animations that run right after compilation
|
|
27802
|
-
setData(
|
|
28147
|
+
setData(
|
|
28148
|
+
/** @type {import("../core/interpolate/interface.js").InterpolationFunction} */ (
|
|
28149
|
+
$interpolate(val)
|
|
28150
|
+
)(scope),
|
|
28151
|
+
);
|
|
27803
28152
|
attrs.$observe("ngAnimateChildren", setData);
|
|
27804
28153
|
}
|
|
27805
28154
|
|
|
28155
|
+
/**
|
|
28156
|
+
* @param {string} [value]
|
|
28157
|
+
*/
|
|
27806
28158
|
function setData(value) {
|
|
27807
|
-
|
|
27808
|
-
|
|
28159
|
+
const res = value === "on" || value === "true";
|
|
28160
|
+
|
|
28161
|
+
setCacheData(element, NG_ANIMATE_CHILDREN_DATA, res);
|
|
27809
28162
|
}
|
|
27810
28163
|
},
|
|
27811
28164
|
};
|
|
@@ -27929,10 +28282,11 @@ function defaults(opts, ...defaultsList) {
|
|
|
27929
28282
|
* var foo = { a: 1, b: 2, c: 3 };
|
|
27930
28283
|
* var ab = pick(foo, ['a', 'b']); // { a: 1, b: 2 }
|
|
27931
28284
|
* ```
|
|
27932
|
-
* @param obj the source object
|
|
27933
|
-
* @param propNames an Array of strings, which are the whitelisted property names
|
|
28285
|
+
* @param {any} obj the source object
|
|
28286
|
+
* @param {string | any[]} propNames an Array of strings, which are the whitelisted property names
|
|
27934
28287
|
*/
|
|
27935
28288
|
function pick(obj, propNames) {
|
|
28289
|
+
/** @type {Record<string, any>} */
|
|
27936
28290
|
const objCopy = {};
|
|
27937
28291
|
|
|
27938
28292
|
for (const _prop in obj) {
|
|
@@ -27943,30 +28297,44 @@ function pick(obj, propNames) {
|
|
|
27943
28297
|
|
|
27944
28298
|
return objCopy;
|
|
27945
28299
|
}
|
|
28300
|
+
|
|
27946
28301
|
/**
|
|
27947
28302
|
* Return a copy of the object omitting the blacklisted properties.
|
|
27948
|
-
*
|
|
27949
|
-
|
|
27950
|
-
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
*
|
|
27954
|
-
*
|
|
27955
|
-
* @param obj the source object
|
|
27956
|
-
* @param propNames an Array of strings, which are the blacklisted property names
|
|
28303
|
+
* @example ```
|
|
28304
|
+
|
|
28305
|
+
var foo = { a: 1, b: 2, c: 3 };
|
|
28306
|
+
var ab = omit(foo, ['a', 'b']); // { c: 3 }
|
|
28307
|
+
```
|
|
28308
|
+
* @param {{ [x: string]: any; }} obj the source object
|
|
28309
|
+
* @param {string | any[]} propNames an Array of strings, which are the blacklisted property names
|
|
27957
28310
|
*/
|
|
27958
28311
|
function omit(obj, propNames) {
|
|
27959
28312
|
return Object.keys(obj)
|
|
27960
28313
|
.filter((x) => !propNames.includes(x))
|
|
27961
|
-
.reduce(
|
|
28314
|
+
.reduce(
|
|
28315
|
+
/**
|
|
28316
|
+
* @param {Record<string, any>} acc
|
|
28317
|
+
* @param {string} key
|
|
28318
|
+
* */ (acc, key) => ((acc[key] = obj[key]), acc),
|
|
28319
|
+
{},
|
|
28320
|
+
);
|
|
27962
28321
|
}
|
|
27963
28322
|
|
|
27964
|
-
/**
|
|
28323
|
+
/**
|
|
28324
|
+
* Filters an Array or an Object's properties based on a predicate
|
|
28325
|
+
* @param {Record<string, any> | ArrayLike<any>} collection
|
|
28326
|
+
* @param {{ (x: any): boolean; (item: any): boolean; (val: any, key: any): boolean; (arg0: any, arg1: string): any; }} callback
|
|
28327
|
+
*/
|
|
27965
28328
|
function filter(collection, callback) {
|
|
27966
|
-
const arr = isArray(collection)
|
|
27967
|
-
result = arr ? [] : {};
|
|
28329
|
+
const arr = isArray(collection);
|
|
27968
28330
|
|
|
27969
|
-
|
|
28331
|
+
/** @type {Record<string, any>} */
|
|
28332
|
+
const result = arr ? [] : {};
|
|
28333
|
+
|
|
28334
|
+
const accept = arr
|
|
28335
|
+
? (/** @type {any} */ x) => result.push(x)
|
|
28336
|
+
: (/** @type {any} */ x, /** @type {string | number} */ key) =>
|
|
28337
|
+
(result[key] = x);
|
|
27970
28338
|
|
|
27971
28339
|
entries(collection).forEach(([i, item]) => {
|
|
27972
28340
|
if (callback(item, i)) accept(item, i);
|
|
@@ -27975,8 +28343,15 @@ function filter(collection, callback) {
|
|
|
27975
28343
|
return result;
|
|
27976
28344
|
}
|
|
27977
28345
|
|
|
27978
|
-
/**
|
|
28346
|
+
/**
|
|
28347
|
+
* Finds an object from an array, or a property of an object, that matches a predicate
|
|
28348
|
+
* @param {{ [s: string]: any; } | ArrayLike<any>} collection
|
|
28349
|
+
* @param {function} callback
|
|
28350
|
+
*/
|
|
27979
28351
|
function find(collection, callback) {
|
|
28352
|
+
/**
|
|
28353
|
+
* @type {any}
|
|
28354
|
+
*/
|
|
27980
28355
|
let result;
|
|
27981
28356
|
|
|
27982
28357
|
entries(collection).forEach(([i, item]) => {
|
|
@@ -27988,10 +28363,30 @@ function find(collection, callback) {
|
|
|
27988
28363
|
return result;
|
|
27989
28364
|
}
|
|
27990
28365
|
|
|
27991
|
-
/**
|
|
28366
|
+
/**
|
|
28367
|
+
* Maps over an array or object and returns a new collection
|
|
28368
|
+
* with the same shape.
|
|
28369
|
+
*
|
|
28370
|
+
* @template T
|
|
28371
|
+
* @template R
|
|
28372
|
+
* @param {T[] | Record<string, T>} collection
|
|
28373
|
+
* @param {(value: T, key: string | number) => R} callback
|
|
28374
|
+
* @param {R[] | Record<string, R>} [target]
|
|
28375
|
+
* @returns {R[] | Record<string, R>}
|
|
28376
|
+
*/
|
|
27992
28377
|
function map(collection, callback, target) {
|
|
27993
28378
|
target = target || (isArray(collection) ? [] : {});
|
|
27994
|
-
|
|
28379
|
+
|
|
28380
|
+
entries(collection).forEach(([i, item]) => {
|
|
28381
|
+
if (isArray(target)) {
|
|
28382
|
+
// Convert string key to number safely
|
|
28383
|
+
const index = Number(i);
|
|
28384
|
+
|
|
28385
|
+
target[index] = callback(item, index);
|
|
28386
|
+
} else {
|
|
28387
|
+
target[i] = callback(item, i);
|
|
28388
|
+
}
|
|
28389
|
+
});
|
|
27995
28390
|
|
|
27996
28391
|
return target;
|
|
27997
28392
|
}
|
|
@@ -28009,7 +28404,8 @@ function map(collection, callback, target) {
|
|
|
28009
28404
|
* vals.reduce(allTrueR, true); // false
|
|
28010
28405
|
* ```
|
|
28011
28406
|
*/
|
|
28012
|
-
const allTrueR = (memo,
|
|
28407
|
+
const allTrueR = (/** @type {any} */ memo, /** @type {any} */ elem) =>
|
|
28408
|
+
memo && elem;
|
|
28013
28409
|
/**
|
|
28014
28410
|
* Reduce function that returns true if any of the values are truthy.
|
|
28015
28411
|
*
|
|
@@ -28023,29 +28419,39 @@ const allTrueR = (memo, elem) => memo && elem;
|
|
|
28023
28419
|
* vals.reduce(anyTrueR, true); // true
|
|
28024
28420
|
* ```
|
|
28025
28421
|
*/
|
|
28026
|
-
const anyTrueR = (memo,
|
|
28422
|
+
const anyTrueR = (/** @type {any} */ memo, /** @type {any} */ elem) =>
|
|
28423
|
+
memo || elem;
|
|
28424
|
+
|
|
28027
28425
|
/**
|
|
28028
28426
|
* Reduce function which un-nests a single level of arrays
|
|
28029
|
-
* @example
|
|
28030
|
-
* ```
|
|
28031
28427
|
*
|
|
28428
|
+
* @template T
|
|
28429
|
+
* @param {T[]} memo
|
|
28430
|
+
* @param {T | T[]} elem
|
|
28431
|
+
* @returns {T[]}
|
|
28432
|
+
*
|
|
28433
|
+
* @example
|
|
28032
28434
|
* let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
|
|
28033
|
-
* input.reduce(unnestR, []) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
|
|
28034
|
-
* ```
|
|
28435
|
+
* input.reduce(unnestR, []) // [ "a", "b", "c", "d", [ "double", "nested" ] ]
|
|
28035
28436
|
*/
|
|
28036
28437
|
const unnestR = (memo, elem) => memo.concat(elem);
|
|
28438
|
+
|
|
28037
28439
|
/**
|
|
28038
28440
|
* Reduce function that pushes an object to an array, then returns the array.
|
|
28039
28441
|
* Mostly just for [[flattenR]] and [[uniqR]]
|
|
28442
|
+
* @param {any[]} arr
|
|
28443
|
+
* @param {unknown} obj
|
|
28040
28444
|
*/
|
|
28041
28445
|
function pushR(arr, obj) {
|
|
28042
28446
|
arr.push(obj);
|
|
28043
28447
|
|
|
28044
28448
|
return arr;
|
|
28045
28449
|
}
|
|
28450
|
+
|
|
28046
28451
|
/** Reduce function that filters out duplicates */
|
|
28047
|
-
const uniqR = (acc, token) =>
|
|
28452
|
+
const uniqR = (/** @type {any[]} */ acc, /** @type {any} */ token) =>
|
|
28048
28453
|
acc.includes(token) ? acc : pushR(acc, token);
|
|
28454
|
+
|
|
28049
28455
|
/**
|
|
28050
28456
|
* Return a new array with a single level of arrays unnested.
|
|
28051
28457
|
*
|
|
@@ -28056,7 +28462,7 @@ const uniqR = (acc, token) =>
|
|
|
28056
28462
|
* unnest(input) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
|
|
28057
28463
|
* ```
|
|
28058
28464
|
*/
|
|
28059
|
-
const unnest = (arr) => arr.reduce(unnestR, []);
|
|
28465
|
+
const unnest = (/** @type {any[]} */ arr) => arr.reduce(unnestR, []);
|
|
28060
28466
|
|
|
28061
28467
|
/**
|
|
28062
28468
|
* Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.
|
|
@@ -28073,6 +28479,11 @@ const unnest = (arr) => arr.reduce(unnestR, []);
|
|
|
28073
28479
|
*/
|
|
28074
28480
|
const assertPredicate = assertFn;
|
|
28075
28481
|
|
|
28482
|
+
/**
|
|
28483
|
+
* @param {(arg0: any) => any} predicateOrMap
|
|
28484
|
+
* @param {string} errMsg
|
|
28485
|
+
* @return {(obj:any) => any}
|
|
28486
|
+
*/
|
|
28076
28487
|
function assertFn(predicateOrMap, errMsg = "assert failure") {
|
|
28077
28488
|
return (obj) => {
|
|
28078
28489
|
const result = predicateOrMap(obj);
|
|
@@ -28131,25 +28542,26 @@ function arrayTuples(...args) {
|
|
|
28131
28542
|
|
|
28132
28543
|
return result;
|
|
28133
28544
|
}
|
|
28545
|
+
|
|
28134
28546
|
/**
|
|
28135
28547
|
* Reduce function which builds an object from an array of [key, value] pairs.
|
|
28136
28548
|
*
|
|
28137
28549
|
* Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.
|
|
28138
28550
|
*
|
|
28139
28551
|
* Each keyValueTuple should be an array with values [ key: string, value: any ]
|
|
28140
|
-
*
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
|
|
28149
|
-
|
|
28150
|
-
|
|
28151
|
-
*
|
|
28152
|
-
*
|
|
28552
|
+
* @example ```
|
|
28553
|
+
|
|
28554
|
+
var pairs = [ ["fookey", "fooval"], ["barkey", "barval"] ]
|
|
28555
|
+
|
|
28556
|
+
var pairsToObj = pairs.reduce((memo, pair) => applyPairs(memo, pair), {})
|
|
28557
|
+
// pairsToObj == { fookey: "fooval", barkey: "barval" }
|
|
28558
|
+
|
|
28559
|
+
// Or, more simply:
|
|
28560
|
+
var pairsToObj = pairs.reduce(applyPairs, {})
|
|
28561
|
+
// pairsToObj == { fookey: "fooval", barkey: "barval" }
|
|
28562
|
+
```
|
|
28563
|
+
* @param {{ [x: string]: any; }} memo
|
|
28564
|
+
* @param {any[]} keyValTuple
|
|
28153
28565
|
*/
|
|
28154
28566
|
function applyPairs(memo, keyValTuple) {
|
|
28155
28567
|
let key, value;
|
|
@@ -28174,6 +28586,8 @@ function tail(arr) {
|
|
|
28174
28586
|
|
|
28175
28587
|
/**
|
|
28176
28588
|
* shallow copy from src to dest
|
|
28589
|
+
* @param {any} src
|
|
28590
|
+
* @param {any} dest
|
|
28177
28591
|
*/
|
|
28178
28592
|
function copy(src, dest) {
|
|
28179
28593
|
if (dest) Object.keys(dest).forEach((key) => delete dest[key]);
|
|
@@ -29237,12 +29651,12 @@ function splitOnDelim(delim) {
|
|
|
29237
29651
|
* let arr = ["foo", "bar", 1, "baz", "", "qux" ];
|
|
29238
29652
|
* arr.reduce(joinNeighborsR, []) // ["foobar", 1, "bazqux" ]
|
|
29239
29653
|
* ```
|
|
29240
|
-
* @param {
|
|
29654
|
+
* @param {any[]} acc
|
|
29241
29655
|
* @param {unknown} str
|
|
29242
29656
|
*/
|
|
29243
29657
|
function joinNeighborsR(acc, str) {
|
|
29244
|
-
if (isString(tail(
|
|
29245
|
-
return acc.slice(0, -1).concat(tail(
|
|
29658
|
+
if (isString(tail(acc)) && isString(str))
|
|
29659
|
+
return acc.slice(0, -1).concat(tail(acc) + str);
|
|
29246
29660
|
|
|
29247
29661
|
return pushR(acc, str);
|
|
29248
29662
|
}
|
|
@@ -29854,13 +30268,13 @@ function getParamDeclaration(paramName, location, state) {
|
|
|
29854
30268
|
|
|
29855
30269
|
function unwrapShorthand(cfg) {
|
|
29856
30270
|
cfg = isShorthand(cfg) ? { value: cfg } : cfg;
|
|
29857
|
-
getStaticDefaultValue.
|
|
30271
|
+
getStaticDefaultValue._cacheable = true;
|
|
29858
30272
|
function getStaticDefaultValue() {
|
|
29859
30273
|
return cfg.value;
|
|
29860
30274
|
}
|
|
29861
|
-
const
|
|
30275
|
+
const _fn = isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue;
|
|
29862
30276
|
|
|
29863
|
-
return Object.assign(cfg, {
|
|
30277
|
+
return Object.assign(cfg, { _fn });
|
|
29864
30278
|
}
|
|
29865
30279
|
|
|
29866
30280
|
function getType(cfg, urlType, location, id, paramTypes) {
|
|
@@ -30005,7 +30419,7 @@ class Param {
|
|
|
30005
30419
|
throw new Error(
|
|
30006
30420
|
"Injectable functions cannot be called at configuration time",
|
|
30007
30421
|
);
|
|
30008
|
-
const defaultValue = window.angular.$injector.invoke(this.config
|
|
30422
|
+
const defaultValue = window.angular.$injector.invoke(this.config._fn);
|
|
30009
30423
|
|
|
30010
30424
|
if (
|
|
30011
30425
|
defaultValue !== null &&
|
|
@@ -30016,7 +30430,7 @@ class Param {
|
|
|
30016
30430
|
`Default value (${defaultValue}) for parameter '${this.id}' is not an instance of ParamType (${this.type.name})`,
|
|
30017
30431
|
);
|
|
30018
30432
|
|
|
30019
|
-
if (this.config
|
|
30433
|
+
if (this.config._fn._cacheable) {
|
|
30020
30434
|
this._defaultValueCache = { defaultValue };
|
|
30021
30435
|
}
|
|
30022
30436
|
|
|
@@ -35242,33 +35656,43 @@ class UrlMatcher {
|
|
|
35242
35656
|
return { param, value, isValid, isDefaultValue, squash, encoded };
|
|
35243
35657
|
}
|
|
35244
35658
|
// Build up the path-portion from the list of static segments and parameters
|
|
35245
|
-
|
|
35246
|
-
|
|
35247
|
-
|
|
35248
|
-
|
|
35249
|
-
|
|
35659
|
+
/** @type {string} */
|
|
35660
|
+
const pathString = /** @type {string} */ (
|
|
35661
|
+
pathSegmentsAndParams.reduce(
|
|
35662
|
+
/** @param {string} acc */ (acc, x) => {
|
|
35663
|
+
// The element is a static segment (a raw string); just append it
|
|
35664
|
+
if (isString(x)) return acc + x;
|
|
35665
|
+
// Otherwise, it's a ParamDetails.
|
|
35666
|
+
const { squash, encoded, param } = x;
|
|
35250
35667
|
|
|
35251
|
-
|
|
35252
|
-
|
|
35668
|
+
// If squash is === true, try to remove a slash from the path
|
|
35669
|
+
if (squash === true) return acc.match(/\/$/) ? acc.slice(0, -1) : acc;
|
|
35253
35670
|
|
|
35254
|
-
|
|
35255
|
-
|
|
35671
|
+
// If squash is a string, use the string for the param value
|
|
35672
|
+
if (isString(squash)) return acc + squash;
|
|
35256
35673
|
|
|
35257
|
-
|
|
35674
|
+
if (squash !== false) return acc; // ?
|
|
35258
35675
|
|
|
35259
|
-
|
|
35676
|
+
if (isNullOrUndefined(encoded)) return acc;
|
|
35260
35677
|
|
|
35261
|
-
|
|
35262
|
-
|
|
35678
|
+
// If this parameter value is an array, encode the value using encodeDashes
|
|
35679
|
+
if (isArray(encoded))
|
|
35680
|
+
return (
|
|
35681
|
+
acc +
|
|
35682
|
+
/** @type {string[]} */ (map(encoded, encodeDashes)).join("-")
|
|
35683
|
+
);
|
|
35263
35684
|
|
|
35264
|
-
|
|
35265
|
-
|
|
35266
|
-
|
|
35267
|
-
|
|
35685
|
+
// If the parameter type is "raw", then do not encodeURIComponent
|
|
35686
|
+
if (param.raw) {
|
|
35687
|
+
return acc + encoded;
|
|
35688
|
+
}
|
|
35268
35689
|
|
|
35269
|
-
|
|
35270
|
-
|
|
35271
|
-
|
|
35690
|
+
// Encode the value
|
|
35691
|
+
return acc + encodeURIComponent(encoded);
|
|
35692
|
+
},
|
|
35693
|
+
"",
|
|
35694
|
+
)
|
|
35695
|
+
);
|
|
35272
35696
|
|
|
35273
35697
|
// Build the query string by applying parameter values (array or regular)
|
|
35274
35698
|
// then mapping to key=value, then flattening and joining using "&"
|
|
@@ -40019,7 +40443,6 @@ function registerNgModule(angular) {
|
|
|
40019
40443
|
$$animateCssDriver: AnimateCssDriverProvider,
|
|
40020
40444
|
$$animateJs: AnimateJsProvider,
|
|
40021
40445
|
$$animateJsDriver: AnimateJsDriverProvider,
|
|
40022
|
-
$$animateCache: AnimateCacheProvider,
|
|
40023
40446
|
$$animateQueue: AnimateQueueProvider,
|
|
40024
40447
|
$controller: ControllerProvider,
|
|
40025
40448
|
$cookie: CookieProvider,
|
|
@@ -40031,7 +40454,6 @@ function registerNgModule(angular) {
|
|
|
40031
40454
|
$location: LocationProvider,
|
|
40032
40455
|
$log: LogProvider,
|
|
40033
40456
|
$parse: ParseProvider,
|
|
40034
|
-
$$rAFScheduler: RafSchedulerProvider,
|
|
40035
40457
|
$rest: RestProvider,
|
|
40036
40458
|
$rootScope: RootScopeProvider,
|
|
40037
40459
|
$router: RouterProvider,
|
|
@@ -40096,7 +40518,7 @@ class Angular extends EventTarget {
|
|
|
40096
40518
|
* @public
|
|
40097
40519
|
* @type {string} `version` from `package.json`
|
|
40098
40520
|
*/
|
|
40099
|
-
this.version = "0.
|
|
40521
|
+
this.version = "0.17.0"; //inserted via rollup plugin
|
|
40100
40522
|
|
|
40101
40523
|
/**
|
|
40102
40524
|
* Gets the controller instance for a given element, if exists. Defaults to "ngControllerController"
|
|
@@ -40199,6 +40621,25 @@ class Angular extends EventTarget {
|
|
|
40199
40621
|
});
|
|
40200
40622
|
}
|
|
40201
40623
|
|
|
40624
|
+
/**
|
|
40625
|
+
* @param {CustomEvent} event
|
|
40626
|
+
*/
|
|
40627
|
+
dispatchEvent(event) {
|
|
40628
|
+
const $parse = this.$injector.get($injectTokens._parse);
|
|
40629
|
+
|
|
40630
|
+
const injectable = event.type;
|
|
40631
|
+
|
|
40632
|
+
const target = this.$injector.has(injectable)
|
|
40633
|
+
? this.$injector.get(injectable)
|
|
40634
|
+
: this.getScopeByName(injectable);
|
|
40635
|
+
|
|
40636
|
+
if (!target) return false;
|
|
40637
|
+
|
|
40638
|
+
$parse(event.detail)(target);
|
|
40639
|
+
|
|
40640
|
+
return true;
|
|
40641
|
+
}
|
|
40642
|
+
|
|
40202
40643
|
/**
|
|
40203
40644
|
* Use this function to manually start up AngularTS application.
|
|
40204
40645
|
*
|