@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.
Files changed (37) hide show
  1. package/core.d.ts +34 -6
  2. package/esm2020/src/debug/debug_node.mjs +1 -1
  3. package/esm2020/src/i18n/tokens.mjs +5 -5
  4. package/esm2020/src/linker/template_ref.mjs +3 -3
  5. package/esm2020/src/linker/view_container_ref.mjs +12 -3
  6. package/esm2020/src/render3/component.mjs +3 -3
  7. package/esm2020/src/render3/component_ref.mjs +24 -18
  8. package/esm2020/src/render3/context_discovery.mjs +9 -3
  9. package/esm2020/src/render3/di.mjs +177 -97
  10. package/esm2020/src/render3/hooks.mjs +3 -3
  11. package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
  12. package/esm2020/src/render3/instructions/shared.mjs +11 -7
  13. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  14. package/esm2020/src/render3/interfaces/lview_tracking.mjs +8 -5
  15. package/esm2020/src/render3/interfaces/renderer_dom.mjs +1 -1
  16. package/esm2020/src/render3/interfaces/view.mjs +3 -2
  17. package/esm2020/src/render3/node_manipulation.mjs +9 -3
  18. package/esm2020/src/version.mjs +1 -1
  19. package/esm2020/testing/src/fake_async.mjs +3 -2
  20. package/esm2020/testing/src/logger.mjs +3 -3
  21. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  22. package/fesm2015/core.mjs +257 -142
  23. package/fesm2015/core.mjs.map +1 -1
  24. package/fesm2015/testing.mjs +3 -2
  25. package/fesm2015/testing.mjs.map +1 -1
  26. package/fesm2020/core.mjs +257 -142
  27. package/fesm2020/core.mjs.map +1 -1
  28. package/fesm2020/testing.mjs +3 -2
  29. package/fesm2020/testing.mjs.map +1 -1
  30. package/package.json +2 -2
  31. package/schematics/migrations/typed-forms/index.d.ts +1 -5
  32. package/schematics/migrations/typed-forms/index.js +12 -34
  33. package/schematics/migrations/typed-forms/util.d.ts +6 -9
  34. package/schematics/migrations/typed-forms/util.js +63 -40
  35. package/schematics/utils/typescript/parse_tsconfig.js +6 -2
  36. package/schematics/utils/typescript/symbol.js +4 -3
  37. package/testing/testing.d.ts +3 -2
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-next.4
2
+ * @license Angular v14.0.0-next.7
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1173,6 +1173,7 @@ const DECLARATION_LCONTAINER = 17;
1173
1173
  const PREORDER_HOOK_FLAGS = 18;
1174
1174
  const QUERIES = 19;
1175
1175
  const ID = 20;
1176
+ const EMBEDDED_VIEW_INJECTOR = 21;
1176
1177
  /**
1177
1178
  * Size of LView's header. Necessary to adjust for it when setting slots.
1178
1179
  *
@@ -1180,7 +1181,7 @@ const ID = 20;
1180
1181
  * instruction index into `LView` index. All other indexes should be in the `LView` index space and
1181
1182
  * there should be no need to refer to `HEADER_OFFSET` anywhere else.
1182
1183
  */
1183
- const HEADER_OFFSET = 21;
1184
+ const HEADER_OFFSET = 22;
1184
1185
  /**
1185
1186
  * Converts `TViewType` into human readable text.
1186
1187
  * Make sure this matches with `TViewType`
@@ -2475,7 +2476,7 @@ function incrementInitPhaseFlags(lView, initPhase) {
2475
2476
  assertNotEqual(initPhase, 3 /* InitPhaseCompleted */, 'Init hooks phase should not be incremented after all init hooks have been run.');
2476
2477
  let flags = lView[FLAGS];
2477
2478
  if ((flags & 3 /* InitPhaseStateMask */) === initPhase) {
2478
- flags &= 2047 /* IndexWithinInitPhaseReset */;
2479
+ flags &= 4095 /* IndexWithinInitPhaseReset */;
2479
2480
  flags += 1 /* InitPhaseStateIncrementer */;
2480
2481
  lView[FLAGS] = flags;
2481
2482
  }
