@angular/core 14.0.0-next.4 → 14.0.0-next.7
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/core.d.ts +34 -6
- package/esm2020/src/debug/debug_node.mjs +1 -1
- package/esm2020/src/i18n/tokens.mjs +5 -5
- package/esm2020/src/linker/template_ref.mjs +3 -3
- package/esm2020/src/linker/view_container_ref.mjs +12 -3
- package/esm2020/src/render3/component.mjs +3 -3
- package/esm2020/src/render3/component_ref.mjs +24 -18
- package/esm2020/src/render3/context_discovery.mjs +9 -3
- package/esm2020/src/render3/di.mjs +177 -97
- package/esm2020/src/render3/hooks.mjs +3 -3
- package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
- package/esm2020/src/render3/instructions/shared.mjs +11 -7
- package/esm2020/src/render3/interfaces/injector.mjs +1 -1
- package/esm2020/src/render3/interfaces/lview_tracking.mjs +8 -5
- package/esm2020/src/render3/interfaces/renderer_dom.mjs +1 -1
- package/esm2020/src/render3/interfaces/view.mjs +3 -2
- package/esm2020/src/render3/node_manipulation.mjs +9 -3
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/fake_async.mjs +3 -2
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/fesm2015/core.mjs +257 -142
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +3 -2
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +257 -142
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +3 -2
- package/fesm2020/testing.mjs.map +1 -1
- package/package.json +2 -2
- package/schematics/migrations/typed-forms/index.d.ts +1 -5
- package/schematics/migrations/typed-forms/index.js +12 -34
- package/schematics/migrations/typed-forms/util.d.ts +6 -9
- package/schematics/migrations/typed-forms/util.js +63 -40
- package/schematics/utils/typescript/parse_tsconfig.js +6 -2
- package/schematics/utils/typescript/symbol.js +4 -3
- package/testing/testing.d.ts +3 -2
package/fesm2015/core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.0-next.
|
|
2
|
+
* @license Angular v14.0.0-next.7
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -1211,6 +1211,7 @@ const DECLARATION_LCONTAINER = 17;
|
|
|
1211
1211
|
const PREORDER_HOOK_FLAGS = 18;
|
|
1212
1212
|
const QUERIES = 19;
|
|
1213
1213
|
const ID = 20;
|
|
1214
|
+
const EMBEDDED_VIEW_INJECTOR = 21;
|
|
1214
1215
|
/**
|
|
1215
1216
|
* Size of LView's header. Necessary to adjust for it when setting slots.
|
|
1216
1217
|
*
|
|
@@ -1218,7 +1219,7 @@ const ID = 20;
|
|
|
1218
1219
|
* instruction index into `LView` index. All other indexes should be in the `LView` index space and
|
|
1219
1220
|
* there should be no need to refer to `HEADER_OFFSET` anywhere else.
|
|
1220
1221
|
*/
|
|
1221
|
-
const HEADER_OFFSET =
|
|
1222
|
+
const HEADER_OFFSET = 22;
|
|
1222
1223
|
/**
|
|
1223
1224
|
* Converts `TViewType` into human readable text.
|
|
1224
1225
|
* Make sure this matches with `TViewType`
|
|
@@ -2468,7 +2469,7 @@ function incrementInitPhaseFlags(lView, initPhase) {
|
|
|
2468
2469
|
assertNotEqual(initPhase, 3 /* InitPhaseCompleted */, 'Init hooks phase should not be incremented after all init hooks have been run.');
|
|
2469
2470
|
let flags = lView[FLAGS];
|
|
2470
2471
|
if ((flags & 3 /* InitPhaseStateMask */) === initPhase) {
|
|
2471
|
-
flags &=
|
|
2472
|
+
flags &= 4095 /* IndexWithinInitPhaseReset */;
|
|
2472
2473
|
flags += 1 /* InitPhaseStateIncrementer */;
|
|
2473
2474
|
lView[FLAGS] = flags;
|
|
2474
2475
|
}
|
|
@@ -2532,12 +2533,12 @@ function callHook(currentView, initPhase, arr, i) {
|
|
|
2532
2533
|
const directiveIndex = isInitHook ? -arr[i] : arr[i];
|
|
2533
2534
|
const directive = currentView[directiveIndex];
|
|
2534
2535
|
if (isInitHook) {
|
|
2535
|
-
const indexWithintInitPhase = currentView[FLAGS] >>
|
|
2536
|
+
const indexWithintInitPhase = currentView[FLAGS] >> 12 /* IndexWithinInitPhaseShift */;
|
|
2536
2537
|
// The init phase state must be always checked here as it may have been recursively updated.
|
|
2537
2538
|
if (indexWithintInitPhase <
|
|
2538
2539
|
(currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
|
|
2539
2540
|
(currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
|
|
2540
|
-
currentView[FLAGS] +=
|
|
2541
|
+
currentView[FLAGS] += 4096 /* IndexWithinInitPhaseIncrementer */;
|
|
2541
2542
|
profiler(4 /* LifecycleHookStart */, directive, hook);
|
|
2542
2543
|
try {
|
|
2543
2544
|
hook.call(directive);
|
|
@@ -3098,6 +3099,8 @@ const BLOOM_MASK = BLOOM_SIZE - 1;
|
|
|
3098
3099
|
const BLOOM_BUCKET_BITS = 5;
|
|
3099
3100
|
/** Counter used to generate unique IDs for directives. */
|
|
3100
3101
|
let nextNgElementId = 0;
|
|
3102
|
+
/** Value used when something wasn't found by an injector. */
|
|
3103
|
+
const NOT_FOUND = {};
|
|
3101
3104
|
/**
|
|
3102
3105
|
* Registers this directive as present in its node's injector by flipping the directive's
|
|
3103
3106
|
* corresponding bit in the injector's bloom filter.
|
|
@@ -3209,23 +3212,7 @@ function getParentInjectorLocation(tNode, lView) {
|
|
|
3209
3212
|
// `LView` hierarchy and look for it. If we walk of the top, that means that there is no parent
|
|
3210
3213
|
// `NodeInjector`.
|
|
3211
3214
|
while (lViewCursor !== null) {
|
|
3212
|
-
|
|
3213
|
-
const tView = lViewCursor[TVIEW];
|
|
3214
|
-
const tViewType = tView.type;
|
|
3215
|
-
if (tViewType === 2 /* Embedded */) {
|
|
3216
|
-
ngDevMode &&
|
|
3217
|
-
assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
|
|
3218
|
-
parentTNode = tView.declTNode;
|
|
3219
|
-
}
|
|
3220
|
-
else if (tViewType === 1 /* Component */) {
|
|
3221
|
-
// Components don't have `TView.declTNode` because each instance of component could be
|
|
3222
|
-
// inserted in different location, hence `TView.declTNode` is meaningless.
|
|
3223
|
-
parentTNode = lViewCursor[T_HOST];
|
|
3224
|
-
}
|
|
3225
|
-
else {
|
|
3226
|
-
ngDevMode && assertEqual(tView.type, 0 /* Root */, 'Root type expected');
|
|
3227
|
-
parentTNode = null;
|
|
3228
|
-
}
|
|
3215
|
+
parentTNode = getTNodeFromLView(lViewCursor);
|
|
3229
3216
|
if (parentTNode === null) {
|
|
3230
3217
|
// If we have no parent, than we are done.
|
|
3231
3218
|
return NO_PARENT_INJECTOR;
|
|
@@ -3386,93 +3373,116 @@ function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
|
|
|
3386
3373
|
*/
|
|
3387
3374
|
function getOrCreateInjectable(tNode, lView, token, flags = InjectFlags.Default, notFoundValue) {
|
|
3388
3375
|
if (tNode !== null) {
|
|
3389
|
-
|
|
3390
|
-
//
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
if (
|
|
3394
|
-
|
|
3395
|
-
// flag, the module injector is not searched for that token in Ivy.
|
|
3396
|
-
return (flags & InjectFlags.Host) ?
|
|
3397
|
-
notFoundValueOrThrow(notFoundValue, token, flags) :
|
|
3398
|
-
lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
|
|
3376
|
+
// If the view or any of its ancestors have an embedded
|
|
3377
|
+
// view injector, we have to look it up there first.
|
|
3378
|
+
if (lView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) {
|
|
3379
|
+
const embeddedInjectorValue = lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, NOT_FOUND);
|
|
3380
|
+
if (embeddedInjectorValue !== NOT_FOUND) {
|
|
3381
|
+
return embeddedInjectorValue;
|
|
3399
3382
|
}
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3383
|
+
}
|
|
3384
|
+
// Otherwise try the node injector.
|
|
3385
|
+
const value = lookupTokenUsingNodeInjector(tNode, lView, token, flags, NOT_FOUND);
|
|
3386
|
+
if (value !== NOT_FOUND) {
|
|
3387
|
+
return value;
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
// Finally, fall back to the module injector.
|
|
3391
|
+
return lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Returns the value associated to the given token from the node injector.
|
|
3395
|
+
*
|
|
3396
|
+
* @param tNode The Node where the search for the injector should start
|
|
3397
|
+
* @param lView The `LView` that contains the `tNode`
|
|
3398
|
+
* @param token The token to look for
|
|
3399
|
+
* @param flags Injection flags
|
|
3400
|
+
* @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
|
|
3401
|
+
* @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
|
|
3402
|
+
*/
|
|
3403
|
+
function lookupTokenUsingNodeInjector(tNode, lView, token, flags, notFoundValue) {
|
|
3404
|
+
const bloomHash = bloomHashBitOrFactory(token);
|
|
3405
|
+
// If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
|
|
3406
|
+
// so just call the factory function to create it.
|
|
3407
|
+
if (typeof bloomHash === 'function') {
|
|
3408
|
+
if (!enterDI(lView, tNode, flags)) {
|
|
3409
|
+
// Failed to enter DI, try module injector instead. If a token is injected with the @Host
|
|
3410
|
+
// flag, the module injector is not searched for that token in Ivy.
|
|
3411
|
+
return (flags & InjectFlags.Host) ?
|
|
3412
|
+
notFoundValueOrThrow(notFoundValue, token, flags) :
|
|
3413
|
+
lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
|
|
3414
|
+
}
|
|
3415
|
+
try {
|
|
3416
|
+
const value = bloomHash(flags);
|
|
3417
|
+
if (value == null && !(flags & InjectFlags.Optional)) {
|
|
3418
|
+
throwProviderNotFoundError(token);
|
|
3408
3419
|
}
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
else if (typeof bloomHash === 'number') {
|
|
3414
|
-
// A reference to the previous injector TView that was found while climbing the element
|
|
3415
|
-
// injector tree. This is used to know if viewProviders can be accessed on the current
|
|
3416
|
-
// injector.
|
|
3417
|
-
let previousTView = null;
|
|
3418
|
-
let injectorIndex = getInjectorIndex(tNode, lView);
|
|
3419
|
-
let parentLocation = NO_PARENT_INJECTOR;
|
|
3420
|
-
let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
|
|
3421
|
-
// If we should skip this injector, or if there is no injector on this node, start by
|
|
3422
|
-
// searching the parent injector.
|
|
3423
|
-
if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
|
|
3424
|
-
parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
|
|
3425
|
-
lView[injectorIndex + 8 /* PARENT */];
|
|
3426
|
-
if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
|
|
3427
|
-
injectorIndex = -1;
|
|
3428
|
-
}
|
|
3429
|
-
else {
|
|
3430
|
-
previousTView = lView[TVIEW];
|
|
3431
|
-
injectorIndex = getParentInjectorIndex(parentLocation);
|
|
3432
|
-
lView = getParentInjectorView(parentLocation, lView);
|
|
3433
|
-
}
|
|
3420
|
+
else {
|
|
3421
|
+
return value;
|
|
3434
3422
|
}
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3423
|
+
}
|
|
3424
|
+
finally {
|
|
3425
|
+
leaveDI();
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
else if (typeof bloomHash === 'number') {
|
|
3429
|
+
// A reference to the previous injector TView that was found while climbing the element
|
|
3430
|
+
// injector tree. This is used to know if viewProviders can be accessed on the current
|
|
3431
|
+
// injector.
|
|
3432
|
+
let previousTView = null;
|
|
3433
|
+
let injectorIndex = getInjectorIndex(tNode, lView);
|
|
3434
|
+
let parentLocation = NO_PARENT_INJECTOR;
|
|
3435
|
+
let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
|
|
3436
|
+
// If we should skip this injector, or if there is no injector on this node, start by
|
|
3437
|
+
// searching the parent injector.
|
|
3438
|
+
if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
|
|
3439
|
+
parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
|
|
3440
|
+
lView[injectorIndex + 8 /* PARENT */];
|
|
3441
|
+
if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
|
|
3442
|
+
injectorIndex = -1;
|
|
3443
|
+
}
|
|
3444
|
+
else {
|
|
3445
|
+
previousTView = lView[TVIEW];
|
|
3446
|
+
injectorIndex = getParentInjectorIndex(parentLocation);
|
|
3447
|
+
lView = getParentInjectorView(parentLocation, lView);
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
// Traverse up the injector tree until we find a potential match or until we know there
|
|
3451
|
+
// *isn't* a match.
|
|
3452
|
+
while (injectorIndex !== -1) {
|
|
3453
|
+
ngDevMode && assertNodeInjector(lView, injectorIndex);
|
|
3454
|
+
// Check the current injector. If it matches, see if it contains token.
|
|
3455
|
+
const tView = lView[TVIEW];
|
|
3456
|
+
ngDevMode &&
|
|
3457
|
+
assertTNodeForLView(tView.data[injectorIndex + 8 /* TNODE */], lView);
|
|
3458
|
+
if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
|
|
3459
|
+
// At this point, we have an injector which *may* contain the token, so we step through
|
|
3460
|
+
// the providers and directives associated with the injector's corresponding node to get
|
|
3461
|
+
// the instance.
|
|
3462
|
+
const instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
|
|
3463
|
+
if (instance !== NOT_FOUND) {
|
|
3464
|
+
return instance;
|
|
3467
3465
|
}
|
|
3468
3466
|
}
|
|
3467
|
+
parentLocation = lView[injectorIndex + 8 /* PARENT */];
|
|
3468
|
+
if (parentLocation !== NO_PARENT_INJECTOR &&
|
|
3469
|
+
shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + 8 /* TNODE */] === hostTElementNode) &&
|
|
3470
|
+
bloomHasToken(bloomHash, injectorIndex, lView)) {
|
|
3471
|
+
// The def wasn't found anywhere on this node, so it was a false positive.
|
|
3472
|
+
// Traverse up the tree and continue searching.
|
|
3473
|
+
previousTView = tView;
|
|
3474
|
+
injectorIndex = getParentInjectorIndex(parentLocation);
|
|
3475
|
+
lView = getParentInjectorView(parentLocation, lView);
|
|
3476
|
+
}
|
|
3477
|
+
else {
|
|
3478
|
+
// If we should not search parent OR If the ancestor bloom filter value does not have the
|
|
3479
|
+
// bit corresponding to the directive we can give up on traversing up to find the specific
|
|
3480
|
+
// injector.
|
|
3481
|
+
injectorIndex = -1;
|
|
3482
|
+
}
|
|
3469
3483
|
}
|
|
3470
3484
|
}
|
|
3471
|
-
return
|
|
3472
|
-
}
|
|
3473
|
-
const NOT_FOUND = {};
|
|
3474
|
-
function createNodeInjector() {
|
|
3475
|
-
return new NodeInjector(getCurrentTNode(), getLView());
|
|
3485
|
+
return notFoundValue;
|
|
3476
3486
|
}
|
|
3477
3487
|
function searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode) {
|
|
3478
3488
|
const currentTView = lView[TVIEW];
|
|
@@ -3646,6 +3656,10 @@ class NodeInjector {
|
|
|
3646
3656
|
return getOrCreateInjectable(this._tNode, this._lView, token, flags, notFoundValue);
|
|
3647
3657
|
}
|
|
3648
3658
|
}
|
|
3659
|
+
/** Creates a `NodeInjector` for the current node. */
|
|
3660
|
+
function createNodeInjector() {
|
|
3661
|
+
return new NodeInjector(getCurrentTNode(), getLView());
|
|
3662
|
+
}
|
|
3649
3663
|
/**
|
|
3650
3664
|
* @codeGenApi
|
|
3651
3665
|
*/
|
|
@@ -3684,6 +3698,73 @@ function getFactoryOf(type) {
|
|
|
3684
3698
|
}
|
|
3685
3699
|
return getFactoryDef(type);
|
|
3686
3700
|
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Returns a value from the closest embedded or node injector.
|
|
3703
|
+
*
|
|
3704
|
+
* @param tNode The Node where the search for the injector should start
|
|
3705
|
+
* @param lView The `LView` that contains the `tNode`
|
|
3706
|
+
* @param token The token to look for
|
|
3707
|
+
* @param flags Injection flags
|
|
3708
|
+
* @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
|
|
3709
|
+
* @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
|
|
3710
|
+
*/
|
|
3711
|
+
function lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, notFoundValue) {
|
|
3712
|
+
let currentTNode = tNode;
|
|
3713
|
+
let currentLView = lView;
|
|
3714
|
+
// When an LView with an embedded view injector is inserted, it'll likely be interlaced with
|
|
3715
|
+
// nodes who may have injectors (e.g. node injector -> embedded view injector -> node injector).
|
|
3716
|
+
// Since the bloom filters for the node injectors have already been constructed and we don't
|
|
3717
|
+
// have a way of extracting the records from an injector, the only way to maintain the correct
|
|
3718
|
+
// hierarchy when resolving the value is to walk it node-by-node while attempting to resolve
|
|
3719
|
+
// the token at each level.
|
|
3720
|
+
while (currentTNode !== null && currentLView !== null &&
|
|
3721
|
+
(currentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) &&
|
|
3722
|
+
!(currentLView[FLAGS] & 512 /* IsRoot */)) {
|
|
3723
|
+
ngDevMode && assertTNodeForLView(currentTNode, currentLView);
|
|
3724
|
+
// Note that this lookup on the node injector is using the `Self` flag, because
|
|
3725
|
+
// we don't want the node injector to look at any parent injectors since we
|
|
3726
|
+
// may hit the embedded view injector first.
|
|
3727
|
+
const nodeInjectorValue = lookupTokenUsingNodeInjector(currentTNode, currentLView, token, flags | InjectFlags.Self, NOT_FOUND);
|
|
3728
|
+
if (nodeInjectorValue !== NOT_FOUND) {
|
|
3729
|
+
return nodeInjectorValue;
|
|
3730
|
+
}
|
|
3731
|
+
// Has an explicit type due to a TS bug: https://github.com/microsoft/TypeScript/issues/33191
|
|
3732
|
+
let parentTNode = currentTNode.parent;
|
|
3733
|
+
// `TNode.parent` includes the parent within the current view only. If it doesn't exist,
|
|
3734
|
+
// it means that we've hit the view boundary and we need to go up to the next view.
|
|
3735
|
+
if (!parentTNode) {
|
|
3736
|
+
// Before we go to the next LView, check if the token exists on the current embedded injector.
|
|
3737
|
+
const embeddedViewInjector = currentLView[EMBEDDED_VIEW_INJECTOR];
|
|
3738
|
+
if (embeddedViewInjector) {
|
|
3739
|
+
const embeddedViewInjectorValue = embeddedViewInjector.get(token, NOT_FOUND, flags);
|
|
3740
|
+
if (embeddedViewInjectorValue !== NOT_FOUND) {
|
|
3741
|
+
return embeddedViewInjectorValue;
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
// Otherwise keep going up the tree.
|
|
3745
|
+
parentTNode = getTNodeFromLView(currentLView);
|
|
3746
|
+
currentLView = currentLView[DECLARATION_VIEW];
|
|
3747
|
+
}
|
|
3748
|
+
currentTNode = parentTNode;
|
|
3749
|
+
}
|
|
3750
|
+
return notFoundValue;
|
|
3751
|
+
}
|
|
3752
|
+
/** Gets the TNode associated with an LView inside of the declaration view. */
|
|
3753
|
+
function getTNodeFromLView(lView) {
|
|
3754
|
+
const tView = lView[TVIEW];
|
|
3755
|
+
const tViewType = tView.type;
|
|
3756
|
+
// The parent pointer differs based on `TView.type`.
|
|
3757
|
+
if (tViewType === 2 /* Embedded */) {
|
|
3758
|
+
ngDevMode && assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
|
|
3759
|
+
return tView.declTNode;
|
|
3760
|
+
}
|
|
3761
|
+
else if (tViewType === 1 /* Component */) {
|
|
3762
|
+
// Components don't have `TView.declTNode` because each instance of component could be
|
|
3763
|
+
// inserted in different location, hence `TView.declTNode` is meaningless.
|
|
3764
|
+
return lView[T_HOST];
|
|
3765
|
+
}
|
|
3766
|
+
return null;
|
|
3767
|
+
}
|
|
3687
3768
|
|
|
3688
3769
|
/**
|
|
3689
3770
|
* @license
|
|
@@ -6167,11 +6248,14 @@ function getSanitizer() {
|
|
|
6167
6248
|
const TRACKED_LVIEWS = new Map();
|
|
6168
6249
|
// Used for generating unique IDs for LViews.
|
|
6169
6250
|
let uniqueIdCounter = 0;
|
|
6170
|
-
/**
|
|
6251
|
+
/** Gets a unique ID that can be assigned to an LView. */
|
|
6252
|
+
function getUniqueLViewId() {
|
|
6253
|
+
return uniqueIdCounter++;
|
|
6254
|
+
}
|
|
6255
|
+
/** Starts tracking an LView. */
|
|
6171
6256
|
function registerLView(lView) {
|
|
6172
|
-
|
|
6173
|
-
TRACKED_LVIEWS.set(
|
|
6174
|
-
return id;
|
|
6257
|
+
ngDevMode && assertNumber(lView[ID], 'LView must have an ID in order to be registered');
|
|
6258
|
+
TRACKED_LVIEWS.set(lView[ID], lView);
|
|
6175
6259
|
}
|
|
6176
6260
|
/** Gets an LView by its unique ID. */
|
|
6177
6261
|
function getLViewById(id) {
|
|
@@ -6380,7 +6464,13 @@ function attachPatchData(target, data) {
|
|
|
6380
6464
|
// Only attach the ID of the view in order to avoid memory leaks (see #41047). We only do this
|
|
6381
6465
|
// for `LView`, because we have control over when an `LView` is created and destroyed, whereas
|
|
6382
6466
|
// we can't know when to remove an `LContext`.
|
|
6383
|
-
|
|
6467
|
+
if (isLView(data)) {
|
|
6468
|
+
target[MONKEY_PATCH_KEY_NAME] = data[ID];
|
|
6469
|
+
registerLView(data);
|
|
6470
|
+
}
|
|
6471
|
+
else {
|
|
6472
|
+
target[MONKEY_PATCH_KEY_NAME] = data;
|
|
6473
|
+
}
|
|
6384
6474
|
}
|
|
6385
6475
|
/**
|
|
6386
6476
|
* Returns the monkey-patch value data present on the target (which could be
|
|
@@ -7510,7 +7600,8 @@ function nativeInsertBefore(renderer, parent, child, beforeNode, isMove) {
|
|
|
7510
7600
|
renderer.insertBefore(parent, child, beforeNode, isMove);
|
|
7511
7601
|
}
|
|
7512
7602
|
else {
|
|
7513
|
-
parent.
|
|
7603
|
+
const targetParent = isTemplateNode(parent) ? parent.content : parent;
|
|
7604
|
+
targetParent.insertBefore(child, beforeNode, isMove);
|
|
7514
7605
|
}
|
|
7515
7606
|
}
|
|
7516
7607
|
function nativeAppendChild(renderer, parent, child) {
|
|
@@ -7520,7 +7611,8 @@ function nativeAppendChild(renderer, parent, child) {
|
|
|
7520
7611
|
renderer.appendChild(parent, child);
|
|
7521
7612
|
}
|
|
7522
7613
|
else {
|
|
7523
|
-
parent.
|
|
7614
|
+
const targetParent = isTemplateNode(parent) ? parent.content : parent;
|
|
7615
|
+
targetParent.appendChild(child);
|
|
7524
7616
|
}
|
|
7525
7617
|
}
|
|
7526
7618
|
function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove) {
|
|
@@ -7540,6 +7632,10 @@ function nativeRemoveChild(renderer, parent, child, isHostElement) {
|
|
|
7540
7632
|
parent.removeChild(child);
|
|
7541
7633
|
}
|
|
7542
7634
|
}
|
|
7635
|
+
/** Checks if an element is a `<template>` node. */
|
|
7636
|
+
function isTemplateNode(node) {
|
|
7637
|
+
return node.tagName === 'TEMPLATE' && node.content !== undefined;
|
|
7638
|
+
}
|
|
7543
7639
|
/**
|
|
7544
7640
|
* Returns a native parent of a given native node.
|
|
7545
7641
|
*/
|
|
@@ -9060,7 +9156,7 @@ class LViewDebug {
|
|
|
9060
9156
|
attached: !!(flags & 128 /* Attached */),
|
|
9061
9157
|
destroyed: !!(flags & 256 /* Destroyed */),
|
|
9062
9158
|
isRoot: !!(flags & 512 /* IsRoot */),
|
|
9063
|
-
indexWithinInitPhase: flags >>
|
|
9159
|
+
indexWithinInitPhase: flags >> 12 /* IndexWithinInitPhaseShift */,
|
|
9064
9160
|
};
|
|
9065
9161
|
}
|
|
9066
9162
|
get parent() {
|
|
@@ -9355,10 +9451,14 @@ function renderChildComponents(hostLView, components) {
|
|
|
9355
9451
|
renderComponent$1(hostLView, components[i]);
|
|
9356
9452
|
}
|
|
9357
9453
|
}
|
|
9358
|
-
function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector) {
|
|
9454
|
+
function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
|
|
9359
9455
|
const lView = ngDevMode ? cloneToLViewFromTViewBlueprint(tView) : tView.blueprint.slice();
|
|
9360
9456
|
lView[HOST] = host;
|
|
9361
9457
|
lView[FLAGS] = flags | 4 /* CreationMode */ | 128 /* Attached */ | 8 /* FirstLViewPass */;
|
|
9458
|
+
if (embeddedViewInjector !== null ||
|
|
9459
|
+
(parentLView && (parentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */))) {
|
|
9460
|
+
lView[FLAGS] |= 2048 /* HasEmbeddedViewInjector */;
|
|
9461
|
+
}
|
|
9362
9462
|
resetPreOrderHookFlags(lView);
|
|
9363
9463
|
ngDevMode && tView.declTNode && parentLView && assertTNodeForLView(tView.declTNode, parentLView);
|
|
9364
9464
|
lView[PARENT] = lView[DECLARATION_VIEW] = parentLView;
|
|
@@ -9370,7 +9470,8 @@ function createLView(parentLView, tView, context, flags, host, tHostNode, render
|
|
|
9370
9470
|
lView[SANITIZER] = sanitizer || parentLView && parentLView[SANITIZER] || null;
|
|
9371
9471
|
lView[INJECTOR$1] = injector || parentLView && parentLView[INJECTOR$1] || null;
|
|
9372
9472
|
lView[T_HOST] = tHostNode;
|
|
9373
|
-
lView[ID] =
|
|
9473
|
+
lView[ID] = getUniqueLViewId();
|
|
9474
|
+
lView[EMBEDDED_VIEW_INJECTOR] = embeddedViewInjector;
|
|
9374
9475
|
ngDevMode &&
|
|
9375
9476
|
assertEqual(tView.type == 2 /* Embedded */ ? parentLView !== null : true, true, 'Embedded views must have parentLView');
|
|
9376
9477
|
lView[DECLARATION_COMPONENT_VIEW] =
|
|
@@ -10379,7 +10480,6 @@ function instantiateAllDirectives(tView, lView, tNode, native) {
|
|
|
10379
10480
|
function invokeDirectivesHostBindings(tView, lView, tNode) {
|
|
10380
10481
|
const start = tNode.directiveStart;
|
|
10381
10482
|
const end = tNode.directiveEnd;
|
|
10382
|
-
const firstCreatePass = tView.firstCreatePass;
|
|
10383
10483
|
const elementIndex = tNode.index;
|
|
10384
10484
|
const currentDirectiveIndex = getCurrentDirectiveIndex();
|
|
10385
10485
|
try {
|
|
@@ -10526,7 +10626,7 @@ function addComponentLogic(lView, hostTNode, def) {
|
|
|
10526
10626
|
// Only component views should be added to the view tree directly. Embedded views are
|
|
10527
10627
|
// accessed through their containers because they may be removed / re-added later.
|
|
10528
10628
|
const rendererFactory = lView[RENDERER_FACTORY];
|
|
10529
|
-
const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null));
|
|
10629
|
+
const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null, null));
|
|
10530
10630
|
// Component view will always be created before any injected LContainers,
|
|
10531
10631
|
// so this is a regular element, wrap it with the component view
|
|
10532
10632
|
lView[hostTNode.index] = componentView;
|
|
@@ -12269,7 +12369,7 @@ function renderComponent(componentType /* Type as workaround for: Microsoft/Type
|
|
|
12269
12369
|
const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
|
|
12270
12370
|
const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
|
|
12271
12371
|
const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
|
|
12272
|
-
const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null);
|
|
12372
|
+
const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
|
|
12273
12373
|
enterView(rootView);
|
|
12274
12374
|
let component;
|
|
12275
12375
|
try {
|
|
@@ -12324,7 +12424,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
|
|
|
12324
12424
|
}
|
|
12325
12425
|
}
|
|
12326
12426
|
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
12327
|
-
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null);
|
|
12427
|
+
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
12328
12428
|
if (tView.firstCreatePass) {
|
|
12329
12429
|
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
12330
12430
|
markAsComponentHost(tView, tNode);
|
|
@@ -21172,7 +21272,7 @@ class Version {
|
|
|
21172
21272
|
/**
|
|
21173
21273
|
* @publicApi
|
|
21174
21274
|
*/
|
|
21175
|
-
const VERSION = new Version('14.0.0-next.
|
|
21275
|
+
const VERSION = new Version('14.0.0-next.7');
|
|
21176
21276
|
|
|
21177
21277
|
/**
|
|
21178
21278
|
* @license
|
|
@@ -21577,22 +21677,28 @@ function getNamespace(elementName) {
|
|
|
21577
21677
|
const name = elementName.toLowerCase();
|
|
21578
21678
|
return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
|
|
21579
21679
|
}
|
|
21580
|
-
|
|
21581
|
-
|
|
21582
|
-
|
|
21583
|
-
|
|
21584
|
-
|
|
21585
|
-
|
|
21586
|
-
|
|
21587
|
-
|
|
21588
|
-
|
|
21589
|
-
|
|
21590
|
-
|
|
21591
|
-
|
|
21592
|
-
|
|
21593
|
-
|
|
21680
|
+
/**
|
|
21681
|
+
* Injector that looks up a value using a specific injector, before falling back to the module
|
|
21682
|
+
* injector. Used primarily when creating components or embedded views dynamically.
|
|
21683
|
+
*/
|
|
21684
|
+
class ChainedInjector {
|
|
21685
|
+
constructor(injector, parentInjector) {
|
|
21686
|
+
this.injector = injector;
|
|
21687
|
+
this.parentInjector = parentInjector;
|
|
21688
|
+
}
|
|
21689
|
+
get(token, notFoundValue, flags) {
|
|
21690
|
+
const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
|
|
21691
|
+
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
|
|
21692
|
+
notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
|
21693
|
+
// Return the value from the root element injector when
|
|
21694
|
+
// - it provides it
|
|
21695
|
+
// (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
|
21696
|
+
// - the module injector should not be checked
|
|
21697
|
+
// (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
|
21698
|
+
return value;
|
|
21594
21699
|
}
|
|
21595
|
-
|
|
21700
|
+
return this.parentInjector.get(token, notFoundValue, flags);
|
|
21701
|
+
}
|
|
21596
21702
|
}
|
|
21597
21703
|
/**
|
|
21598
21704
|
* Render3 implementation of {@link viewEngine_ComponentFactory}.
|
|
@@ -21620,7 +21726,7 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
21620
21726
|
}
|
|
21621
21727
|
create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
|
|
21622
21728
|
ngModule = ngModule || this.ngModule;
|
|
21623
|
-
const rootViewInjector = ngModule ?
|
|
21729
|
+
const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
|
|
21624
21730
|
const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
|
|
21625
21731
|
const sanitizer = rootViewInjector.get(Sanitizer, null);
|
|
21626
21732
|
const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
|
|
@@ -21635,7 +21741,7 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
21635
21741
|
const rootContext = createRootContext();
|
|
21636
21742
|
// Create the root view. Uses empty TView and ContentTemplate.
|
|
21637
21743
|
const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
|
|
21638
|
-
const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector);
|
|
21744
|
+
const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
|
|
21639
21745
|
// rootView is the parent when bootstrapping
|
|
21640
21746
|
// TODO(misko): it looks like we are entering view here but we don't really need to as
|
|
21641
21747
|
// `renderView` does that. However as the code is written it is needed because
|
|
@@ -22756,9 +22862,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
|
|
|
22756
22862
|
this._declarationTContainer = _declarationTContainer;
|
|
22757
22863
|
this.elementRef = elementRef;
|
|
22758
22864
|
}
|
|
22759
|
-
createEmbeddedView(context) {
|
|
22865
|
+
createEmbeddedView(context, injector) {
|
|
22760
22866
|
const embeddedTView = this._declarationTContainer.tViews;
|
|
22761
|
-
const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
|
|
22867
|
+
const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null, injector || null);
|
|
22762
22868
|
const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
|
|
22763
22869
|
ngDevMode && assertLContainer(declarationLContainer);
|
|
22764
22870
|
embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
|
|
@@ -22874,8 +22980,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
|
|
|
22874
22980
|
get length() {
|
|
22875
22981
|
return this._lContainer.length - CONTAINER_HEADER_OFFSET;
|
|
22876
22982
|
}
|
|
22877
|
-
createEmbeddedView(templateRef, context,
|
|
22878
|
-
|
|
22983
|
+
createEmbeddedView(templateRef, context, indexOrOptions) {
|
|
22984
|
+
let index;
|
|
22985
|
+
let injector;
|
|
22986
|
+
if (typeof indexOrOptions === 'number') {
|
|
22987
|
+
index = indexOrOptions;
|
|
22988
|
+
}
|
|
22989
|
+
else if (indexOrOptions != null) {
|
|
22990
|
+
index = indexOrOptions.index;
|
|
22991
|
+
injector = indexOrOptions.injector;
|
|
22992
|
+
}
|
|
22993
|
+
const viewRef = templateRef.createEmbeddedView(context || {}, injector);
|
|
22879
22994
|
this.insert(viewRef, index);
|
|
22880
22995
|
return viewRef;
|
|
22881
22996
|
}
|
|
@@ -25011,16 +25126,16 @@ Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: C
|
|
|
25011
25126
|
/**
|
|
25012
25127
|
* Work out the locale from the potential global properties.
|
|
25013
25128
|
*
|
|
25014
|
-
* * Closure Compiler: use `goog.
|
|
25129
|
+
* * Closure Compiler: use `goog.LOCALE`.
|
|
25015
25130
|
* * Ivy enabled: use `$localize.locale`
|
|
25016
25131
|
*/
|
|
25017
25132
|
function getGlobalLocale() {
|
|
25018
25133
|
if (typeof ngI18nClosureMode !== 'undefined' && ngI18nClosureMode &&
|
|
25019
|
-
typeof goog !== 'undefined' && goog.
|
|
25020
|
-
// * The default `goog.
|
|
25134
|
+
typeof goog !== 'undefined' && goog.LOCALE !== 'en') {
|
|
25135
|
+
// * The default `goog.LOCALE` value is `en`, while Angular used `en-US`.
|
|
25021
25136
|
// * In order to preserve backwards compatibility, we use Angular default value over
|
|
25022
25137
|
// Closure Compiler's one.
|
|
25023
|
-
return goog.
|
|
25138
|
+
return goog.LOCALE;
|
|
25024
25139
|
}
|
|
25025
25140
|
else {
|
|
25026
25141
|
// KEEP `typeof $localize !== 'undefined' && $localize.locale` IN SYNC WITH THE LOCALIZE
|