@@ -2539,12 +2540,12 @@ function callHook(currentView, initPhase, arr, i) {
2539
2540
  const directiveIndex = isInitHook ? -arr[i] : arr[i];
2540
2541
  const directive = currentView[directiveIndex];
2541
2542
  if (isInitHook) {
2542
- const indexWithintInitPhase = currentView[FLAGS] >> 11 /* IndexWithinInitPhaseShift */;
2543
+ const indexWithintInitPhase = currentView[FLAGS] >> 12 /* IndexWithinInitPhaseShift */;
2543
2544
  // The init phase state must be always checked here as it may have been recursively updated.
2544
2545
  if (indexWithintInitPhase <
2545
2546
  (currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
2546
2547
  (currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
2547
- currentView[FLAGS] += 2048 /* IndexWithinInitPhaseIncrementer */;
2548
+ currentView[FLAGS] += 4096 /* IndexWithinInitPhaseIncrementer */;
2548
2549
  profiler(4 /* LifecycleHookStart */, directive, hook);
2549
2550
  try {
2550
2551
  hook.call(directive);
@@ -3105,6 +3106,8 @@ const BLOOM_MASK = BLOOM_SIZE - 1;
3105
3106
  const BLOOM_BUCKET_BITS = 5;
3106
3107
  /** Counter used to generate unique IDs for directives. */
3107
3108
  let nextNgElementId = 0;
3109
+ /** Value used when something wasn't found by an injector. */
3110
+ const NOT_FOUND = {};
3108
3111
  /**
3109
3112
  * Registers this directive as present in its node's injector by flipping the directive's
3110
3113
  * corresponding bit in the injector's bloom filter.
@@ -3216,23 +3219,7 @@ function getParentInjectorLocation(tNode, lView) {
3216
3219
  // `LView` hierarchy and look for it. If we walk of the top, that means that there is no parent
3217
3220
  // `NodeInjector`.
3218
3221
  while (lViewCursor !== null) {
3219
- // First determine the `parentTNode` location. The parent pointer differs based on `TView.type`.
3220
- const tView = lViewCursor[TVIEW];
3221
- const tViewType = tView.type;
3222
- if (tViewType === 2 /* Embedded */) {
3223
- ngDevMode &&
3224
- assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
3225
- parentTNode = tView.declTNode;
3226
- }
3227
- else if (tViewType === 1 /* Component */) {
3228
- // Components don't have `TView.declTNode` because each instance of component could be
3229
- // inserted in different location, hence `TView.declTNode` is meaningless.
3230
- parentTNode = lViewCursor[T_HOST];
3231
- }
3232
- else {
3233
- ngDevMode && assertEqual(tView.type, 0 /* Root */, 'Root type expected');
3234
- parentTNode = null;
3235
- }
3222
+ parentTNode = getTNodeFromLView(lViewCursor);
3236
3223
  if (parentTNode === null) {
3237
3224
  // If we have no parent, than we are done.
3238
3225
  return NO_PARENT_INJECTOR;
@@ -3393,93 +3380,116 @@ function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
3393
3380
  */
3394
3381
  function getOrCreateInjectable(tNode, lView, token, flags = InjectFlags.Default, notFoundValue) {
3395
3382
  if (tNode !== null) {
3396
- const bloomHash = bloomHashBitOrFactory(token);
3397
- // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
3398
- // so just call the factory function to create it.
3399
- if (typeof bloomHash === 'function') {
3400
- if (!enterDI(lView, tNode, flags)) {
3401
- // Failed to enter DI, try module injector instead. If a token is injected with the @Host
3402
- // flag, the module injector is not searched for that token in Ivy.
3403
- return (flags & InjectFlags.Host) ?
3404
- notFoundValueOrThrow(notFoundValue, token, flags) :
3405
- lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3383
+ // If the view or any of its ancestors have an embedded
3384
+ // view injector, we have to look it up there first.
3385
+ if (lView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) {
3386
+ const embeddedInjectorValue = lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, NOT_FOUND);
3387
+ if (embeddedInjectorValue !== NOT_FOUND) {
3388
+ return embeddedInjectorValue;
3406
3389
  }
3407
- try {
3408
- const value = bloomHash(flags);
3409
- if (value == null && !(flags & InjectFlags.Optional)) {
3410
- throwProviderNotFoundError(token);
3411
- }
3412
- else {
3413
- return value;
3414
- }
3390
+ }
3391
+ // Otherwise try the node injector.
3392
+ const value = lookupTokenUsingNodeInjector(tNode, lView, token, flags, NOT_FOUND);
3393
+ if (value !== NOT_FOUND) {
3394
+ return value;
3395
+ }
3396
+ }
3397
+ // Finally, fall back to the module injector.
3398
+ return lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3399
+ }
3400
+ /**
3401
+ * Returns the value associated to the given token from the node injector.
3402
+ *
3403
+ * @param tNode The Node where the search for the injector should start
3404
+ * @param lView The `LView` that contains the `tNode`
3405
+ * @param token The token to look for
3406
+ * @param flags Injection flags
3407
+ * @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
3408
+ * @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
3409
+ */
3410
+ function lookupTokenUsingNodeInjector(tNode, lView, token, flags, notFoundValue) {
3411
+ const bloomHash = bloomHashBitOrFactory(token);
3412
+ // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
3413
+ // so just call the factory function to create it.
3414
+ if (typeof bloomHash === 'function') {
3415
+ if (!enterDI(lView, tNode, flags)) {
3416
+ // Failed to enter DI, try module injector instead. If a token is injected with the @Host
3417
+ // flag, the module injector is not searched for that token in Ivy.
3418
+ return (flags & InjectFlags.Host) ?
3419
+ notFoundValueOrThrow(notFoundValue, token, flags) :
3420
+ lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3421
+ }
3422
+ try {
3423
+ const value = bloomHash(flags);
3424
+ if (value == null && !(flags & InjectFlags.Optional)) {
3425
+ throwProviderNotFoundError(token);
3415
3426
  }
3416
- finally {
3417
- leaveDI();
3418
- }
3419
- }
3420
- else if (typeof bloomHash === 'number') {
3421
- // A reference to the previous injector TView that was found while climbing the element
3422
- // injector tree. This is used to know if viewProviders can be accessed on the current
3423
- // injector.
3424
- let previousTView = null;
3425
- let injectorIndex = getInjectorIndex(tNode, lView);
3426
- let parentLocation = NO_PARENT_INJECTOR;
3427
- let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
3428
- // If we should skip this injector, or if there is no injector on this node, start by
3429
- // searching the parent injector.
3430
- if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
3431
- parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
3432
- lView[injectorIndex + 8 /* PARENT */];
3433
- if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
3434
- injectorIndex = -1;
3435
- }
3436
- else {
3437
- previousTView = lView[TVIEW];
3438
- injectorIndex = getParentInjectorIndex(parentLocation);
3439
- lView = getParentInjectorView(parentLocation, lView);
3440
- }
3427
+ else {
3428
+ return value;
3441
3429
  }
3442
- // Traverse up the injector tree until we find a potential match or until we know there
3443
- // *isn't* a match.
3444
- while (injectorIndex !== -1) {
3445
- ngDevMode && assertNodeInjector(lView, injectorIndex);
3446
- // Check the current injector. If it matches, see if it contains token.
3447
- const tView = lView[TVIEW];
3448
- ngDevMode &&
3449
- assertTNodeForLView(tView.data[injectorIndex + 8 /* TNODE */], lView);
3450
- if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
3451
- // At this point, we have an injector which *may* contain the token, so we step through
3452
- // the providers and directives associated with the injector's corresponding node to get
3453
- // the instance.
3454
- const instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
3455
- if (instance !== NOT_FOUND) {
3456
- return instance;
3457
- }
3458
- }
3459
- parentLocation = lView[injectorIndex + 8 /* PARENT */];
3460
- if (parentLocation !== NO_PARENT_INJECTOR &&
3461
- shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + 8 /* TNODE */] === hostTElementNode) &&
3462
- bloomHasToken(bloomHash, injectorIndex, lView)) {
3463
- // The def wasn't found anywhere on this node, so it was a false positive.
3464
- // Traverse up the tree and continue searching.
3465
- previousTView = tView;
3466
- injectorIndex = getParentInjectorIndex(parentLocation);
3467
- lView = getParentInjectorView(parentLocation, lView);
3468
- }
3469
- else {
3470
- // If we should not search parent OR If the ancestor bloom filter value does not have the
3471
- // bit corresponding to the directive we can give up on traversing up to find the specific
3472
- // injector.
3473
- injectorIndex = -1;
3430
+ }
3431
+ finally {
3432
+ leaveDI();
3433
+ }
3434
+ }
3435
+ else if (typeof bloomHash === 'number') {
3436
+ // A reference to the previous injector TView that was found while climbing the element
3437
+ // injector tree. This is used to know if viewProviders can be accessed on the current
3438
+ // injector.
3439
+ let previousTView = null;
3440
+ let injectorIndex = getInjectorIndex(tNode, lView);
3441
+ let parentLocation = NO_PARENT_INJECTOR;
3442
+ let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
3443
+ // If we should skip this injector, or if there is no injector on this node, start by
3444
+ // searching the parent injector.
3445
+ if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
3446
+ parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
3447
+ lView[injectorIndex + 8 /* PARENT */];
3448
+ if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
3449
+ injectorIndex = -1;
3450
+ }
3451
+ else {
3452
+ previousTView = lView[TVIEW];
3453
+ injectorIndex = getParentInjectorIndex(parentLocation);
3454
+ lView = getParentInjectorView(parentLocation, lView);
3455
+ }
3456
+ }
3457
+ // Traverse up the injector tree until we find a potential match or until we know there
3458
+ // *isn't* a match.
3459
+ while (injectorIndex !== -1) {
3460
+ ngDevMode && assertNodeInjector(lView, injectorIndex);
3461
+ // Check the current injector. If it matches, see if it contains token.
3462
+ const tView = lView[TVIEW];
3463
+ ngDevMode &&
3464
+ assertTNodeForLView(tView.data[injectorIndex + 8 /* TNODE */], lView);
3465
+ if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
3466
+ // At this point, we have an injector which *may* contain the token, so we step through
3467
+ // the providers and directives associated with the injector's corresponding node to get
3468
+ // the instance.
3469
+ const instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
3470
+ if (instance !== NOT_FOUND) {
3471
+ return instance;
3474
3472
  }
3475
3473
  }
3474
+ parentLocation = lView[injectorIndex + 8 /* PARENT */];
3475
+ if (parentLocation !== NO_PARENT_INJECTOR &&
3476
+ shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + 8 /* TNODE */] === hostTElementNode) &&
3477
+ bloomHasToken(bloomHash, injectorIndex, lView)) {
3478
+ // The def wasn't found anywhere on this node, so it was a false positive.
3479
+ // Traverse up the tree and continue searching.
3480
+ previousTView = tView;
3481
+ injectorIndex = getParentInjectorIndex(parentLocation);
3482
+ lView = getParentInjectorView(parentLocation, lView);
3483
+ }
3484
+ else {
3485
+ // If we should not search parent OR If the ancestor bloom filter value does not have the
3486
+ // bit corresponding to the directive we can give up on traversing up to find the specific
3487
+ // injector.
3488
+ injectorIndex = -1;
3489
+ }
3476
3490
  }
3477
3491
  }
3478
- return lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3479
- }
3480
- const NOT_FOUND = {};
3481
- function createNodeInjector() {
3482
- return new NodeInjector(getCurrentTNode(), getLView());
3492
+ return notFoundValue;
3483
3493
  }
3484
3494
  function searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode) {
3485
3495
  const currentTView = lView[TVIEW];
@@ -3653,6 +3663,10 @@ class NodeInjector {
3653
3663
  return getOrCreateInjectable(this._tNode, this._lView, token, flags, notFoundValue);
3654
3664
  }
3655
3665
  }
3666
+ /** Creates a `NodeInjector` for the current node. */
3667
+ function createNodeInjector() {
3668
+ return new NodeInjector(getCurrentTNode(), getLView());
3669
+ }
3656
3670
  /**
3657
3671
  * @codeGenApi
3658
3672
  */
@@ -3691,6 +3705,73 @@ function getFactoryOf(type) {
3691
3705
  }
3692
3706
  return getFactoryDef(type);
3693
3707
  }
3708
+ /**
3709
+ * Returns a value from the closest embedded or node injector.
3710
+ *
3711
+ * @param tNode The Node where the search for the injector should start
3712
+ * @param lView The `LView` that contains the `tNode`
3713
+ * @param token The token to look for
3714
+ * @param flags Injection flags
3715
+ * @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
3716
+ * @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
3717
+ */
3718
+ function lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, notFoundValue) {
3719
+ let currentTNode = tNode;
3720
+ let currentLView = lView;
3721
+ // When an LView with an embedded view injector is inserted, it'll likely be interlaced with
3722
+ // nodes who may have injectors (e.g. node injector -> embedded view injector -> node injector).
3723
+ // Since the bloom filters for the node injectors have already been constructed and we don't
3724
+ // have a way of extracting the records from an injector, the only way to maintain the correct
3725
+ // hierarchy when resolving the value is to walk it node-by-node while attempting to resolve
3726
+ // the token at each level.
3727
+ while (currentTNode !== null && currentLView !== null &&
3728
+ (currentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) &&
3729
+ !(currentLView[FLAGS] & 512 /* IsRoot */)) {
3730
+ ngDevMode && assertTNodeForLView(currentTNode, currentLView);
3731
+ // Note that this lookup on the node injector is using the `Self` flag, because
3732
+ // we don't want the node injector to look at any parent injectors since we
3733
+ // may hit the embedded view injector first.
3734
+ const nodeInjectorValue = lookupTokenUsingNodeInjector(currentTNode, currentLView, token, flags | InjectFlags.Self, NOT_FOUND);
3735
+ if (nodeInjectorValue !== NOT_FOUND) {
3736
+ return nodeInjectorValue;
3737
+ }
3738
+ // Has an explicit type due to a TS bug: https://github.com/microsoft/TypeScript/issues/33191
3739
+ let parentTNode = currentTNode.parent;
3740
+ // `TNode.parent` includes the parent within the current view only. If it doesn't exist,
3741
+ // it means that we've hit the view boundary and we need to go up to the next view.
3742
+ if (!parentTNode) {
3743
+ // Before we go to the next LView, check if the token exists on the current embedded injector.
3744
+ const embeddedViewInjector = currentLView[EMBEDDED_VIEW_INJECTOR];
3745
+ if (embeddedViewInjector) {
3746
+ const embeddedViewInjectorValue = embeddedViewInjector.get(token, NOT_FOUND, flags);
3747
+ if (embeddedViewInjectorValue !== NOT_FOUND) {
3748
+ return embeddedViewInjectorValue;
3749
+ }
3750
+ }
3751
+ // Otherwise keep going up the tree.
3752
+ parentTNode = getTNodeFromLView(currentLView);
3753
+ currentLView = currentLView[DECLARATION_VIEW];
3754
+ }
3755
+ currentTNode = parentTNode;
3756
+ }
3757
+ return notFoundValue;
3758
+ }
3759
+ /** Gets the TNode associated with an LView inside of the declaration view. */
3760
+ function getTNodeFromLView(lView) {
3761
+ const tView = lView[TVIEW];
3762
+ const tViewType = tView.type;
3763
+ // The parent pointer differs based on `TView.type`.
3764
+ if (tViewType === 2 /* Embedded */) {
3765
+ ngDevMode && assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
3766
+ return tView.declTNode;
3767
+ }
3768
+ else if (tViewType === 1 /* Component */) {
3769
+ // Components don't have `TView.declTNode` because each instance of component could be
3770
+ // inserted in different location, hence `TView.declTNode` is meaningless.
3771
+ return lView[T_HOST];
3772
+ }
3773
+ return null;
3774
+ }
3694
3775
 
3695
3776
  /**
3696
3777
  * @license
@@ -6182,11 +6263,14 @@ function getSanitizer() {
6182
6263
  const TRACKED_LVIEWS = new Map();
6183
6264
  // Used for generating unique IDs for LViews.
6184
6265
  let uniqueIdCounter = 0;
6185
- /** Starts tracking an LView and returns a unique ID that can be used for future lookups. */
6266
+ /** Gets a unique ID that can be assigned to an LView. */
6267
+ function getUniqueLViewId() {
6268
+ return uniqueIdCounter++;
6269
+ }
6270
+ /** Starts tracking an LView. */
6186
6271
  function registerLView(lView) {
6187
- const id = uniqueIdCounter++;
6188
- TRACKED_LVIEWS.set(id, lView);
6189
- return id;
6272
+ ngDevMode && assertNumber(lView[ID], 'LView must have an ID in order to be registered');
6273
+ TRACKED_LVIEWS.set(lView[ID], lView);
6190
6274
  }
6191
6275
  /** Gets an LView by its unique ID. */
6192
6276
  function getLViewById(id) {
@@ -6395,7 +6479,13 @@ function attachPatchData(target, data) {
6395
6479
  // Only attach the ID of the view in order to avoid memory leaks (see #41047). We only do this
6396
6480
  // for `LView`, because we have control over when an `LView` is created and destroyed, whereas
6397
6481
  // we can't know when to remove an `LContext`.
6398
- target[MONKEY_PATCH_KEY_NAME] = isLView(data) ? data[ID] : data;
6482
+ if (isLView(data)) {
6483
+ target[MONKEY_PATCH_KEY_NAME] = data[ID];
6484
+ registerLView(data);
6485
+ }
6486
+ else {
6487
+ target[MONKEY_PATCH_KEY_NAME] = data;
6488
+ }
6399
6489
  }
6400
6490
  /**
6401
6491
  * Returns the monkey-patch value data present on the target (which could be
@@ -7525,7 +7615,8 @@ function nativeInsertBefore(renderer, parent, child, beforeNode, isMove) {
7525
7615
  renderer.insertBefore(parent, child, beforeNode, isMove);
7526
7616
  }
7527
7617
  else {
7528
- parent.insertBefore(child, beforeNode, isMove);
7618
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
7619
+ targetParent.insertBefore(child, beforeNode, isMove);
7529
7620
  }
7530
7621
  }
7531
7622
  function nativeAppendChild(renderer, parent, child) {
@@ -7535,7 +7626,8 @@ function nativeAppendChild(renderer, parent, child) {
7535
7626
  renderer.appendChild(parent, child);
7536
7627
  }
7537
7628
  else {
7538
- parent.appendChild(child);
7629
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
7630
+ targetParent.appendChild(child);
7539
7631
  }
7540
7632
  }
7541
7633
  function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove) {
@@ -7555,6 +7647,10 @@ function nativeRemoveChild(renderer, parent, child, isHostElement) {
7555
7647
  parent.removeChild(child);
7556
7648
  }
7557
7649
  }
7650
+ /** Checks if an element is a `<template>` node. */
7651
+ function isTemplateNode(node) {
7652
+ return node.tagName === 'TEMPLATE' && node.content !== undefined;
7653
+ }
7558
7654
  /**
7559
7655
  * Returns a native parent of a given native node.
7560
7656
  */
@@ -9075,7 +9171,7 @@ class LViewDebug {
9075
9171
  attached: !!(flags & 128 /* Attached */),
9076
9172
  destroyed: !!(flags & 256 /* Destroyed */),
9077
9173
  isRoot: !!(flags & 512 /* IsRoot */),
9078
- indexWithinInitPhase: flags >> 11 /* IndexWithinInitPhaseShift */,
9174
+ indexWithinInitPhase: flags >> 12 /* IndexWithinInitPhaseShift */,
9079
9175
  };
9080
9176
  }
9081
9177
  get parent() {
@@ -9370,10 +9466,14 @@ function renderChildComponents(hostLView, components) {
9370
9466
  renderComponent$1(hostLView, components[i]);
9371
9467
  }
9372
9468
  }
9373
- function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector) {
9469
+ function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
9374
9470
  const lView = ngDevMode ? cloneToLViewFromTViewBlueprint(tView) : tView.blueprint.slice();
9375
9471
  lView[HOST] = host;
9376
9472
  lView[FLAGS] = flags | 4 /* CreationMode */ | 128 /* Attached */ | 8 /* FirstLViewPass */;
9473
+ if (embeddedViewInjector !== null ||
9474
+ (parentLView && (parentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */))) {
9475
+ lView[FLAGS] |= 2048 /* HasEmbeddedViewInjector */;
9476
+ }
9377
9477
  resetPreOrderHookFlags(lView);
9378
9478
  ngDevMode && tView.declTNode && parentLView && assertTNodeForLView(tView.declTNode, parentLView);
9379
9479
  lView[PARENT] = lView[DECLARATION_VIEW] = parentLView;
@@ -9385,7 +9485,8 @@ function createLView(parentLView, tView, context, flags, host, tHostNode, render
9385
9485
  lView[SANITIZER] = sanitizer || parentLView && parentLView[SANITIZER] || null;
9386
9486
  lView[INJECTOR$1] = injector || parentLView && parentLView[INJECTOR$1] || null;
9387
9487
  lView[T_HOST] = tHostNode;
9388
- lView[ID] = registerLView(lView);
9488
+ lView[ID] = getUniqueLViewId();
9489
+ lView[EMBEDDED_VIEW_INJECTOR] = embeddedViewInjector;
9389
9490
  ngDevMode &&
9390
9491
  assertEqual(tView.type == 2 /* Embedded */ ? parentLView !== null : true, true, 'Embedded views must have parentLView');
9391
9492
  lView[DECLARATION_COMPONENT_VIEW] =
@@ -10394,7 +10495,6 @@ function instantiateAllDirectives(tView, lView, tNode, native) {
10394
10495
  function invokeDirectivesHostBindings(tView, lView, tNode) {
10395
10496
  const start = tNode.directiveStart;
10396
10497
  const end = tNode.directiveEnd;
10397
- const firstCreatePass = tView.firstCreatePass;
10398
10498
  const elementIndex = tNode.index;
10399
10499
  const currentDirectiveIndex = getCurrentDirectiveIndex();
10400
10500
  try {
@@ -10541,7 +10641,7 @@ function addComponentLogic(lView, hostTNode, def) {
10541
10641
  // Only component views should be added to the view tree directly. Embedded views are
10542
10642
  // accessed through their containers because they may be removed / re-added later.
10543
10643
  const rendererFactory = lView[RENDERER_FACTORY];
10544
- const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null));
10644
+ const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null, null));
10545
10645
  // Component view will always be created before any injected LContainers,
10546
10646
  // so this is a regular element, wrap it with the component view
10547
10647
  lView[hostTNode.index] = componentView;
@@ -12283,7 +12383,7 @@ function renderComponent(componentType /* Type as workaround for: Microsoft/Type
12283
12383
  const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
12284
12384
  const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
12285
12385
  const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
12286
- const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null);
12386
+ const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
12287
12387
  enterView(rootView);
12288
12388
  let component;
12289
12389
  try {
@@ -12338,7 +12438,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
12338
12438
  }
12339
12439
  }
12340
12440
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
12341
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null);
12441
+ const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
12342
12442
  if (tView.firstCreatePass) {
12343
12443
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
12344
12444
  markAsComponentHost(tView, tNode);
@@ -21186,7 +21286,7 @@ class Version {
21186
21286
  /**
21187
21287
  * @publicApi
21188
21288
  */
21189
- const VERSION = new Version('14.0.0-next.4');
21289
+ const VERSION = new Version('14.0.0-next.7');
21190
21290
 
21191
21291
  /**
21192
21292
  * @license
@@ -21591,22 +21691,28 @@ function getNamespace(elementName) {
21591
21691
  const name = elementName.toLowerCase();
21592
21692
  return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
21593
21693
  }
21594
- function createChainedInjector(rootViewInjector, moduleInjector) {
21595
- return {
21596
- get: (token, notFoundValue, flags) => {
21597
- const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21598
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21599
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21600
- // Return the value from the root element injector when
21601
- // - it provides it
21602
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21603
- // - the module injector should not be checked
21604
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21605
- return value;
21606
- }
21607
- return moduleInjector.get(token, notFoundValue, flags);
21694
+ /**
21695
+ * Injector that looks up a value using a specific injector, before falling back to the module
21696
+ * injector. Used primarily when creating components or embedded views dynamically.
21697
+ */
21698
+ class ChainedInjector {
21699
+ constructor(injector, parentInjector) {
21700
+ this.injector = injector;
21701
+ this.parentInjector = parentInjector;
21702
+ }
21703
+ get(token, notFoundValue, flags) {
21704
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21705
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21706
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21707
+ // Return the value from the root element injector when
21708
+ // - it provides it
21709
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21710
+ // - the module injector should not be checked
21711
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21712
+ return value;
21608
21713
  }
21609
- };
21714
+ return this.parentInjector.get(token, notFoundValue, flags);
21715
+ }
21610
21716
  }
21611
21717
  /**
21612
21718
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
@@ -21634,7 +21740,7 @@ class ComponentFactory extends ComponentFactory$1 {
21634
21740
  }
21635
21741
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21636
21742
  ngModule = ngModule || this.ngModule;
21637
- const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21743
+ const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21638
21744
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21639
21745
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21640
21746
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -21649,7 +21755,7 @@ class ComponentFactory extends ComponentFactory$1 {
21649
21755
  const rootContext = createRootContext();
21650
21756
  // Create the root view. Uses empty TView and ContentTemplate.
21651
21757
  const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
21652
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector);
21758
+ const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
21653
21759
  // rootView is the parent when bootstrapping
21654
21760
  // TODO(misko): it looks like we are entering view here but we don't really need to as
21655
21761
  // `renderView` does that. However as the code is written it is needed because
@@ -22769,9 +22875,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22769
22875
  this._declarationTContainer = _declarationTContainer;
22770
22876
  this.elementRef = elementRef;
22771
22877
  }
22772
- createEmbeddedView(context) {
22878
+ createEmbeddedView(context, injector) {
22773
22879
  const embeddedTView = this._declarationTContainer.tViews;
22774
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22880
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null, injector || null);
22775
22881
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22776
22882
  ngDevMode && assertLContainer(declarationLContainer);
22777
22883
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22887,8 +22993,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22887
22993
  get length() {
22888
22994
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22889
22995
  }
22890
- createEmbeddedView(templateRef, context, index) {
22891
- const viewRef = templateRef.createEmbeddedView(context || {});
22996
+ createEmbeddedView(templateRef, context, indexOrOptions) {
22997
+ let index;
22998
+ let injector;
22999
+ if (typeof indexOrOptions === 'number') {
23000
+ index = indexOrOptions;
23001
+ }
23002
+ else if (indexOrOptions != null) {
23003
+ index = indexOrOptions.index;
23004
+ injector = indexOrOptions.injector;
23005
+ }
23006
+ const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22892
23007
  this.insert(viewRef, index);
22893
23008
  return viewRef;
22894
23009
  }
@@ -25039,16 +25154,16 @@ Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: C
25039
25154
  /**
25040
25155
  * Work out the locale from the potential global properties.
25041
25156
  *
25042
- * * Closure Compiler: use `goog.getLocale()`.
25157
+ * * Closure Compiler: use `goog.LOCALE`.
25043
25158
  * * Ivy enabled: use `$localize.locale`
25044
25159
  */
25045
25160
  function getGlobalLocale() {
25046
25161
  if (typeof ngI18nClosureMode !== 'undefined' && ngI18nClosureMode &&
25047
- typeof goog !== 'undefined' && goog.getLocale() !== 'en') {
25048
- // * The default `goog.getLocale()` value is `en`, while Angular used `en-US`.
25162
+ typeof goog !== 'undefined' && goog.LOCALE !== 'en') {
25163
+ // * The default `goog.LOCALE` value is `en`, while Angular used `en-US`.
25049
25164
  // * In order to preserve backwards compatibility, we use Angular default value over
25050
25165
  // Closure Compiler's one.
25051
- return goog.getLocale();
25166
+ return goog.LOCALE;
25052
25167
  }
25053
25168
  else {
25054
25169
  // KEEP `typeof $localize !== 'undefined' && $localize.locale` IN SYNC WITH THE LOCALIZE