@angular/core 14.0.4 → 14.0.5

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 (33) hide show
  1. package/esm2020/src/application_ref.mjs +1 -1
  2. package/esm2020/src/core.mjs +1 -1
  3. package/esm2020/src/core_render3_private_export.mjs +2 -2
  4. package/esm2020/src/debug/debug_node.mjs +2 -3
  5. package/esm2020/src/errors.mjs +1 -1
  6. package/esm2020/src/render/api.mjs +2 -11
  7. package/esm2020/src/render3/component.mjs +3 -58
  8. package/esm2020/src/render3/component_ref.mjs +9 -3
  9. package/esm2020/src/render3/index.mjs +3 -3
  10. package/esm2020/src/render3/instructions/listener.mjs +34 -44
  11. package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
  12. package/esm2020/src/render3/instructions/shared.mjs +19 -57
  13. package/esm2020/src/render3/instructions/styling.mjs +2 -2
  14. package/esm2020/src/render3/interfaces/renderer.mjs +1 -26
  15. package/esm2020/src/render3/interfaces/view.mjs +1 -1
  16. package/esm2020/src/render3/node_manipulation.mjs +24 -87
  17. package/esm2020/src/render3/node_manipulation_i18n.mjs +1 -1
  18. package/esm2020/src/render3/util/attrs_utils.mjs +4 -12
  19. package/esm2020/src/render3/util/view_utils.mjs +3 -6
  20. package/esm2020/src/version.mjs +1 -1
  21. package/esm2020/testing/src/logger.mjs +3 -3
  22. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  23. package/fesm2015/core.mjs +1751 -1946
  24. package/fesm2015/core.mjs.map +1 -1
  25. package/fesm2015/testing.mjs +1625 -1912
  26. package/fesm2015/testing.mjs.map +1 -1
  27. package/fesm2020/core.mjs +1751 -1946
  28. package/fesm2020/core.mjs.map +1 -1
  29. package/fesm2020/testing.mjs +1625 -1912
  30. package/fesm2020/testing.mjs.map +1 -1
  31. package/index.d.ts +55 -128
  32. package/package.json +1 -1
  33. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.4
2
+ * @license Angular v14.0.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -3189,96 +3189,6 @@ function getNamespaceUri(namespace) {
3189
3189
  (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
3190
3190
  }
3191
3191
 
3192
- /**
3193
- * @license
3194
- * Copyright Google LLC All Rights Reserved.
3195
- *
3196
- * Use of this source code is governed by an MIT-style license that can be
3197
- * found in the LICENSE file at https://angular.io/license
3198
- */
3199
- /**
3200
- * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
3201
- * inject the `DOCUMENT` token and are done.
3202
- *
3203
- * Ivy is special because it does not rely upon the DI and must get hold of the document some other
3204
- * way.
3205
- *
3206
- * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
3207
- * Wherever ivy needs the global document, it calls `getDocument()` instead.
3208
- *
3209
- * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
3210
- * tell ivy what the global `document` is.
3211
- *
3212
- * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
3213
- * by calling `setDocument()` when providing the `DOCUMENT` token.
3214
- */
3215
- let DOCUMENT = undefined;
3216
- /**
3217
- * Tell ivy what the `document` is for this platform.
3218
- *
3219
- * It is only necessary to call this if the current platform is not a browser.
3220
- *
3221
- * @param document The object representing the global `document` in this environment.
3222
- */
3223
- function setDocument(document) {
3224
- DOCUMENT = document;
3225
- }
3226
- /**
3227
- * Access the object that represents the `document` for this platform.
3228
- *
3229
- * Ivy calls this whenever it needs to access the `document` object.
3230
- * For example to create the renderer or to do sanitization.
3231
- */
3232
- function getDocument() {
3233
- if (DOCUMENT !== undefined) {
3234
- return DOCUMENT;
3235
- }
3236
- else if (typeof document !== 'undefined') {
3237
- return document;
3238
- }
3239
- // No "document" can be found. This should only happen if we are running ivy outside Angular and
3240
- // the current platform is not a browser. Since this is not a supported scenario at the moment
3241
- // this should not happen in Angular apps.
3242
- // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
3243
- // public API. Meanwhile we just return `undefined` and let the application fail.
3244
- return undefined;
3245
- }
3246
-
3247
- /**
3248
- * @license
3249
- * Copyright Google LLC All Rights Reserved.
3250
- *
3251
- * Use of this source code is governed by an MIT-style license that can be
3252
- * found in the LICENSE file at https://angular.io/license
3253
- */
3254
- // TODO: cleanup once the code is merged in angular/angular
3255
- var RendererStyleFlags3;
3256
- (function (RendererStyleFlags3) {
3257
- RendererStyleFlags3[RendererStyleFlags3["Important"] = 1] = "Important";
3258
- RendererStyleFlags3[RendererStyleFlags3["DashCase"] = 2] = "DashCase";
3259
- })(RendererStyleFlags3 || (RendererStyleFlags3 = {}));
3260
- /** Returns whether the `renderer` is a `ProceduralRenderer3` */
3261
- function isProceduralRenderer(renderer) {
3262
- return !!(renderer.listen);
3263
- }
3264
- let renderer3Enabled = false;
3265
- function enableRenderer3() {
3266
- renderer3Enabled = true;
3267
- }
3268
- const domRendererFactory3 = {
3269
- createRenderer: (hostElement, rendererType) => {
3270
- if (!renderer3Enabled) {
3271
- throw new Error(ngDevMode ?
3272
- `Renderer3 is not supported. This problem is likely caused by some component in the hierarchy was constructed without a correct parent injector.` :
3273
- 'Renderer3 disabled');
3274
- }
3275
- return getDocument();
3276
- }
3277
- };
3278
- // Note: This hack is necessary so we don't erroneously get a circular dependency
3279
- // failure based on types.
3280
- const unusedValueExportToPlacateAjd$6 = 1;
3281
-
3282
3192
  /**
3283
3193
  * @license
3284
3194
  * Copyright Google LLC All Rights Reserved.
@@ -3361,7 +3271,6 @@ function getNativeByTNode(tNode, lView) {
3361
3271
  ngDevMode && assertTNodeForLView(tNode, lView);
3362
3272
  ngDevMode && assertIndexInRange(lView, tNode.index);
3363
3273
  const node = unwrapRNode(lView[tNode.index]);
3364
- ngDevMode && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3365
3274
  return node;
3366
3275
  }
3367
3276
  /**
@@ -3377,7 +3286,6 @@ function getNativeByTNodeOrNull(tNode, lView) {
3377
3286
  if (index !== -1) {
3378
3287
  ngDevMode && assertTNodeForLView(tNode, lView);
3379
3288
  const node = unwrapRNode(lView[index]);
3380
- ngDevMode && node !== null && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3381
3289
  return node;
3382
3290
  }
3383
3291
  return null;
@@ -4326,7 +4234,7 @@ function isFactory(obj) {
4326
4234
  }
4327
4235
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4328
4236
  // failure based on types.
4329
- const unusedValueExportToPlacateAjd$5 = 1;
4237
+ const unusedValueExportToPlacateAjd$6 = 1;
4330
4238
 
4331
4239
  /**
4332
4240
  * Converts `TNodeType` into human readable text.
@@ -4345,7 +4253,7 @@ function toTNodeTypeAsString(tNodeType) {
4345
4253
  }
4346
4254
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4347
4255
  // failure based on types.
4348
- const unusedValueExportToPlacateAjd$4 = 1;
4256
+ const unusedValueExportToPlacateAjd$5 = 1;
4349
4257
  /**
4350
4258
  * Returns `true` if the `TNode` has a directive which has `@Input()` for `class` binding.
4351
4259
  *
@@ -4449,7 +4357,6 @@ function assertPureTNodeType(type) {
4449
4357
  * @returns the index value that was last accessed in the attributes array
4450
4358
  */
4451
4359
  function setUpAttributes(renderer, native, attrs) {
4452
- const isProc = isProceduralRenderer(renderer);
4453
4360
  let i = 0;
4454
4361
  while (i < attrs.length) {
4455
4362
  const value = attrs[i];
@@ -4466,9 +4373,7 @@ function setUpAttributes(renderer, native, attrs) {
4466
4373
  const attrName = attrs[i++];
4467
4374
  const attrVal = attrs[i++];
4468
4375
  ngDevMode && ngDevMode.rendererSetAttribute++;
4469
- isProc ?
4470
- renderer.setAttribute(native, attrName, attrVal, namespaceURI) :
4471
- native.setAttributeNS(namespaceURI, attrName, attrVal);
4376
+ renderer.setAttribute(native, attrName, attrVal, namespaceURI);
4472
4377
  }
4473
4378
  else {
4474
4379
  // attrName is string;
@@ -4477,14 +4382,10 @@ function setUpAttributes(renderer, native, attrs) {
4477
4382
  // Standard attributes
4478
4383
  ngDevMode && ngDevMode.rendererSetAttribute++;
4479
4384
  if (isAnimationProp(attrName)) {
4480
- if (isProc) {
4481
- renderer.setProperty(native, attrName, attrVal);
4482
- }
4385
+ renderer.setProperty(native, attrName, attrVal);
4483
4386
  }
4484
4387
  else {
4485
- isProc ?
4486
- renderer.setAttribute(native, attrName, attrVal) :
4487
- native.setAttribute(attrName, attrVal);
4388
+ renderer.setAttribute(native, attrName, attrVal);
4488
4389
  }
4489
4390
  i++;
4490
4391
  }
@@ -5618,6 +5519,61 @@ function maybeUnwrapFn$1(value) {
5618
5519
  }
5619
5520
  }
5620
5521
 
5522
+ /**
5523
+ * @license
5524
+ * Copyright Google LLC All Rights Reserved.
5525
+ *
5526
+ * Use of this source code is governed by an MIT-style license that can be
5527
+ * found in the LICENSE file at https://angular.io/license
5528
+ */
5529
+ /**
5530
+ * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
5531
+ * inject the `DOCUMENT` token and are done.
5532
+ *
5533
+ * Ivy is special because it does not rely upon the DI and must get hold of the document some other
5534
+ * way.
5535
+ *
5536
+ * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
5537
+ * Wherever ivy needs the global document, it calls `getDocument()` instead.
5538
+ *
5539
+ * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
5540
+ * tell ivy what the global `document` is.
5541
+ *
5542
+ * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
5543
+ * by calling `setDocument()` when providing the `DOCUMENT` token.
5544
+ */
5545
+ let DOCUMENT = undefined;
5546
+ /**
5547
+ * Tell ivy what the `document` is for this platform.
5548
+ *
5549
+ * It is only necessary to call this if the current platform is not a browser.
5550
+ *
5551
+ * @param document The object representing the global `document` in this environment.
5552
+ */
5553
+ function setDocument(document) {
5554
+ DOCUMENT = document;
5555
+ }
5556
+ /**
5557
+ * Access the object that represents the `document` for this platform.
5558
+ *
5559
+ * Ivy calls this whenever it needs to access the `document` object.
5560
+ * For example to create the renderer or to do sanitization.
5561
+ */
5562
+ function getDocument() {
5563
+ if (DOCUMENT !== undefined) {
5564
+ return DOCUMENT;
5565
+ }
5566
+ else if (typeof document !== 'undefined') {
5567
+ return document;
5568
+ }
5569
+ // No "document" can be found. This should only happen if we are running ivy outside Angular and
5570
+ // the current platform is not a browser. Since this is not a supported scenario at the moment
5571
+ // this should not happen in Angular apps.
5572
+ // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
5573
+ // public API. Meanwhile we just return `undefined` and let the application fail.
5574
+ return undefined;
5575
+ }
5576
+
5621
5577
  /**
5622
5578
  * @license
5623
5579
  * Copyright Google LLC All Rights Reserved.
@@ -7287,6 +7243,17 @@ function ensureIcuContainerVisitorLoaded(loader) {
7287
7243
  }
7288
7244
  }
7289
7245
 
7246
+ /**
7247
+ * @license
7248
+ * Copyright Google LLC All Rights Reserved.
7249
+ *
7250
+ * Use of this source code is governed by an MIT-style license that can be
7251
+ * found in the LICENSE file at https://angular.io/license
7252
+ */
7253
+ // Note: This hack is necessary so we don't erroneously get a circular dependency
7254
+ // failure based on types.
7255
+ const unusedValueExportToPlacateAjd$4 = 1;
7256
+
7290
7257
  /**
7291
7258
  * @license
7292
7259
  * Copyright Google LLC All Rights Reserved.
@@ -7369,7 +7336,7 @@ function getNearestLContainer(viewOrContainer) {
7369
7336
  * Use of this source code is governed by an MIT-style license that can be
7370
7337
  * found in the LICENSE file at https://angular.io/license
7371
7338
  */
7372
- const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$8;
7339
+ const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$8;
7373
7340
  /**
7374
7341
  * NOTE: for performance reasons, the possible actions are inlined within the function instead of
7375
7342
  * being passed as an argument.
@@ -7394,7 +7361,6 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
7394
7361
  lNodeToHandle = lNodeToHandle[HOST];
7395
7362
  }
7396
7363
  const rNode = unwrapRNode(lNodeToHandle);
7397
- ngDevMode && !isProceduralRenderer(renderer) && assertDomNode(rNode);
7398
7364
  if (action === 0 /* WalkTNodeTreeAction.Create */ && parent !== null) {
7399
7365
  if (beforeNode == null) {
7400
7366
  nativeAppendChild(renderer, parent, rNode);
@@ -7421,17 +7387,14 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
7421
7387
  function createTextNode(renderer, value) {
7422
7388
  ngDevMode && ngDevMode.rendererCreateTextNode++;
7423
7389
  ngDevMode && ngDevMode.rendererSetText++;
7424
- return isProceduralRenderer(renderer) ? renderer.createText(value) :
7425
- renderer.createTextNode(value);
7390
+ return renderer.createText(value);
7426
7391
  }
7427
7392
  function updateTextNode(renderer, rNode, value) {
7428
7393
  ngDevMode && ngDevMode.rendererSetText++;
7429
- isProceduralRenderer(renderer) ? renderer.setValue(rNode, value) : rNode.textContent = value;
7394
+ renderer.setValue(rNode, value);
7430
7395
  }
7431
7396
  function createCommentNode(renderer, value) {
7432
7397
  ngDevMode && ngDevMode.rendererCreateComment++;
7433
- // isProceduralRenderer check is not needed because both `Renderer2` and `Renderer3` have the same
7434
- // method name.
7435
7398
  return renderer.createComment(escapeCommentText(value));
7436
7399
  }
7437
7400
  /**
@@ -7443,14 +7406,7 @@ function createCommentNode(renderer, value) {
7443
7406
  */
7444
7407
  function createElementNode(renderer, name, namespace) {
7445
7408
  ngDevMode && ngDevMode.rendererCreateElement++;
7446
- if (isProceduralRenderer(renderer)) {
7447
- return renderer.createElement(name, namespace);
7448
- }
7449
- else {
7450
- const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
7451
- return namespaceUri === null ? renderer.createElement(name) :
7452
- renderer.createElementNS(namespaceUri, name);
7453
- }
7409
+ return renderer.createElement(name, namespace);
7454
7410
  }
7455
7411
  /**
7456
7412
  * Removes all DOM elements associated with a view.
@@ -7682,7 +7638,7 @@ function detachView(lContainer, removeIndex) {
7682
7638
  function destroyLView(tView, lView) {
7683
7639
  if (!(lView[FLAGS] & 128 /* LViewFlags.Destroyed */)) {
7684
7640
  const renderer = lView[RENDERER];
7685
- if (isProceduralRenderer(renderer) && renderer.destroyNode) {
7641
+ if (renderer.destroyNode) {
7686
7642
  applyView(tView, lView, renderer, 3 /* WalkTNodeTreeAction.Destroy */, null, null);
7687
7643
  }
7688
7644
  destroyViewTree(lView);
@@ -7710,7 +7666,7 @@ function cleanUpView(tView, lView) {
7710
7666
  executeOnDestroys(tView, lView);
7711
7667
  processCleanups(tView, lView);
7712
7668
  // For component views only, the local renderer is destroyed at clean up time.
7713
- if (lView[TVIEW].type === 1 /* TViewType.Component */ && isProceduralRenderer(lView[RENDERER])) {
7669
+ if (lView[TVIEW].type === 1 /* TViewType.Component */) {
7714
7670
  ngDevMode && ngDevMode.rendererDestroy++;
7715
7671
  lView[RENDERER].destroy();
7716
7672
  }
@@ -7886,30 +7842,17 @@ function getClosestRElement(tView, tNode, lView) {
7886
7842
  }
7887
7843
  }
7888
7844
  /**
7889
- * Inserts a native node before another native node for a given parent using {@link Renderer3}.
7890
- * This is a utility function that can be used when native nodes were determined - it abstracts an
7891
- * actual renderer being used.
7845
+ * Inserts a native node before another native node for a given parent.
7846
+ * This is a utility function that can be used when native nodes were determined.
7892
7847
  */
7893
7848
  function nativeInsertBefore(renderer, parent, child, beforeNode, isMove) {
7894
7849
  ngDevMode && ngDevMode.rendererInsertBefore++;
7895
- if (isProceduralRenderer(renderer)) {
7896
- renderer.insertBefore(parent, child, beforeNode, isMove);
7897
- }
7898
- else {
7899
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
7900
- targetParent.insertBefore(child, beforeNode, isMove);
7901
- }
7850
+ renderer.insertBefore(parent, child, beforeNode, isMove);
7902
7851
  }
7903
7852
  function nativeAppendChild(renderer, parent, child) {
7904
7853
  ngDevMode && ngDevMode.rendererAppendChild++;
7905
7854
  ngDevMode && assertDefined(parent, 'parent node must be defined');
7906
- if (isProceduralRenderer(renderer)) {
7907
- renderer.appendChild(parent, child);
7908
- }
7909
- else {
7910
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
7911
- targetParent.appendChild(child);
7912
- }
7855
+ renderer.appendChild(parent, child);
7913
7856
  }
7914
7857
  function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove) {
7915
7858
  if (beforeNode !== null) {
@@ -7921,12 +7864,7 @@ function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove)
7921
7864
  }
7922
7865
  /** Removes a node from the DOM given its native parent. */
7923
7866
  function nativeRemoveChild(renderer, parent, child, isHostElement) {
7924
- if (isProceduralRenderer(renderer)) {
7925
- renderer.removeChild(parent, child, isHostElement);
7926
- }
7927
- else {
7928
- parent.removeChild(child);
7929
- }
7867
+ renderer.removeChild(parent, child, isHostElement);
7930
7868
  }
7931
7869
  /** Checks if an element is a `<template>` node. */
7932
7870
  function isTemplateNode(node) {
@@ -7936,13 +7874,13 @@ function isTemplateNode(node) {
7936
7874
  * Returns a native parent of a given native node.
7937
7875
  */
7938
7876
  function nativeParentNode(renderer, node) {
7939
- return (isProceduralRenderer(renderer) ? renderer.parentNode(node) : node.parentNode);
7877
+ return renderer.parentNode(node);
7940
7878
  }
7941
7879
  /**
7942
7880
  * Returns a native sibling of a given native node.
7943
7881
  */
7944
7882
  function nativeNextSibling(renderer, node) {
7945
- return isProceduralRenderer(renderer) ? renderer.nextSibling(node) : node.nextSibling;
7883
+ return renderer.nextSibling(node);
7946
7884
  }
7947
7885
  /**
7948
7886
  * Find a node in front of which `currentTNode` should be inserted.
@@ -8251,39 +8189,22 @@ function applyContainer(renderer, action, lContainer, parentRElement, beforeNode
8251
8189
  * otherwise).
8252
8190
  */
8253
8191
  function applyStyling(renderer, isClassBased, rNode, prop, value) {
8254
- const isProcedural = isProceduralRenderer(renderer);
8255
8192
  if (isClassBased) {
8256
8193
  // We actually want JS true/false here because any truthy value should add the class
8257
8194
  if (!value) {
8258
8195
  ngDevMode && ngDevMode.rendererRemoveClass++;
8259
- if (isProcedural) {
8260
- renderer.removeClass(rNode, prop);
8261
- }
8262
- else {
8263
- rNode.classList.remove(prop);
8264
- }
8196
+ renderer.removeClass(rNode, prop);
8265
8197
  }
8266
8198
  else {
8267
8199
  ngDevMode && ngDevMode.rendererAddClass++;
8268
- if (isProcedural) {
8269
- renderer.addClass(rNode, prop);
8270
- }
8271
- else {
8272
- ngDevMode && assertDefined(rNode.classList, 'HTMLElement expected');
8273
- rNode.classList.add(prop);
8274
- }
8200
+ renderer.addClass(rNode, prop);
8275
8201
  }
8276
8202
  }
8277
8203
  else {
8278
8204
  let flags = prop.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
8279
8205
  if (value == null /** || value === undefined */) {
8280
8206
  ngDevMode && ngDevMode.rendererRemoveStyle++;
8281
- if (isProcedural) {
8282
- renderer.removeStyle(rNode, prop, flags);
8283
- }
8284
- else {
8285
- rNode.style.removeProperty(prop);
8286
- }
8207
+ renderer.removeStyle(rNode, prop, flags);
8287
8208
  }
8288
8209
  else {
8289
8210
  // A value is important if it ends with `!important`. The style
@@ -8295,13 +8216,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
8295
8216
  flags |= RendererStyleFlags2.Important;
8296
8217
  }
8297
8218
  ngDevMode && ngDevMode.rendererSetStyle++;
8298
- if (isProcedural) {
8299
- renderer.setStyle(rNode, prop, value, flags);
8300
- }
8301
- else {
8302
- ngDevMode && assertDefined(rNode.style, 'HTMLElement expected');
8303
- rNode.style.setProperty(prop, value, isImportant ? 'important' : '');
8304
- }
8219
+ renderer.setStyle(rNode, prop, value, flags);
8305
8220
  }
8306
8221
  }
8307
8222
  }
@@ -8317,12 +8232,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
8317
8232
  */
8318
8233
  function writeDirectStyle(renderer, element, newValue) {
8319
8234
  ngDevMode && assertString(newValue, '\'newValue\' should be a string');
8320
- if (isProceduralRenderer(renderer)) {
8321
- renderer.setAttribute(element, 'style', newValue);
8322
- }
8323
- else {
8324
- element.style.cssText = newValue;
8325
- }
8235
+ renderer.setAttribute(element, 'style', newValue);
8326
8236
  ngDevMode && ngDevMode.rendererSetStyle++;
8327
8237
  }
8328
8238
  /**
@@ -8337,17 +8247,12 @@ function writeDirectStyle(renderer, element, newValue) {
8337
8247
  */
8338
8248
  function writeDirectClass(renderer, element, newValue) {
8339
8249
  ngDevMode && assertString(newValue, '\'newValue\' should be a string');
8340
- if (isProceduralRenderer(renderer)) {
8341
- if (newValue === '') {
8342
- // There are tests in `google3` which expect `element.getAttribute('class')` to be `null`.
8343
- renderer.removeAttribute(element, 'class');
8344
- }
8345
- else {
8346
- renderer.setAttribute(element, 'class', newValue);
8347
- }
8250
+ if (newValue === '') {
8251
+ // There are tests in `google3` which expect `element.getAttribute('class')` to be `null`.
8252
+ renderer.removeAttribute(element, 'class');
8348
8253
  }
8349
8254
  else {
8350
- element.className = newValue;
8255
+ renderer.setAttribute(element, 'class', newValue);
8351
8256
  }
8352
8257
  ngDevMode && ngDevMode.rendererSetClassName++;
8353
8258
  }
@@ -8397,7 +8302,7 @@ function classIndexOf(className, classToSearch, startingIndex) {
8397
8302
  * Use of this source code is governed by an MIT-style license that can be
8398
8303
  * found in the LICENSE file at https://angular.io/license
8399
8304
  */
8400
- const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3;
8305
+ const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4;
8401
8306
  const NG_TEMPLATE_SELECTOR = 'ng-template';
8402
8307
  /**
8403
8308
  * Search the `TAttributes` to see if it contains `cssClassToMatch` (case insensitive)
@@ -11812,6 +11717,13 @@ class LContainerDebug {
11812
11717
  }
11813
11718
  }
11814
11719
 
11720
+ /**
11721
+ * @license
11722
+ * Copyright Google LLC All Rights Reserved.
11723
+ *
11724
+ * Use of this source code is governed by an MIT-style license that can be
11725
+ * found in the LICENSE file at https://angular.io/license
11726
+ */
11815
11727
  /**
11816
11728
  * A permanent marker promise which signifies that the current CD tree is
11817
11729
  * clean.
@@ -11879,7 +11791,7 @@ function refreshChildComponents(hostLView, components) {
11879
11791
  /** Renders child components in the current view (creation mode). */
11880
11792
  function renderChildComponents(hostLView, components) {
11881
11793
  for (let i = 0; i < components.length; i++) {
11882
- renderComponent$1(hostLView, components[i]);
11794
+ renderComponent(hostLView, components[i]);
11883
11795
  }
11884
11796
  }
11885
11797
  function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
@@ -12397,16 +12309,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
12397
12309
  function createError(text, token) {
12398
12310
  return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
12399
12311
  }
12400
- function assertHostNodeExists(rElement, elementOrSelector) {
12401
- if (!rElement) {
12402
- if (typeof elementOrSelector === 'string') {
12403
- throw createError('Host node with selector not found:', elementOrSelector);
12404
- }
12405
- else {
12406
- throw createError('Host node is required:', elementOrSelector);
12407
- }
12408
- }
12409
- }
12410
12312
  /**
12411
12313
  * Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
12412
12314
  *
@@ -12415,21 +12317,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
12415
12317
  * @param encapsulation View Encapsulation defined for component that requests host element.
12416
12318
  */
12417
12319
  function locateHostElement(renderer, elementOrSelector, encapsulation) {
12418
- if (isProceduralRenderer(renderer)) {
12419
- // When using native Shadow DOM, do not clear host element to allow native slot projection
12420
- const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12421
- return renderer.selectRootElement(elementOrSelector, preserveContent);
12422
- }
12423
- let rElement = typeof elementOrSelector === 'string' ?
12424
- renderer.querySelector(elementOrSelector) :
12425
- elementOrSelector;
12426
- ngDevMode && assertHostNodeExists(rElement, elementOrSelector);
12427
- // Always clear host element's content when Renderer3 is in use. For procedural renderer case we
12428
- // make it depend on whether ShadowDom encapsulation is used (in which case the content should be
12429
- // preserved to allow native slot projection). ShadowDom encapsulation requires procedural
12430
- // renderer, and procedural renderer case is handled above.
12431
- rElement.textContent = '';
12432
- return rElement;
12320
+ // When using native Shadow DOM, do not clear host element to allow native slot projection
12321
+ const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12322
+ return renderer.selectRootElement(elementOrSelector, preserveContent);
12433
12323
  }
12434
12324
  /**
12435
12325
  * Saves context for this cleanup function in LView.cleanupInstances.
@@ -12644,13 +12534,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
12644
12534
  // It is assumed that the sanitizer is only added when the compiler determines that the
12645
12535
  // property is risky, so sanitization can be done without further checks.
12646
12536
  value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
12647
- if (isProceduralRenderer(renderer)) {
12648
- renderer.setProperty(element, propName, value);
12649
- }
12650
- else if (!isAnimationProp(propName)) {
12651
- element.setProperty ? element.setProperty(propName, value) :
12652
- element[propName] = value;
12653
- }
12537
+ renderer.setProperty(element, propName, value);
12654
12538
  }
12655
12539
  else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
12656
12540
  // If the node is a container and the property didn't
@@ -12674,23 +12558,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
12674
12558
  const debugValue = normalizeDebugBindingValue(value);
12675
12559
  if (type & 3 /* TNodeType.AnyRNode */) {
12676
12560
  if (value == null) {
12677
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, attrName) :
12678
- element.removeAttribute(attrName);
12561
+ renderer.removeAttribute(element, attrName);
12679
12562
  }
12680
12563
  else {
12681
- isProceduralRenderer(renderer) ?
12682
- renderer.setAttribute(element, attrName, debugValue) :
12683
- element.setAttribute(attrName, debugValue);
12564
+ renderer.setAttribute(element, attrName, debugValue);
12684
12565
  }
12685
12566
  }
12686
12567
  else {
12687
12568
  const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
12688
- if (isProceduralRenderer(renderer)) {
12689
- renderer.setValue(element, textContent);
12690
- }
12691
- else {
12692
- element.textContent = textContent;
12693
- }
12569
+ renderer.setValue(element, textContent);
12694
12570
  }
12695
12571
  }
12696
12572
  function setNgReflectProperties(lView, element, type, dataValue, value) {
@@ -13044,19 +12920,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
13044
12920
  function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
13045
12921
  if (value == null) {
13046
12922
  ngDevMode && ngDevMode.rendererRemoveAttribute++;
13047
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, name, namespace) :
13048
- element.removeAttribute(name);
12923
+ renderer.removeAttribute(element, name, namespace);
13049
12924
  }
13050
12925
  else {
13051
12926
  ngDevMode && ngDevMode.rendererSetAttribute++;
13052
12927
  const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
13053
- if (isProceduralRenderer(renderer)) {
13054
- renderer.setAttribute(element, name, strValue, namespace);
13055
- }
13056
- else {
13057
- namespace ? element.setAttributeNS(namespace, name, strValue) :
13058
- element.setAttribute(name, strValue);
13059
- }
12928
+ renderer.setAttribute(element, name, strValue, namespace);
13060
12929
  }
13061
12930
  }
13062
12931
  /**
@@ -13148,7 +13017,6 @@ const LContainerArray = class LContainer extends Array {
13148
13017
  */
13149
13018
  function createLContainer(hostNative, currentView, native, tNode) {
13150
13019
  ngDevMode && assertLView(currentView);
13151
- ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
13152
13020
  // https://jsperf.com/array-literal-vs-new-array-really
13153
13021
  const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
13154
13022
  true, // Boolean `true` in this position signifies that this is an `LContainer`
@@ -13264,7 +13132,7 @@ function refreshContainsDirtyView(lView) {
13264
13132
  }
13265
13133
  }
13266
13134
  }
13267
- function renderComponent$1(hostLView, componentHostIdx) {
13135
+ function renderComponent(hostLView, componentHostIdx) {
13268
13136
  ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
13269
13137
  const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
13270
13138
  const componentTView = componentView[TVIEW];
@@ -13616,48 +13484,135 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
13616
13484
  * Use of this source code is governed by an MIT-style license that can be
13617
13485
  * found in the LICENSE file at https://angular.io/license
13618
13486
  */
13487
+ // TODO: A hack to not pull in the NullInjector from @angular/core.
13488
+ const NULL_INJECTOR = {
13489
+ get: (token, notFoundValue) => {
13490
+ throwProviderNotFoundError(token, 'NullInjector');
13491
+ }
13492
+ };
13619
13493
  /**
13620
- * Synchronously perform change detection on a component (and possibly its sub-components).
13494
+ * Creates the root component view and the root component node.
13621
13495
  *
13622
- * This function triggers change detection in a synchronous way on a component.
13496
+ * @param rNode Render host element.
13497
+ * @param def ComponentDef
13498
+ * @param rootView The parent view where the host node is stored
13499
+ * @param rendererFactory Factory to be used for creating child renderers.
13500
+ * @param hostRenderer The current renderer
13501
+ * @param sanitizer The sanitizer, if provided
13623
13502
  *
13624
- * @param component The component which the change detection should be performed on.
13503
+ * @returns Component view created
13625
13504
  */
13626
- function detectChanges(component) {
13627
- const view = getComponentViewByInstance(component);
13628
- detectChangesInternal(view[TVIEW], view, component);
13505
+ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
13506
+ const tView = rootView[TVIEW];
13507
+ const index = HEADER_OFFSET;
13508
+ ngDevMode && assertIndexInRange(rootView, index);
13509
+ rootView[index] = rNode;
13510
+ // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
13511
+ // the same time we want to communicate the debug `TNode` that this is a special `TNode`
13512
+ // representing a host element.
13513
+ const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
13514
+ const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
13515
+ if (mergedAttrs !== null) {
13516
+ computeStaticStyling(tNode, mergedAttrs, true);
13517
+ if (rNode !== null) {
13518
+ setUpAttributes(hostRenderer, rNode, mergedAttrs);
13519
+ if (tNode.classes !== null) {
13520
+ writeDirectClass(hostRenderer, rNode, tNode.classes);
13521
+ }
13522
+ if (tNode.styles !== null) {
13523
+ writeDirectStyle(hostRenderer, rNode, tNode.styles);
13524
+ }
13525
+ }
13526
+ }
13527
+ const viewRenderer = rendererFactory.createRenderer(rNode, def);
13528
+ const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13529
+ if (tView.firstCreatePass) {
13530
+ diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
13531
+ markAsComponentHost(tView, tNode);
13532
+ initTNodeFlags(tNode, rootView.length, 1);
13533
+ }
13534
+ addToViewTree(rootView, componentView);
13535
+ // Store component view at node index, with node as the HOST
13536
+ return rootView[index] = componentView;
13629
13537
  }
13630
13538
  /**
13631
- * Marks the component as dirty (needing change detection). Marking a component dirty will
13632
- * schedule a change detection on it at some point in the future.
13633
- *
13634
- * Marking an already dirty component as dirty won't do anything. Only one outstanding change
13635
- * detection can be scheduled per component tree.
13636
- *
13637
- * @param component Component to mark as dirty.
13539
+ * Creates a root component and sets it up with features and host bindings. Shared by
13540
+ * renderComponent() and ViewContainerRef.createComponent().
13638
13541
  */
13639
- function markDirty(component) {
13640
- ngDevMode && assertDefined(component, 'component');
13641
- const rootView = markViewDirty(getComponentViewByInstance(component));
13642
- ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
13643
- scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
13644
- }
13542
+ function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
13543
+ const tView = rootLView[TVIEW];
13544
+ // Create directive instance with factory() and store at next index in viewData
13545
+ const component = instantiateRootComponent(tView, rootLView, componentDef);
13546
+ rootContext.components.push(component);
13547
+ componentView[CONTEXT] = component;
13548
+ if (hostFeatures !== null) {
13549
+ for (const feature of hostFeatures) {
13550
+ feature(component, componentDef);
13551
+ }
13552
+ }
13553
+ // We want to generate an empty QueryList for root content queries for backwards
13554
+ // compatibility with ViewEngine.
13555
+ if (componentDef.contentQueries) {
13556
+ const tNode = getCurrentTNode();
13557
+ ngDevMode && assertDefined(tNode, 'TNode expected');
13558
+ componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
13559
+ }
13560
+ const rootTNode = getCurrentTNode();
13561
+ ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
13562
+ if (tView.firstCreatePass &&
13563
+ (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
13564
+ setSelectedIndex(rootTNode.index);
13565
+ const rootTView = rootLView[TVIEW];
13566
+ registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
13567
+ invokeHostBindingsInCreationMode(componentDef, component);
13568
+ }
13569
+ return component;
13570
+ }
13571
+ function createRootContext(scheduler, playerHandler) {
13572
+ return {
13573
+ components: [],
13574
+ scheduler: scheduler || defaultScheduler,
13575
+ clean: CLEAN_PROMISE,
13576
+ playerHandler: playerHandler || null,
13577
+ flags: 0 /* RootContextFlags.Empty */
13578
+ };
13579
+ }
13645
13580
  /**
13646
- * Used to perform change detection on the whole application.
13581
+ * Used to enable lifecycle hooks on the root component.
13647
13582
  *
13648
- * This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
13649
- * executes lifecycle hooks and conditionally checks components based on their
13650
- * `ChangeDetectionStrategy` and dirtiness.
13583
+ * Include this feature when calling `renderComponent` if the root component
13584
+ * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
13585
+ * be called properly.
13651
13586
  *
13652
- * The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
13653
- * schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
13654
- * single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
13655
- * be changed when calling `renderComponent` and providing the `scheduler` option.
13587
+ * Example:
13588
+ *
13589
+ * ```
13590
+ * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
13591
+ * ```
13656
13592
  */
13657
- function tick(component) {
13658
- const rootView = getRootView(component);
13659
- const rootContext = rootView[CONTEXT];
13660
- tickRootContext(rootContext);
13593
+ function LifecycleHooksFeature() {
13594
+ const tNode = getCurrentTNode();
13595
+ ngDevMode && assertDefined(tNode, 'TNode is required');
13596
+ registerPostOrderHooks(getLView()[TVIEW], tNode);
13597
+ }
13598
+ /**
13599
+ * Wait on component until it is rendered.
13600
+ *
13601
+ * This function returns a `Promise` which is resolved when the component's
13602
+ * change detection is executed. This is determined by finding the scheduler
13603
+ * associated with the `component`'s render tree and waiting until the scheduler
13604
+ * flushes. If nothing is scheduled, the function returns a resolved promise.
13605
+ *
13606
+ * Example:
13607
+ * ```
13608
+ * await whenRendered(myComponent);
13609
+ * ```
13610
+ *
13611
+ * @param component Component to wait upon
13612
+ * @returns Promise which resolves when the component is rendered.
13613
+ */
13614
+ function whenRendered(component) {
13615
+ return getRootContext(component).clean;
13661
13616
  }
13662
13617
 
13663
13618
  /**
@@ -13667,407 +13622,312 @@ function tick(component) {
13667
13622
  * Use of this source code is governed by an MIT-style license that can be
13668
13623
  * found in the LICENSE file at https://angular.io/license
13669
13624
  */
13625
+ function getSuperType(type) {
13626
+ return Object.getPrototypeOf(type.prototype).constructor;
13627
+ }
13670
13628
  /**
13671
- * Retrieves the component instance associated with a given DOM element.
13672
- *
13673
- * @usageNotes
13674
- * Given the following DOM structure:
13675
- *
13676
- * ```html
13677
- * <app-root>
13678
- * <div>
13679
- * <child-comp></child-comp>
13680
- * </div>
13681
- * </app-root>
13682
- * ```
13683
- *
13684
- * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
13685
- * associated with this DOM element.
13686
- *
13687
- * Calling the function on `<app-root>` will return the `MyApp` instance.
13688
- *
13689
- *
13690
- * @param element DOM element from which the component should be retrieved.
13691
- * @returns Component instance associated with the element or `null` if there
13692
- * is no component associated with it.
13629
+ * Merges the definition from a super class to a sub class.
13630
+ * @param definition The definition that is a SubClass of another directive of component
13693
13631
  *
13694
- * @publicApi
13695
- * @globalApi ng
13632
+ * @codeGenApi
13696
13633
  */
13697
- function getComponent$1(element) {
13698
- ngDevMode && assertDomElement(element);
13699
- const context = getLContext(element);
13700
- if (context === null)
13701
- return null;
13702
- if (context.component === undefined) {
13703
- const lView = context.lView;
13704
- if (lView === null) {
13705
- return null;
13634
+ function ɵɵInheritDefinitionFeature(definition) {
13635
+ let superType = getSuperType(definition.type);
13636
+ let shouldInheritFields = true;
13637
+ const inheritanceChain = [definition];
13638
+ while (superType) {
13639
+ let superDef = undefined;
13640
+ if (isComponentDef(definition)) {
13641
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13642
+ superDef = superType.ɵcmp || superType.ɵdir;
13706
13643
  }
13707
- context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
13644
+ else {
13645
+ if (superType.ɵcmp) {
13646
+ throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
13647
+ `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
13648
+ }
13649
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13650
+ superDef = superType.ɵdir;
13651
+ }
13652
+ if (superDef) {
13653
+ if (shouldInheritFields) {
13654
+ inheritanceChain.push(superDef);
13655
+ // Some fields in the definition may be empty, if there were no values to put in them that
13656
+ // would've justified object creation. Unwrap them if necessary.
13657
+ const writeableDef = definition;
13658
+ writeableDef.inputs = maybeUnwrapEmpty(definition.inputs);
13659
+ writeableDef.declaredInputs = maybeUnwrapEmpty(definition.declaredInputs);
13660
+ writeableDef.outputs = maybeUnwrapEmpty(definition.outputs);
13661
+ // Merge hostBindings
13662
+ const superHostBindings = superDef.hostBindings;
13663
+ superHostBindings && inheritHostBindings(definition, superHostBindings);
13664
+ // Merge queries
13665
+ const superViewQuery = superDef.viewQuery;
13666
+ const superContentQueries = superDef.contentQueries;
13667
+ superViewQuery && inheritViewQuery(definition, superViewQuery);
13668
+ superContentQueries && inheritContentQueries(definition, superContentQueries);
13669
+ // Merge inputs and outputs
13670
+ fillProperties(definition.inputs, superDef.inputs);
13671
+ fillProperties(definition.declaredInputs, superDef.declaredInputs);
13672
+ fillProperties(definition.outputs, superDef.outputs);
13673
+ // Merge animations metadata.
13674
+ // If `superDef` is a Component, the `data` field is present (defaults to an empty object).
13675
+ if (isComponentDef(superDef) && superDef.data.animation) {
13676
+ // If super def is a Component, the `definition` is also a Component, since Directives can
13677
+ // not inherit Components (we throw an error above and cannot reach this code).
13678
+ const defData = definition.data;
13679
+ defData.animation = (defData.animation || []).concat(superDef.data.animation);
13680
+ }
13681
+ }
13682
+ // Run parent features
13683
+ const features = superDef.features;
13684
+ if (features) {
13685
+ for (let i = 0; i < features.length; i++) {
13686
+ const feature = features[i];
13687
+ if (feature && feature.ngInherit) {
13688
+ feature(definition);
13689
+ }
13690
+ // If `InheritDefinitionFeature` is a part of the current `superDef`, it means that this
13691
+ // def already has all the necessary information inherited from its super class(es), so we
13692
+ // can stop merging fields from super classes. However we need to iterate through the
13693
+ // prototype chain to look for classes that might contain other "features" (like
13694
+ // NgOnChanges), which we should invoke for the original `definition`. We set the
13695
+ // `shouldInheritFields` flag to indicate that, essentially skipping fields inheritance
13696
+ // logic and only invoking functions from the "features" list.
13697
+ if (feature === ɵɵInheritDefinitionFeature) {
13698
+ shouldInheritFields = false;
13699
+ }
13700
+ }
13701
+ }
13702
+ }
13703
+ superType = Object.getPrototypeOf(superType);
13708
13704
  }
13709
- return context.component;
13705
+ mergeHostAttrsAcrossInheritance(inheritanceChain);
13710
13706
  }
13711
13707
  /**
13712
- * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
13713
- * view that the element is part of. Otherwise retrieves the instance of the component whose view
13714
- * owns the element (in this case, the result is the same as calling `getOwningComponent`).
13715
- *
13716
- * @param element Element for which to get the surrounding component instance.
13717
- * @returns Instance of the component that is around the element or null if the element isn't
13718
- * inside any component.
13708
+ * Merge the `hostAttrs` and `hostVars` from the inherited parent to the base class.
13719
13709
  *
13720
- * @publicApi
13721
- * @globalApi ng
13710
+ * @param inheritanceChain A list of `WritableDefs` starting at the top most type and listing
13711
+ * sub-types in order. For each type take the `hostAttrs` and `hostVars` and merge it with the child
13712
+ * type.
13722
13713
  */
13723
- function getContext(element) {
13724
- assertDomElement(element);
13725
- const context = getLContext(element);
13726
- const lView = context ? context.lView : null;
13727
- return lView === null ? null : lView[CONTEXT];
13714
+ function mergeHostAttrsAcrossInheritance(inheritanceChain) {
13715
+ let hostVars = 0;
13716
+ let hostAttrs = null;
13717
+ // We process the inheritance order from the base to the leaves here.
13718
+ for (let i = inheritanceChain.length - 1; i >= 0; i--) {
13719
+ const def = inheritanceChain[i];
13720
+ // For each `hostVars`, we need to add the superclass amount.
13721
+ def.hostVars = (hostVars += def.hostVars);
13722
+ // for each `hostAttrs` we need to merge it with superclass.
13723
+ def.hostAttrs =
13724
+ mergeHostAttrs(def.hostAttrs, hostAttrs = mergeHostAttrs(hostAttrs, def.hostAttrs));
13725
+ }
13728
13726
  }
13729
- /**
13730
- * Retrieves the component instance whose view contains the DOM element.
13731
- *
13732
- * For example, if `<child-comp>` is used in the template of `<app-comp>`
13733
- * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
13734
- * would return `<app-comp>`.
13735
- *
13736
- * @param elementOrDir DOM element, component or directive instance
13737
- * for which to retrieve the root components.
13738
- * @returns Component instance whose view owns the DOM element or null if the element is not
13739
- * part of a component view.
13740
- *
13741
- * @publicApi
13742
- * @globalApi ng
13743
- */
13744
- function getOwningComponent(elementOrDir) {
13745
- const context = getLContext(elementOrDir);
13746
- let lView = context ? context.lView : null;
13747
- if (lView === null)
13748
- return null;
13749
- let parent;
13750
- while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
13751
- lView = parent;
13727
+ function maybeUnwrapEmpty(value) {
13728
+ if (value === EMPTY_OBJ) {
13729
+ return {};
13730
+ }
13731
+ else if (value === EMPTY_ARRAY) {
13732
+ return [];
13733
+ }
13734
+ else {
13735
+ return value;
13752
13736
  }
13753
- return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
13754
13737
  }
13755
- /**
13756
- * Retrieves all root components associated with a DOM element, directive or component instance.
13757
- * Root components are those which have been bootstrapped by Angular.
13758
- *
13759
- * @param elementOrDir DOM element, component or directive instance
13760
- * for which to retrieve the root components.
13761
- * @returns Root components associated with the target object.
13762
- *
13763
- * @publicApi
13764
- * @globalApi ng
13765
- */
13766
- function getRootComponents(elementOrDir) {
13767
- const lView = readPatchedLView(elementOrDir);
13768
- return lView !== null ? [...getRootContext(lView).components] : [];
13738
+ function inheritViewQuery(definition, superViewQuery) {
13739
+ const prevViewQuery = definition.viewQuery;
13740
+ if (prevViewQuery) {
13741
+ definition.viewQuery = (rf, ctx) => {
13742
+ superViewQuery(rf, ctx);
13743
+ prevViewQuery(rf, ctx);
13744
+ };
13745
+ }
13746
+ else {
13747
+ definition.viewQuery = superViewQuery;
13748
+ }
13749
+ }
13750
+ function inheritContentQueries(definition, superContentQueries) {
13751
+ const prevContentQueries = definition.contentQueries;
13752
+ if (prevContentQueries) {
13753
+ definition.contentQueries = (rf, ctx, directiveIndex) => {
13754
+ superContentQueries(rf, ctx, directiveIndex);
13755
+ prevContentQueries(rf, ctx, directiveIndex);
13756
+ };
13757
+ }
13758
+ else {
13759
+ definition.contentQueries = superContentQueries;
13760
+ }
13761
+ }
13762
+ function inheritHostBindings(definition, superHostBindings) {
13763
+ const prevHostBindings = definition.hostBindings;
13764
+ if (prevHostBindings) {
13765
+ definition.hostBindings = (rf, ctx) => {
13766
+ superHostBindings(rf, ctx);
13767
+ prevHostBindings(rf, ctx);
13768
+ };
13769
+ }
13770
+ else {
13771
+ definition.hostBindings = superHostBindings;
13772
+ }
13769
13773
  }
13774
+
13770
13775
  /**
13771
- * Retrieves an `Injector` associated with an element, component or directive instance.
13772
- *
13773
- * @param elementOrDir DOM element, component or directive instance for which to
13774
- * retrieve the injector.
13775
- * @returns Injector associated with the element, component or directive instance.
13776
+ * @license
13777
+ * Copyright Google LLC All Rights Reserved.
13776
13778
  *
13777
- * @publicApi
13778
- * @globalApi ng
13779
+ * Use of this source code is governed by an MIT-style license that can be
13780
+ * found in the LICENSE file at https://angular.io/license
13779
13781
  */
13780
- function getInjector(elementOrDir) {
13781
- const context = getLContext(elementOrDir);
13782
- const lView = context ? context.lView : null;
13783
- if (lView === null)
13784
- return Injector.NULL;
13785
- const tNode = lView[TVIEW].data[context.nodeIndex];
13786
- return new NodeInjector(tNode, lView);
13787
- }
13788
13782
  /**
13789
- * Retrieve a set of injection tokens at a given DOM node.
13790
- *
13791
- * @param element Element for which the injection tokens should be retrieved.
13783
+ * Fields which exist on either directive or component definitions, and need to be copied from
13784
+ * parent to child classes by the `ɵɵCopyDefinitionFeature`.
13792
13785
  */
13793
- function getInjectionTokens(element) {
13794
- const context = getLContext(element);
13795
- const lView = context ? context.lView : null;
13796
- if (lView === null)
13797
- return [];
13798
- const tView = lView[TVIEW];
13799
- const tNode = tView.data[context.nodeIndex];
13800
- const providerTokens = [];
13801
- const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
13802
- const endIndex = tNode.directiveEnd;
13803
- for (let i = startIndex; i < endIndex; i++) {
13804
- let value = tView.data[i];
13805
- if (isDirectiveDefHack(value)) {
13806
- // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
13807
- // design flaw. We should always store same type so that we can be monomorphic. The issue
13808
- // is that for Components/Directives we store the def instead the type. The correct behavior
13809
- // is that we should always be storing injectable type in this location.
13810
- value = value.type;
13811
- }
13812
- providerTokens.push(value);
13813
- }
13814
- return providerTokens;
13815
- }
13786
+ const COPY_DIRECTIVE_FIELDS = [
13787
+ // The child class should use the providers of its parent.
13788
+ 'providersResolver',
13789
+ // Not listed here are any fields which are handled by the `ɵɵInheritDefinitionFeature`, such
13790
+ // as inputs, outputs, and host binding functions.
13791
+ ];
13816
13792
  /**
13817
- * Retrieves directive instances associated with a given DOM node. Does not include
13818
- * component instances.
13819
- *
13820
- * @usageNotes
13821
- * Given the following DOM structure:
13793
+ * Fields which exist only on component definitions, and need to be copied from parent to child
13794
+ * classes by the `ɵɵCopyDefinitionFeature`.
13822
13795
  *
13823
- * ```html
13824
- * <app-root>
13825
- * <button my-button></button>
13826
- * <my-comp></my-comp>
13827
- * </app-root>
13828
- * ```
13796
+ * The type here allows any field of `ComponentDef` which is not also a property of `DirectiveDef`,
13797
+ * since those should go in `COPY_DIRECTIVE_FIELDS` above.
13798
+ */
13799
+ const COPY_COMPONENT_FIELDS = [
13800
+ // The child class should use the template function of its parent, including all template
13801
+ // semantics.
13802
+ 'template',
13803
+ 'decls',
13804
+ 'consts',
13805
+ 'vars',
13806
+ 'onPush',
13807
+ 'ngContentSelectors',
13808
+ // The child class should use the CSS styles of its parent, including all styling semantics.
13809
+ 'styles',
13810
+ 'encapsulation',
13811
+ // The child class should be checked by the runtime in the same way as its parent.
13812
+ 'schemas',
13813
+ ];
13814
+ /**
13815
+ * Copies the fields not handled by the `ɵɵInheritDefinitionFeature` from the supertype of a
13816
+ * definition.
13829
13817
  *
13830
- * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
13831
- * directive that is associated with the DOM node.
13818
+ * This exists primarily to support ngcc migration of an existing View Engine pattern, where an
13819
+ * entire decorator is inherited from a parent to a child class. When ngcc detects this case, it
13820
+ * generates a skeleton definition on the child class, and applies this feature.
13832
13821
  *
13833
- * Calling `getDirectives` on `<my-comp>` will return an empty array.
13822
+ * The `ɵɵCopyDefinitionFeature` then copies any needed fields from the parent class' definition,
13823
+ * including things like the component template function.
13834
13824
  *
13835
- * @param node DOM node for which to get the directives.
13836
- * @returns Array of directives associated with the node.
13825
+ * @param definition The definition of a child class which inherits from a parent class with its
13826
+ * own definition.
13837
13827
  *
13838
- * @publicApi
13839
- * @globalApi ng
13828
+ * @codeGenApi
13840
13829
  */
13841
- function getDirectives(node) {
13842
- // Skip text nodes because we can't have directives associated with them.
13843
- if (node instanceof Text) {
13844
- return [];
13830
+ function ɵɵCopyDefinitionFeature(definition) {
13831
+ let superType = getSuperType(definition.type);
13832
+ let superDef = undefined;
13833
+ if (isComponentDef(definition)) {
13834
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13835
+ superDef = superType.ɵcmp;
13845
13836
  }
13846
- const context = getLContext(node);
13847
- const lView = context ? context.lView : null;
13848
- if (lView === null) {
13849
- return [];
13837
+ else {
13838
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13839
+ superDef = superType.ɵdir;
13850
13840
  }
13851
- const tView = lView[TVIEW];
13852
- const nodeIndex = context.nodeIndex;
13853
- if (!tView?.data[nodeIndex]) {
13854
- return [];
13841
+ // Needed because `definition` fields are readonly.
13842
+ const defAny = definition;
13843
+ // Copy over any fields that apply to either directives or components.
13844
+ for (const field of COPY_DIRECTIVE_FIELDS) {
13845
+ defAny[field] = superDef[field];
13855
13846
  }
13856
- if (context.directives === undefined) {
13857
- context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
13847
+ if (isComponentDef(superDef)) {
13848
+ // Copy over any component-specific fields.
13849
+ for (const field of COPY_COMPONENT_FIELDS) {
13850
+ defAny[field] = superDef[field];
13851
+ }
13858
13852
  }
13859
- // The `directives` in this case are a named array called `LComponentView`. Clone the
13860
- // result so we don't expose an internal data structure in the user's console.
13861
- return context.directives === null ? [] : [...context.directives];
13862
13853
  }
13854
+
13863
13855
  /**
13864
- * Returns the debug (partial) metadata for a particular directive or component instance.
13865
- * The function accepts an instance of a directive or component and returns the corresponding
13866
- * metadata.
13867
- *
13868
- * @param directiveOrComponentInstance Instance of a directive or component
13869
- * @returns metadata of the passed directive or component
13856
+ * @license
13857
+ * Copyright Google LLC All Rights Reserved.
13870
13858
  *
13871
- * @publicApi
13872
- * @globalApi ng
13859
+ * Use of this source code is governed by an MIT-style license that can be
13860
+ * found in the LICENSE file at https://angular.io/license
13873
13861
  */
13874
- function getDirectiveMetadata(directiveOrComponentInstance) {
13875
- const { constructor } = directiveOrComponentInstance;
13876
- if (!constructor) {
13877
- throw new Error('Unable to find the instance constructor');
13878
- }
13879
- // In case a component inherits from a directive, we may have component and directive metadata
13880
- // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
13881
- const componentDef = getComponentDef$1(constructor);
13882
- if (componentDef) {
13883
- return {
13884
- inputs: componentDef.inputs,
13885
- outputs: componentDef.outputs,
13886
- encapsulation: componentDef.encapsulation,
13887
- changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
13888
- ChangeDetectionStrategy.Default
13889
- };
13890
- }
13891
- const directiveDef = getDirectiveDef(constructor);
13892
- if (directiveDef) {
13893
- return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
13862
+ let _symbolIterator = null;
13863
+ function getSymbolIterator() {
13864
+ if (!_symbolIterator) {
13865
+ const Symbol = _global$1['Symbol'];
13866
+ if (Symbol && Symbol.iterator) {
13867
+ _symbolIterator = Symbol.iterator;
13868
+ }
13869
+ else {
13870
+ // es6-shim specific logic
13871
+ const keys = Object.getOwnPropertyNames(Map.prototype);
13872
+ for (let i = 0; i < keys.length; ++i) {
13873
+ const key = keys[i];
13874
+ if (key !== 'entries' && key !== 'size' &&
13875
+ Map.prototype[key] === Map.prototype['entries']) {
13876
+ _symbolIterator = key;
13877
+ }
13878
+ }
13879
+ }
13894
13880
  }
13895
- return null;
13881
+ return _symbolIterator;
13896
13882
  }
13883
+
13897
13884
  /**
13898
- * Retrieve map of local references.
13899
- *
13900
- * The references are retrieved as a map of local reference name to element or directive instance.
13885
+ * @license
13886
+ * Copyright Google LLC All Rights Reserved.
13901
13887
  *
13902
- * @param target DOM element, component or directive instance for which to retrieve
13903
- * the local references.
13888
+ * Use of this source code is governed by an MIT-style license that can be
13889
+ * found in the LICENSE file at https://angular.io/license
13904
13890
  */
13905
- function getLocalRefs(target) {
13906
- const context = getLContext(target);
13907
- if (context === null)
13908
- return {};
13909
- if (context.localRefs === undefined) {
13910
- const lView = context.lView;
13911
- if (lView === null) {
13912
- return {};
13913
- }
13914
- context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
13915
- }
13916
- return context.localRefs || {};
13917
- }
13918
- /**
13919
- * Retrieves the host element of a component or directive instance.
13920
- * The host element is the DOM element that matched the selector of the directive.
13921
- *
13922
- * @param componentOrDirective Component or directive instance for which the host
13923
- * element should be retrieved.
13924
- * @returns Host element of the target.
13925
- *
13926
- * @publicApi
13927
- * @globalApi ng
13928
- */
13929
- function getHostElement(componentOrDirective) {
13930
- return getLContext(componentOrDirective).native;
13891
+ function isIterable(obj) {
13892
+ return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
13931
13893
  }
13932
- /**
13933
- * Retrieves the rendered text for a given component.
13934
- *
13935
- * This function retrieves the host element of a component and
13936
- * and then returns the `textContent` for that element. This implies
13937
- * that the text returned will include re-projected content of
13938
- * the component as well.
13939
- *
13940
- * @param component The component to return the content text for.
13941
- */
13942
- function getRenderedText(component) {
13943
- const hostElement = getHostElement(component);
13944
- return hostElement.textContent || '';
13894
+ function isListLikeIterable(obj) {
13895
+ if (!isJsObject(obj))
13896
+ return false;
13897
+ return Array.isArray(obj) ||
13898
+ (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
13899
+ getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
13945
13900
  }
13946
- /**
13947
- * Retrieves a list of event listeners associated with a DOM element. The list does include host
13948
- * listeners, but it does not include event listeners defined outside of the Angular context
13949
- * (e.g. through `addEventListener`).
13950
- *
13951
- * @usageNotes
13952
- * Given the following DOM structure:
13953
- *
13954
- * ```html
13955
- * <app-root>
13956
- * <div (click)="doSomething()"></div>
13957
- * </app-root>
13958
- * ```
13959
- *
13960
- * Calling `getListeners` on `<div>` will return an object that looks as follows:
13961
- *
13962
- * ```ts
13963
- * {
13964
- * name: 'click',
13965
- * element: <div>,
13966
- * callback: () => doSomething(),
13967
- * useCapture: false
13968
- * }
13969
- * ```
13970
- *
13971
- * @param element Element for which the DOM listeners should be retrieved.
13972
- * @returns Array of event listeners on the DOM element.
13973
- *
13974
- * @publicApi
13975
- * @globalApi ng
13976
- */
13977
- function getListeners(element) {
13978
- ngDevMode && assertDomElement(element);
13979
- const lContext = getLContext(element);
13980
- const lView = lContext === null ? null : lContext.lView;
13981
- if (lView === null)
13982
- return [];
13983
- const tView = lView[TVIEW];
13984
- const lCleanup = lView[CLEANUP];
13985
- const tCleanup = tView.cleanup;
13986
- const listeners = [];
13987
- if (tCleanup && lCleanup) {
13988
- for (let i = 0; i < tCleanup.length;) {
13989
- const firstParam = tCleanup[i++];
13990
- const secondParam = tCleanup[i++];
13991
- if (typeof firstParam === 'string') {
13992
- const name = firstParam;
13993
- const listenerElement = unwrapRNode(lView[secondParam]);
13994
- const callback = lCleanup[tCleanup[i++]];
13995
- const useCaptureOrIndx = tCleanup[i++];
13996
- // if useCaptureOrIndx is boolean then report it as is.
13997
- // if useCaptureOrIndx is positive number then it in unsubscribe method
13998
- // if useCaptureOrIndx is negative number then it is a Subscription
13999
- const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
14000
- const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
14001
- if (element == listenerElement) {
14002
- listeners.push({ element, name, callback, useCapture, type });
14003
- }
14004
- }
14005
- }
13901
+ function areIterablesEqual(a, b, comparator) {
13902
+ const iterator1 = a[getSymbolIterator()]();
13903
+ const iterator2 = b[getSymbolIterator()]();
13904
+ while (true) {
13905
+ const item1 = iterator1.next();
13906
+ const item2 = iterator2.next();
13907
+ if (item1.done && item2.done)
13908
+ return true;
13909
+ if (item1.done || item2.done)
13910
+ return false;
13911
+ if (!comparator(item1.value, item2.value))
13912
+ return false;
14006
13913
  }
14007
- listeners.sort(sortListeners);
14008
- return listeners;
14009
- }
14010
- function sortListeners(a, b) {
14011
- if (a.name == b.name)
14012
- return 0;
14013
- return a.name < b.name ? -1 : 1;
14014
- }
14015
- /**
14016
- * This function should not exist because it is megamorphic and only mostly correct.
14017
- *
14018
- * See call site for more info.
14019
- */
14020
- function isDirectiveDefHack(obj) {
14021
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
14022
13914
  }
14023
- /**
14024
- * Returns the attached `DebugNode` instance for an element in the DOM.
14025
- *
14026
- * @param element DOM element which is owned by an existing component's view.
14027
- */
14028
- function getDebugNode(element) {
14029
- if (ngDevMode && !(element instanceof Node)) {
14030
- throw new Error('Expecting instance of DOM Element');
14031
- }
14032
- const lContext = getLContext(element);
14033
- const lView = lContext ? lContext.lView : null;
14034
- if (lView === null) {
14035
- return null;
13915
+ function iterateListLike(obj, fn) {
13916
+ if (Array.isArray(obj)) {
13917
+ for (let i = 0; i < obj.length; i++) {
13918
+ fn(obj[i]);
13919
+ }
14036
13920
  }
14037
- const nodeIndex = lContext.nodeIndex;
14038
- if (nodeIndex !== -1) {
14039
- const valueInLView = lView[nodeIndex];
14040
- // this means that value in the lView is a component with its own
14041
- // data. In this situation the TNode is not accessed at the same spot.
14042
- const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
14043
- ngDevMode &&
14044
- assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
14045
- return buildDebugNode(tNode, lView);
13921
+ else {
13922
+ const iterator = obj[getSymbolIterator()]();
13923
+ let item;
13924
+ while (!((item = iterator.next()).done)) {
13925
+ fn(item.value);
13926
+ }
14046
13927
  }
14047
- return null;
14048
- }
14049
- /**
14050
- * Retrieve the component `LView` from component/element.
14051
- *
14052
- * NOTE: `LView` is a private and should not be leaked outside.
14053
- * Don't export this method to `ng.*` on window.
14054
- *
14055
- * @param target DOM element or component instance for which to retrieve the LView.
14056
- */
14057
- function getComponentLView(target) {
14058
- const lContext = getLContext(target);
14059
- const nodeIndx = lContext.nodeIndex;
14060
- const lView = lContext.lView;
14061
- ngDevMode && assertLView(lView);
14062
- const componentLView = lView[nodeIndx];
14063
- ngDevMode && assertLView(componentLView);
14064
- return componentLView;
14065
13928
  }
14066
- /** Asserts that a value is a DOM Element. */
14067
- function assertDomElement(value) {
14068
- if (typeof Element !== 'undefined' && !(value instanceof Element)) {
14069
- throw new Error('Expecting instance of DOM Element');
14070
- }
13929
+ function isJsObject(o) {
13930
+ return o !== null && (typeof o === 'function' || typeof o === 'object');
14071
13931
  }
14072
13932
 
14073
13933
  /**
@@ -14077,18 +13937,22 @@ function assertDomElement(value) {
14077
13937
  * Use of this source code is governed by an MIT-style license that can be
14078
13938
  * found in the LICENSE file at https://angular.io/license
14079
13939
  */
14080
- /**
14081
- * Marks a component for check (in case of OnPush components) and synchronously
14082
- * performs change detection on the application this component belongs to.
14083
- *
14084
- * @param component Component to {@link ChangeDetectorRef#markForCheck mark for check}.
14085
- *
14086
- * @publicApi
14087
- * @globalApi ng
14088
- */
14089
- function applyChanges(component) {
14090
- markDirty(component);
14091
- getRootComponents(component).forEach(rootComponent => detectChanges(rootComponent));
13940
+ function devModeEqual(a, b) {
13941
+ const isListLikeIterableA = isListLikeIterable(a);
13942
+ const isListLikeIterableB = isListLikeIterable(b);
13943
+ if (isListLikeIterableA && isListLikeIterableB) {
13944
+ return areIterablesEqual(a, b, devModeEqual);
13945
+ }
13946
+ else {
13947
+ const isAObject = a && (typeof a === 'object' || typeof a === 'function');
13948
+ const isBObject = b && (typeof b === 'object' || typeof b === 'function');
13949
+ if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
13950
+ return true;
13951
+ }
13952
+ else {
13953
+ return Object.is(a, b);
13954
+ }
13955
+ }
14092
13956
  }
14093
13957
 
14094
13958
  /**
@@ -14098,70 +13962,73 @@ function applyChanges(component) {
14098
13962
  * Use of this source code is governed by an MIT-style license that can be
14099
13963
  * found in the LICENSE file at https://angular.io/license
14100
13964
  */
13965
+ // TODO(misko): consider inlining
13966
+ /** Updates binding and returns the value. */
13967
+ function updateBinding(lView, bindingIndex, value) {
13968
+ return lView[bindingIndex] = value;
13969
+ }
13970
+ /** Gets the current binding value. */
13971
+ function getBinding(lView, bindingIndex) {
13972
+ ngDevMode && assertIndexInRange(lView, bindingIndex);
13973
+ ngDevMode &&
13974
+ assertNotSame(lView[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
13975
+ return lView[bindingIndex];
13976
+ }
14101
13977
  /**
14102
- * This file introduces series of globally accessible debug tools
14103
- * to allow for the Angular debugging story to function.
14104
- *
14105
- * To see this in action run the following command:
14106
- *
14107
- * bazel run //packages/core/test/bundling/todo:devserver
13978
+ * Updates binding if changed, then returns whether it was updated.
14108
13979
  *
14109
- * Then load `localhost:5432` and start using the console tools.
14110
- */
14111
- /**
14112
- * This value reflects the property on the window where the dev
14113
- * tools are patched (window.ng).
14114
- * */
14115
- const GLOBAL_PUBLISH_EXPANDO_KEY = 'ng';
14116
- let _published = false;
14117
- /**
14118
- * Publishes a collection of default debug tools onto`window.ng`.
13980
+ * This function also checks the `CheckNoChangesMode` and throws if changes are made.
13981
+ * Some changes (Objects/iterables) during `CheckNoChangesMode` are exempt to comply with VE
13982
+ * behavior.
14119
13983
  *
14120
- * These functions are available globally when Angular is in development
14121
- * mode and are automatically stripped away from prod mode is on.
13984
+ * @param lView current `LView`
13985
+ * @param bindingIndex The binding in the `LView` to check
13986
+ * @param value New value to check against `lView[bindingIndex]`
13987
+ * @returns `true` if the bindings has changed. (Throws if binding has changed during
13988
+ * `CheckNoChangesMode`)
14122
13989
  */
14123
- function publishDefaultGlobalUtils() {
14124
- if (!_published) {
14125
- _published = true;
14126
- /**
14127
- * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
14128
- * The contract of the function might be changed in any release and/or the function can be
14129
- * removed completely.
14130
- */
14131
- publishGlobalUtil('ɵsetProfiler', setProfiler);
14132
- publishGlobalUtil('getDirectiveMetadata', getDirectiveMetadata);
14133
- publishGlobalUtil('getComponent', getComponent$1);
14134
- publishGlobalUtil('getContext', getContext);
14135
- publishGlobalUtil('getListeners', getListeners);
14136
- publishGlobalUtil('getOwningComponent', getOwningComponent);
14137
- publishGlobalUtil('getHostElement', getHostElement);
14138
- publishGlobalUtil('getInjector', getInjector);
14139
- publishGlobalUtil('getRootComponents', getRootComponents);
14140
- publishGlobalUtil('getDirectives', getDirectives);
14141
- publishGlobalUtil('applyChanges', applyChanges);
13990
+ function bindingUpdated(lView, bindingIndex, value) {
13991
+ ngDevMode && assertNotSame(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
13992
+ ngDevMode &&
13993
+ assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
13994
+ const oldValue = lView[bindingIndex];
13995
+ if (Object.is(oldValue, value)) {
13996
+ return false;
14142
13997
  }
14143
- }
14144
- /**
14145
- * Publishes the given function to `window.ng` so that it can be
14146
- * used from the browser console when an application is not in production.
14147
- */
14148
- function publishGlobalUtil(name, fn) {
14149
- if (typeof COMPILED === 'undefined' || !COMPILED) {
14150
- // Note: we can't export `ng` when using closure enhanced optimization as:
14151
- // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
14152
- // - we can't declare a closure extern as the namespace `ng` is already used within Google
14153
- // for typings for AngularJS (via `goog.provide('ng....')`).
14154
- const w = _global$1;
14155
- ngDevMode && assertDefined(fn, 'function not defined');
14156
- if (w) {
14157
- let container = w[GLOBAL_PUBLISH_EXPANDO_KEY];
14158
- if (!container) {
14159
- container = w[GLOBAL_PUBLISH_EXPANDO_KEY] = {};
13998
+ else {
13999
+ if (ngDevMode && isInCheckNoChangesMode()) {
14000
+ // View engine didn't report undefined values as changed on the first checkNoChanges pass
14001
+ // (before the change detection was run).
14002
+ const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined;
14003
+ if (!devModeEqual(oldValueToCompare, value)) {
14004
+ const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
14005
+ throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName);
14160
14006
  }
14161
- container[name] = fn;
14162
- }
14007
+ // There was a change, but the `devModeEqual` decided that the change is exempt from an error.
14008
+ // For this reason we exit as if no change. The early exit is needed to prevent the changed
14009
+ // value to be written into `LView` (If we would write the new value that we would not see it
14010
+ // as change on next CD.)
14011
+ return false;
14012
+ }
14013
+ lView[bindingIndex] = value;
14014
+ return true;
14163
14015
  }
14164
14016
  }
14017
+ /** Updates 2 bindings if changed, then returns whether either was updated. */
14018
+ function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
14019
+ const different = bindingUpdated(lView, bindingIndex, exp1);
14020
+ return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
14021
+ }
14022
+ /** Updates 3 bindings if changed, then returns whether any was updated. */
14023
+ function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
14024
+ const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14025
+ return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
14026
+ }
14027
+ /** Updates 4 bindings if changed, then returns whether any was updated. */
14028
+ function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
14029
+ const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14030
+ return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
14031
+ }
14165
14032
 
14166
14033
  /**
14167
14034
  * @license
@@ -14170,885 +14037,281 @@ function publishGlobalUtil(name, fn) {
14170
14037
  * Use of this source code is governed by an MIT-style license that can be
14171
14038
  * found in the LICENSE file at https://angular.io/license
14172
14039
  */
14173
- // TODO: A hack to not pull in the NullInjector from @angular/core.
14174
- const NULL_INJECTOR = {
14175
- get: (token, notFoundValue) => {
14176
- throwProviderNotFoundError(token, 'NullInjector');
14177
- }
14178
- };
14179
14040
  /**
14180
- * Bootstraps a Component into an existing host element and returns an instance
14181
- * of the component.
14182
- *
14183
- * Use this function to bootstrap a component into the DOM tree. Each invocation
14184
- * of this function will create a separate tree of components, injectors and
14185
- * change detection cycles and lifetimes. To dynamically insert a new component
14186
- * into an existing tree such that it shares the same injection, change detection
14187
- * and object lifetime, use {@link ViewContainer#createComponent}.
14188
- *
14189
- * @param componentType Component to bootstrap
14190
- * @param options Optional parameters which control bootstrapping
14191
- */
14192
- function renderComponent(componentType /* Type as workaround for: Microsoft/TypeScript/issues/4881 */, opts = {}) {
14193
- ngDevMode && publishDefaultGlobalUtils();
14194
- ngDevMode && assertComponentType(componentType);
14195
- enableRenderer3();
14196
- const rendererFactory = opts.rendererFactory || domRendererFactory3;
14197
- const sanitizer = opts.sanitizer || null;
14198
- const componentDef = getComponentDef$1(componentType);
14199
- if (componentDef.type != componentType)
14200
- componentDef.type = componentType;
14201
- // The first index of the first selector is the tag name.
14202
- const componentTag = componentDef.selectors[0][0];
14203
- const hostRenderer = rendererFactory.createRenderer(null, null);
14204
- const hostRNode = locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
14205
- const rootFlags = componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
14206
- 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
14207
- const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
14208
- const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
14209
- const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
14210
- const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
14211
- enterView(rootView);
14212
- let component;
14213
- try {
14214
- if (rendererFactory.begin)
14215
- rendererFactory.begin();
14216
- const componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
14217
- component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
14218
- // create mode pass
14219
- renderView(rootTView, rootView, null);
14220
- // update mode pass
14221
- refreshView(rootTView, rootView, null, null);
14222
- }
14223
- finally {
14224
- leaveView();
14225
- if (rendererFactory.end)
14226
- rendererFactory.end();
14041
+ * Updates the value of or removes a bound attribute on an Element.
14042
+ *
14043
+ * Used in the case of `[attr.title]="value"`
14044
+ *
14045
+ * @param name name The name of the attribute.
14046
+ * @param value value The attribute is removed when value is `null` or `undefined`.
14047
+ * Otherwise the attribute value is set to the stringified value.
14048
+ * @param sanitizer An optional function used to sanitize the value.
14049
+ * @param namespace Optional namespace to use when setting the attribute.
14050
+ *
14051
+ * @codeGenApi
14052
+ */
14053
+ function ɵɵattribute(name, value, sanitizer, namespace) {
14054
+ const lView = getLView();
14055
+ const bindingIndex = nextBindingIndex();
14056
+ if (bindingUpdated(lView, bindingIndex, value)) {
14057
+ const tView = getTView();
14058
+ const tNode = getSelectedTNode();
14059
+ elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace);
14060
+ ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex);
14227
14061
  }
14228
- return component;
14062
+ return ɵɵattribute;
14229
14063
  }
14064
+
14230
14065
  /**
14231
- * Creates the root component view and the root component node.
14066
+ * @license
14067
+ * Copyright Google LLC All Rights Reserved.
14232
14068
  *
14233
- * @param rNode Render host element.
14234
- * @param def ComponentDef
14235
- * @param rootView The parent view where the host node is stored
14236
- * @param rendererFactory Factory to be used for creating child renderers.
14237
- * @param hostRenderer The current renderer
14238
- * @param sanitizer The sanitizer, if provided
14069
+ * Use of this source code is governed by an MIT-style license that can be
14070
+ * found in the LICENSE file at https://angular.io/license
14071
+ */
14072
+ /**
14073
+ * Create interpolation bindings with a variable number of expressions.
14239
14074
  *
14240
- * @returns Component view created
14075
+ * If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
14076
+ * Those are faster because there is no need to create an array of expressions and iterate over it.
14077
+ *
14078
+ * `values`:
14079
+ * - has static text at even indexes,
14080
+ * - has evaluated expressions at odd indexes.
14081
+ *
14082
+ * Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
14241
14083
  */
14242
- function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
14243
- const tView = rootView[TVIEW];
14244
- const index = HEADER_OFFSET;
14245
- ngDevMode && assertIndexInRange(rootView, index);
14246
- rootView[index] = rNode;
14247
- // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
14248
- // the same time we want to communicate the debug `TNode` that this is a special `TNode`
14249
- // representing a host element.
14250
- const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
14251
- const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
14252
- if (mergedAttrs !== null) {
14253
- computeStaticStyling(tNode, mergedAttrs, true);
14254
- if (rNode !== null) {
14255
- setUpAttributes(hostRenderer, rNode, mergedAttrs);
14256
- if (tNode.classes !== null) {
14257
- writeDirectClass(hostRenderer, rNode, tNode.classes);
14258
- }
14259
- if (tNode.styles !== null) {
14260
- writeDirectStyle(hostRenderer, rNode, tNode.styles);
14261
- }
14262
- }
14084
+ function interpolationV(lView, values) {
14085
+ ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
14086
+ ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
14087
+ let isBindingUpdated = false;
14088
+ let bindingIndex = getBindingIndex();
14089
+ for (let i = 1; i < values.length; i += 2) {
14090
+ // Check if bindings (odd indexes) have changed
14091
+ isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
14263
14092
  }
14264
- const viewRenderer = rendererFactory.createRenderer(rNode, def);
14265
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14266
- if (tView.firstCreatePass) {
14267
- diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14268
- markAsComponentHost(tView, tNode);
14269
- initTNodeFlags(tNode, rootView.length, 1);
14093
+ setBindingIndex(bindingIndex);
14094
+ if (!isBindingUpdated) {
14095
+ return NO_CHANGE;
14270
14096
  }
14271
- addToViewTree(rootView, componentView);
14272
- // Store component view at node index, with node as the HOST
14273
- return rootView[index] = componentView;
14097
+ // Build the updated content
14098
+ let content = values[0];
14099
+ for (let i = 1; i < values.length; i += 2) {
14100
+ content += renderStringify(values[i]) + values[i + 1];
14101
+ }
14102
+ return content;
14274
14103
  }
14275
14104
  /**
14276
- * Creates a root component and sets it up with features and host bindings. Shared by
14277
- * renderComponent() and ViewContainerRef.createComponent().
14105
+ * Creates an interpolation binding with 1 expression.
14106
+ *
14107
+ * @param prefix static value used for concatenation only.
14108
+ * @param v0 value checked for change.
14109
+ * @param suffix static value used for concatenation only.
14278
14110
  */
14279
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
14280
- const tView = rootLView[TVIEW];
14281
- // Create directive instance with factory() and store at next index in viewData
14282
- const component = instantiateRootComponent(tView, rootLView, componentDef);
14283
- rootContext.components.push(component);
14284
- componentView[CONTEXT] = component;
14285
- if (hostFeatures !== null) {
14286
- for (const feature of hostFeatures) {
14287
- feature(component, componentDef);
14288
- }
14289
- }
14290
- // We want to generate an empty QueryList for root content queries for backwards
14291
- // compatibility with ViewEngine.
14292
- if (componentDef.contentQueries) {
14293
- const tNode = getCurrentTNode();
14294
- ngDevMode && assertDefined(tNode, 'TNode expected');
14295
- componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
14296
- }
14297
- const rootTNode = getCurrentTNode();
14298
- ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
14299
- if (tView.firstCreatePass &&
14300
- (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
14301
- setSelectedIndex(rootTNode.index);
14302
- const rootTView = rootLView[TVIEW];
14303
- registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
14304
- invokeHostBindingsInCreationMode(componentDef, component);
14305
- }
14306
- return component;
14111
+ function interpolation1(lView, prefix, v0, suffix) {
14112
+ const different = bindingUpdated(lView, nextBindingIndex(), v0);
14113
+ return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
14307
14114
  }
14308
- function createRootContext(scheduler, playerHandler) {
14309
- return {
14310
- components: [],
14311
- scheduler: scheduler || defaultScheduler,
14312
- clean: CLEAN_PROMISE,
14313
- playerHandler: playerHandler || null,
14314
- flags: 0 /* RootContextFlags.Empty */
14315
- };
14115
+ /**
14116
+ * Creates an interpolation binding with 2 expressions.
14117
+ */
14118
+ function interpolation2(lView, prefix, v0, i0, v1, suffix) {
14119
+ const bindingIndex = getBindingIndex();
14120
+ const different = bindingUpdated2(lView, bindingIndex, v0, v1);
14121
+ incrementBindingIndex(2);
14122
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
14316
14123
  }
14317
14124
  /**
14318
- * Used to enable lifecycle hooks on the root component.
14319
- *
14320
- * Include this feature when calling `renderComponent` if the root component
14321
- * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
14322
- * be called properly.
14323
- *
14324
- * Example:
14325
- *
14326
- * ```
14327
- * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
14328
- * ```
14125
+ * Creates an interpolation binding with 3 expressions.
14329
14126
  */
14330
- function LifecycleHooksFeature() {
14331
- const tNode = getCurrentTNode();
14332
- ngDevMode && assertDefined(tNode, 'TNode is required');
14333
- registerPostOrderHooks(getLView()[TVIEW], tNode);
14127
+ function interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix) {
14128
+ const bindingIndex = getBindingIndex();
14129
+ const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
14130
+ incrementBindingIndex(3);
14131
+ return different ?
14132
+ prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
14133
+ NO_CHANGE;
14334
14134
  }
14335
14135
  /**
14336
- * Wait on component until it is rendered.
14337
- *
14338
- * This function returns a `Promise` which is resolved when the component's
14339
- * change detection is executed. This is determined by finding the scheduler
14340
- * associated with the `component`'s render tree and waiting until the scheduler
14341
- * flushes. If nothing is scheduled, the function returns a resolved promise.
14342
- *
14343
- * Example:
14344
- * ```
14345
- * await whenRendered(myComponent);
14346
- * ```
14347
- *
14348
- * @param component Component to wait upon
14349
- * @returns Promise which resolves when the component is rendered.
14136
+ * Create an interpolation binding with 4 expressions.
14350
14137
  */
14351
- function whenRendered(component) {
14352
- return getRootContext(component).clean;
14138
+ function interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix) {
14139
+ const bindingIndex = getBindingIndex();
14140
+ const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14141
+ incrementBindingIndex(4);
14142
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14143
+ renderStringify(v2) + i2 + renderStringify(v3) + suffix :
14144
+ NO_CHANGE;
14353
14145
  }
14354
-
14355
14146
  /**
14356
- * @license
14357
- * Copyright Google LLC All Rights Reserved.
14358
- *
14359
- * Use of this source code is governed by an MIT-style license that can be
14360
- * found in the LICENSE file at https://angular.io/license
14147
+ * Creates an interpolation binding with 5 expressions.
14361
14148
  */
14362
- function getSuperType(type) {
14363
- return Object.getPrototypeOf(type.prototype).constructor;
14149
+ function interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix) {
14150
+ const bindingIndex = getBindingIndex();
14151
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14152
+ different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
14153
+ incrementBindingIndex(5);
14154
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14155
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
14156
+ NO_CHANGE;
14364
14157
  }
14365
14158
  /**
14366
- * Merges the definition from a super class to a sub class.
14367
- * @param definition The definition that is a SubClass of another directive of component
14368
- *
14369
- * @codeGenApi
14159
+ * Creates an interpolation binding with 6 expressions.
14370
14160
  */
14371
- function ɵɵInheritDefinitionFeature(definition) {
14372
- let superType = getSuperType(definition.type);
14373
- let shouldInheritFields = true;
14374
- const inheritanceChain = [definition];
14375
- while (superType) {
14376
- let superDef = undefined;
14377
- if (isComponentDef(definition)) {
14378
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14379
- superDef = superType.ɵcmp || superType.ɵdir;
14380
- }
14381
- else {
14382
- if (superType.ɵcmp) {
14383
- throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
14384
- `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
14385
- }
14386
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14387
- superDef = superType.ɵdir;
14388
- }
14389
- if (superDef) {
14390
- if (shouldInheritFields) {
14391
- inheritanceChain.push(superDef);
14392
- // Some fields in the definition may be empty, if there were no values to put in them that
14393
- // would've justified object creation. Unwrap them if necessary.
14394
- const writeableDef = definition;
14395
- writeableDef.inputs = maybeUnwrapEmpty(definition.inputs);
14396
- writeableDef.declaredInputs = maybeUnwrapEmpty(definition.declaredInputs);
14397
- writeableDef.outputs = maybeUnwrapEmpty(definition.outputs);
14398
- // Merge hostBindings
14399
- const superHostBindings = superDef.hostBindings;
14400
- superHostBindings && inheritHostBindings(definition, superHostBindings);
14401
- // Merge queries
14402
- const superViewQuery = superDef.viewQuery;
14403
- const superContentQueries = superDef.contentQueries;
14404
- superViewQuery && inheritViewQuery(definition, superViewQuery);
14405
- superContentQueries && inheritContentQueries(definition, superContentQueries);
14406
- // Merge inputs and outputs
14407
- fillProperties(definition.inputs, superDef.inputs);
14408
- fillProperties(definition.declaredInputs, superDef.declaredInputs);
14409
- fillProperties(definition.outputs, superDef.outputs);
14410
- // Merge animations metadata.
14411
- // If `superDef` is a Component, the `data` field is present (defaults to an empty object).
14412
- if (isComponentDef(superDef) && superDef.data.animation) {
14413
- // If super def is a Component, the `definition` is also a Component, since Directives can
14414
- // not inherit Components (we throw an error above and cannot reach this code).
14415
- const defData = definition.data;
14416
- defData.animation = (defData.animation || []).concat(superDef.data.animation);
14417
- }
14418
- }
14419
- // Run parent features
14420
- const features = superDef.features;
14421
- if (features) {
14422
- for (let i = 0; i < features.length; i++) {
14423
- const feature = features[i];
14424
- if (feature && feature.ngInherit) {
14425
- feature(definition);
14426
- }
14427
- // If `InheritDefinitionFeature` is a part of the current `superDef`, it means that this
14428
- // def already has all the necessary information inherited from its super class(es), so we
14429
- // can stop merging fields from super classes. However we need to iterate through the
14430
- // prototype chain to look for classes that might contain other "features" (like
14431
- // NgOnChanges), which we should invoke for the original `definition`. We set the
14432
- // `shouldInheritFields` flag to indicate that, essentially skipping fields inheritance
14433
- // logic and only invoking functions from the "features" list.
14434
- if (feature === ɵɵInheritDefinitionFeature) {
14435
- shouldInheritFields = false;
14436
- }
14437
- }
14438
- }
14439
- }
14440
- superType = Object.getPrototypeOf(superType);
14441
- }
14442
- mergeHostAttrsAcrossInheritance(inheritanceChain);
14161
+ function interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix) {
14162
+ const bindingIndex = getBindingIndex();
14163
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14164
+ different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
14165
+ incrementBindingIndex(6);
14166
+ return different ?
14167
+ prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
14168
+ renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
14169
+ NO_CHANGE;
14443
14170
  }
14444
14171
  /**
14445
- * Merge the `hostAttrs` and `hostVars` from the inherited parent to the base class.
14446
- *
14447
- * @param inheritanceChain A list of `WritableDefs` starting at the top most type and listing
14448
- * sub-types in order. For each type take the `hostAttrs` and `hostVars` and merge it with the child
14449
- * type.
14172
+ * Creates an interpolation binding with 7 expressions.
14450
14173
  */
14451
- function mergeHostAttrsAcrossInheritance(inheritanceChain) {
14452
- let hostVars = 0;
14453
- let hostAttrs = null;
14454
- // We process the inheritance order from the base to the leaves here.
14455
- for (let i = inheritanceChain.length - 1; i >= 0; i--) {
14456
- const def = inheritanceChain[i];
14457
- // For each `hostVars`, we need to add the superclass amount.
14458
- def.hostVars = (hostVars += def.hostVars);
14459
- // for each `hostAttrs` we need to merge it with superclass.
14460
- def.hostAttrs =
14461
- mergeHostAttrs(def.hostAttrs, hostAttrs = mergeHostAttrs(hostAttrs, def.hostAttrs));
14462
- }
14463
- }
14464
- function maybeUnwrapEmpty(value) {
14465
- if (value === EMPTY_OBJ) {
14466
- return {};
14467
- }
14468
- else if (value === EMPTY_ARRAY) {
14469
- return [];
14470
- }
14471
- else {
14472
- return value;
14473
- }
14474
- }
14475
- function inheritViewQuery(definition, superViewQuery) {
14476
- const prevViewQuery = definition.viewQuery;
14477
- if (prevViewQuery) {
14478
- definition.viewQuery = (rf, ctx) => {
14479
- superViewQuery(rf, ctx);
14480
- prevViewQuery(rf, ctx);
14481
- };
14482
- }
14483
- else {
14484
- definition.viewQuery = superViewQuery;
14485
- }
14486
- }
14487
- function inheritContentQueries(definition, superContentQueries) {
14488
- const prevContentQueries = definition.contentQueries;
14489
- if (prevContentQueries) {
14490
- definition.contentQueries = (rf, ctx, directiveIndex) => {
14491
- superContentQueries(rf, ctx, directiveIndex);
14492
- prevContentQueries(rf, ctx, directiveIndex);
14493
- };
14494
- }
14495
- else {
14496
- definition.contentQueries = superContentQueries;
14497
- }
14174
+ function interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix) {
14175
+ const bindingIndex = getBindingIndex();
14176
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14177
+ different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
14178
+ incrementBindingIndex(7);
14179
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14180
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14181
+ renderStringify(v5) + i5 + renderStringify(v6) + suffix :
14182
+ NO_CHANGE;
14498
14183
  }
14499
- function inheritHostBindings(definition, superHostBindings) {
14500
- const prevHostBindings = definition.hostBindings;
14501
- if (prevHostBindings) {
14502
- definition.hostBindings = (rf, ctx) => {
14503
- superHostBindings(rf, ctx);
14504
- prevHostBindings(rf, ctx);
14505
- };
14506
- }
14507
- else {
14508
- definition.hostBindings = superHostBindings;
14509
- }
14184
+ /**
14185
+ * Creates an interpolation binding with 8 expressions.
14186
+ */
14187
+ function interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix) {
14188
+ const bindingIndex = getBindingIndex();
14189
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14190
+ different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
14191
+ incrementBindingIndex(8);
14192
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14193
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14194
+ renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
14195
+ NO_CHANGE;
14510
14196
  }
14511
14197
 
14512
14198
  /**
14513
- * @license
14514
- * Copyright Google LLC All Rights Reserved.
14515
14199
  *
14516
- * Use of this source code is governed by an MIT-style license that can be
14517
- * found in the LICENSE file at https://angular.io/license
14518
- */
14519
- /**
14520
- * Fields which exist on either directive or component definitions, and need to be copied from
14521
- * parent to child classes by the `ɵɵCopyDefinitionFeature`.
14522
- */
14523
- const COPY_DIRECTIVE_FIELDS = [
14524
- // The child class should use the providers of its parent.
14525
- 'providersResolver',
14526
- // Not listed here are any fields which are handled by the `ɵɵInheritDefinitionFeature`, such
14527
- // as inputs, outputs, and host binding functions.
14528
- ];
14529
- /**
14530
- * Fields which exist only on component definitions, and need to be copied from parent to child
14531
- * classes by the `ɵɵCopyDefinitionFeature`.
14200
+ * Update an interpolated attribute on an element with single bound value surrounded by text.
14532
14201
  *
14533
- * The type here allows any field of `ComponentDef` which is not also a property of `DirectiveDef`,
14534
- * since those should go in `COPY_DIRECTIVE_FIELDS` above.
14535
- */
14536
- const COPY_COMPONENT_FIELDS = [
14537
- // The child class should use the template function of its parent, including all template
14538
- // semantics.
14539
- 'template',
14540
- 'decls',
14541
- 'consts',
14542
- 'vars',
14543
- 'onPush',
14544
- 'ngContentSelectors',
14545
- // The child class should use the CSS styles of its parent, including all styling semantics.
14546
- 'styles',
14547
- 'encapsulation',
14548
- // The child class should be checked by the runtime in the same way as its parent.
14549
- 'schemas',
14550
- ];
14551
- /**
14552
- * Copies the fields not handled by the `ɵɵInheritDefinitionFeature` from the supertype of a
14553
- * definition.
14202
+ * Used when the value passed to a property has 1 interpolated value in it:
14554
14203
  *
14555
- * This exists primarily to support ngcc migration of an existing View Engine pattern, where an
14556
- * entire decorator is inherited from a parent to a child class. When ngcc detects this case, it
14557
- * generates a skeleton definition on the child class, and applies this feature.
14204
+ * ```html
14205
+ * <div attr.title="prefix{{v0}}suffix"></div>
14206
+ * ```
14558
14207
  *
14559
- * The `ɵɵCopyDefinitionFeature` then copies any needed fields from the parent class' definition,
14560
- * including things like the component template function.
14208
+ * Its compiled representation is::
14561
14209
  *
14562
- * @param definition The definition of a child class which inherits from a parent class with its
14563
- * own definition.
14210
+ * ```ts
14211
+ * ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
14212
+ * ```
14564
14213
  *
14214
+ * @param attrName The name of the attribute to update
14215
+ * @param prefix Static value used for concatenation only.
14216
+ * @param v0 Value checked for change.
14217
+ * @param suffix Static value used for concatenation only.
14218
+ * @param sanitizer An optional sanitizer function
14219
+ * @returns itself, so that it may be chained.
14565
14220
  * @codeGenApi
14566
14221
  */
14567
- function ɵɵCopyDefinitionFeature(definition) {
14568
- let superType = getSuperType(definition.type);
14569
- let superDef = undefined;
14570
- if (isComponentDef(definition)) {
14571
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14572
- superDef = superType.ɵcmp;
14573
- }
14574
- else {
14575
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14576
- superDef = superType.ɵdir;
14577
- }
14578
- // Needed because `definition` fields are readonly.
14579
- const defAny = definition;
14580
- // Copy over any fields that apply to either directives or components.
14581
- for (const field of COPY_DIRECTIVE_FIELDS) {
14582
- defAny[field] = superDef[field];
14583
- }
14584
- if (isComponentDef(superDef)) {
14585
- // Copy over any component-specific fields.
14586
- for (const field of COPY_COMPONENT_FIELDS) {
14587
- defAny[field] = superDef[field];
14588
- }
14222
+ function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
14223
+ const lView = getLView();
14224
+ const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
14225
+ if (interpolatedValue !== NO_CHANGE) {
14226
+ const tNode = getSelectedTNode();
14227
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14228
+ ngDevMode &&
14229
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
14589
14230
  }
14231
+ return ɵɵattributeInterpolate1;
14590
14232
  }
14591
-
14592
14233
  /**
14593
- * @license
14594
- * Copyright Google LLC All Rights Reserved.
14595
14234
  *
14596
- * Use of this source code is governed by an MIT-style license that can be
14597
- * found in the LICENSE file at https://angular.io/license
14598
- */
14599
- let _symbolIterator = null;
14600
- function getSymbolIterator() {
14601
- if (!_symbolIterator) {
14602
- const Symbol = _global$1['Symbol'];
14603
- if (Symbol && Symbol.iterator) {
14604
- _symbolIterator = Symbol.iterator;
14605
- }
14606
- else {
14607
- // es6-shim specific logic
14608
- const keys = Object.getOwnPropertyNames(Map.prototype);
14609
- for (let i = 0; i < keys.length; ++i) {
14610
- const key = keys[i];
14611
- if (key !== 'entries' && key !== 'size' &&
14612
- Map.prototype[key] === Map.prototype['entries']) {
14613
- _symbolIterator = key;
14614
- }
14615
- }
14616
- }
14617
- }
14618
- return _symbolIterator;
14619
- }
14620
-
14621
- /**
14622
- * @license
14623
- * Copyright Google LLC All Rights Reserved.
14235
+ * Update an interpolated attribute on an element with 2 bound values surrounded by text.
14624
14236
  *
14625
- * Use of this source code is governed by an MIT-style license that can be
14626
- * found in the LICENSE file at https://angular.io/license
14627
- */
14628
- function isIterable(obj) {
14629
- return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
14630
- }
14631
- function isListLikeIterable(obj) {
14632
- if (!isJsObject(obj))
14633
- return false;
14634
- return Array.isArray(obj) ||
14635
- (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
14636
- getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
14637
- }
14638
- function areIterablesEqual(a, b, comparator) {
14639
- const iterator1 = a[getSymbolIterator()]();
14640
- const iterator2 = b[getSymbolIterator()]();
14641
- while (true) {
14642
- const item1 = iterator1.next();
14643
- const item2 = iterator2.next();
14644
- if (item1.done && item2.done)
14645
- return true;
14646
- if (item1.done || item2.done)
14647
- return false;
14648
- if (!comparator(item1.value, item2.value))
14649
- return false;
14650
- }
14651
- }
14652
- function iterateListLike(obj, fn) {
14653
- if (Array.isArray(obj)) {
14654
- for (let i = 0; i < obj.length; i++) {
14655
- fn(obj[i]);
14656
- }
14657
- }
14658
- else {
14659
- const iterator = obj[getSymbolIterator()]();
14660
- let item;
14661
- while (!((item = iterator.next()).done)) {
14662
- fn(item.value);
14663
- }
14664
- }
14665
- }
14666
- function isJsObject(o) {
14667
- return o !== null && (typeof o === 'function' || typeof o === 'object');
14668
- }
14669
-
14670
- /**
14671
- * @license
14672
- * Copyright Google LLC All Rights Reserved.
14237
+ * Used when the value passed to a property has 2 interpolated values in it:
14673
14238
  *
14674
- * Use of this source code is governed by an MIT-style license that can be
14675
- * found in the LICENSE file at https://angular.io/license
14676
- */
14677
- function devModeEqual(a, b) {
14678
- const isListLikeIterableA = isListLikeIterable(a);
14679
- const isListLikeIterableB = isListLikeIterable(b);
14680
- if (isListLikeIterableA && isListLikeIterableB) {
14681
- return areIterablesEqual(a, b, devModeEqual);
14682
- }
14683
- else {
14684
- const isAObject = a && (typeof a === 'object' || typeof a === 'function');
14685
- const isBObject = b && (typeof b === 'object' || typeof b === 'function');
14686
- if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
14687
- return true;
14688
- }
14689
- else {
14690
- return Object.is(a, b);
14691
- }
14692
- }
14693
- }
14694
-
14695
- /**
14696
- * @license
14697
- * Copyright Google LLC All Rights Reserved.
14239
+ * ```html
14240
+ * <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
14241
+ * ```
14698
14242
  *
14699
- * Use of this source code is governed by an MIT-style license that can be
14700
- * found in the LICENSE file at https://angular.io/license
14701
- */
14702
- // TODO(misko): consider inlining
14703
- /** Updates binding and returns the value. */
14704
- function updateBinding(lView, bindingIndex, value) {
14705
- return lView[bindingIndex] = value;
14706
- }
14707
- /** Gets the current binding value. */
14708
- function getBinding(lView, bindingIndex) {
14709
- ngDevMode && assertIndexInRange(lView, bindingIndex);
14710
- ngDevMode &&
14711
- assertNotSame(lView[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
14712
- return lView[bindingIndex];
14713
- }
14714
- /**
14715
- * Updates binding if changed, then returns whether it was updated.
14243
+ * Its compiled representation is::
14716
14244
  *
14717
- * This function also checks the `CheckNoChangesMode` and throws if changes are made.
14718
- * Some changes (Objects/iterables) during `CheckNoChangesMode` are exempt to comply with VE
14719
- * behavior.
14245
+ * ```ts
14246
+ * ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
14247
+ * ```
14720
14248
  *
14721
- * @param lView current `LView`
14722
- * @param bindingIndex The binding in the `LView` to check
14723
- * @param value New value to check against `lView[bindingIndex]`
14724
- * @returns `true` if the bindings has changed. (Throws if binding has changed during
14725
- * `CheckNoChangesMode`)
14249
+ * @param attrName The name of the attribute to update
14250
+ * @param prefix Static value used for concatenation only.
14251
+ * @param v0 Value checked for change.
14252
+ * @param i0 Static value used for concatenation only.
14253
+ * @param v1 Value checked for change.
14254
+ * @param suffix Static value used for concatenation only.
14255
+ * @param sanitizer An optional sanitizer function
14256
+ * @returns itself, so that it may be chained.
14257
+ * @codeGenApi
14726
14258
  */
14727
- function bindingUpdated(lView, bindingIndex, value) {
14728
- ngDevMode && assertNotSame(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
14729
- ngDevMode &&
14730
- assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
14731
- const oldValue = lView[bindingIndex];
14732
- if (Object.is(oldValue, value)) {
14733
- return false;
14734
- }
14735
- else {
14736
- if (ngDevMode && isInCheckNoChangesMode()) {
14737
- // View engine didn't report undefined values as changed on the first checkNoChanges pass
14738
- // (before the change detection was run).
14739
- const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined;
14740
- if (!devModeEqual(oldValueToCompare, value)) {
14741
- const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
14742
- throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName);
14743
- }
14744
- // There was a change, but the `devModeEqual` decided that the change is exempt from an error.
14745
- // For this reason we exit as if no change. The early exit is needed to prevent the changed
14746
- // value to be written into `LView` (If we would write the new value that we would not see it
14747
- // as change on next CD.)
14748
- return false;
14749
- }
14750
- lView[bindingIndex] = value;
14751
- return true;
14259
+ function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
14260
+ const lView = getLView();
14261
+ const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
14262
+ if (interpolatedValue !== NO_CHANGE) {
14263
+ const tNode = getSelectedTNode();
14264
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14265
+ ngDevMode &&
14266
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
14752
14267
  }
14268
+ return ɵɵattributeInterpolate2;
14753
14269
  }
14754
- /** Updates 2 bindings if changed, then returns whether either was updated. */
14755
- function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
14756
- const different = bindingUpdated(lView, bindingIndex, exp1);
14757
- return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
14758
- }
14759
- /** Updates 3 bindings if changed, then returns whether any was updated. */
14760
- function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
14761
- const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14762
- return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
14763
- }
14764
- /** Updates 4 bindings if changed, then returns whether any was updated. */
14765
- function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
14766
- const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14767
- return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
14768
- }
14769
-
14770
14270
  /**
14771
- * @license
14772
- * Copyright Google LLC All Rights Reserved.
14773
14271
  *
14774
- * Use of this source code is governed by an MIT-style license that can be
14775
- * found in the LICENSE file at https://angular.io/license
14776
- */
14777
- /**
14778
- * Updates the value of or removes a bound attribute on an Element.
14272
+ * Update an interpolated attribute on an element with 3 bound values surrounded by text.
14779
14273
  *
14780
- * Used in the case of `[attr.title]="value"`
14274
+ * Used when the value passed to a property has 3 interpolated values in it:
14781
14275
  *
14782
- * @param name name The name of the attribute.
14783
- * @param value value The attribute is removed when value is `null` or `undefined`.
14784
- * Otherwise the attribute value is set to the stringified value.
14785
- * @param sanitizer An optional function used to sanitize the value.
14786
- * @param namespace Optional namespace to use when setting the attribute.
14276
+ * ```html
14277
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
14278
+ * ```
14279
+ *
14280
+ * Its compiled representation is::
14281
+ *
14282
+ * ```ts
14283
+ * ɵɵattributeInterpolate3(
14284
+ * 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
14285
+ * ```
14787
14286
  *
14287
+ * @param attrName The name of the attribute to update
14288
+ * @param prefix Static value used for concatenation only.
14289
+ * @param v0 Value checked for change.
14290
+ * @param i0 Static value used for concatenation only.
14291
+ * @param v1 Value checked for change.
14292
+ * @param i1 Static value used for concatenation only.
14293
+ * @param v2 Value checked for change.
14294
+ * @param suffix Static value used for concatenation only.
14295
+ * @param sanitizer An optional sanitizer function
14296
+ * @returns itself, so that it may be chained.
14788
14297
  * @codeGenApi
14789
14298
  */
14790
- function ɵɵattribute(name, value, sanitizer, namespace) {
14299
+ function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
14791
14300
  const lView = getLView();
14792
- const bindingIndex = nextBindingIndex();
14793
- if (bindingUpdated(lView, bindingIndex, value)) {
14794
- const tView = getTView();
14301
+ const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
14302
+ if (interpolatedValue !== NO_CHANGE) {
14795
14303
  const tNode = getSelectedTNode();
14796
- elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace);
14797
- ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex);
14304
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14305
+ ngDevMode &&
14306
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
14798
14307
  }
14799
- return ɵɵattribute;
14308
+ return ɵɵattributeInterpolate3;
14800
14309
  }
14801
-
14802
14310
  /**
14803
- * @license
14804
- * Copyright Google LLC All Rights Reserved.
14805
14311
  *
14806
- * Use of this source code is governed by an MIT-style license that can be
14807
- * found in the LICENSE file at https://angular.io/license
14808
- */
14809
- /**
14810
- * Create interpolation bindings with a variable number of expressions.
14312
+ * Update an interpolated attribute on an element with 4 bound values surrounded by text.
14811
14313
  *
14812
- * If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
14813
- * Those are faster because there is no need to create an array of expressions and iterate over it.
14814
- *
14815
- * `values`:
14816
- * - has static text at even indexes,
14817
- * - has evaluated expressions at odd indexes.
14818
- *
14819
- * Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
14820
- */
14821
- function interpolationV(lView, values) {
14822
- ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
14823
- ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
14824
- let isBindingUpdated = false;
14825
- let bindingIndex = getBindingIndex();
14826
- for (let i = 1; i < values.length; i += 2) {
14827
- // Check if bindings (odd indexes) have changed
14828
- isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
14829
- }
14830
- setBindingIndex(bindingIndex);
14831
- if (!isBindingUpdated) {
14832
- return NO_CHANGE;
14833
- }
14834
- // Build the updated content
14835
- let content = values[0];
14836
- for (let i = 1; i < values.length; i += 2) {
14837
- content += renderStringify(values[i]) + values[i + 1];
14838
- }
14839
- return content;
14840
- }
14841
- /**
14842
- * Creates an interpolation binding with 1 expression.
14843
- *
14844
- * @param prefix static value used for concatenation only.
14845
- * @param v0 value checked for change.
14846
- * @param suffix static value used for concatenation only.
14847
- */
14848
- function interpolation1(lView, prefix, v0, suffix) {
14849
- const different = bindingUpdated(lView, nextBindingIndex(), v0);
14850
- return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
14851
- }
14852
- /**
14853
- * Creates an interpolation binding with 2 expressions.
14854
- */
14855
- function interpolation2(lView, prefix, v0, i0, v1, suffix) {
14856
- const bindingIndex = getBindingIndex();
14857
- const different = bindingUpdated2(lView, bindingIndex, v0, v1);
14858
- incrementBindingIndex(2);
14859
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
14860
- }
14861
- /**
14862
- * Creates an interpolation binding with 3 expressions.
14863
- */
14864
- function interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix) {
14865
- const bindingIndex = getBindingIndex();
14866
- const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
14867
- incrementBindingIndex(3);
14868
- return different ?
14869
- prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
14870
- NO_CHANGE;
14871
- }
14872
- /**
14873
- * Create an interpolation binding with 4 expressions.
14874
- */
14875
- function interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix) {
14876
- const bindingIndex = getBindingIndex();
14877
- const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14878
- incrementBindingIndex(4);
14879
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14880
- renderStringify(v2) + i2 + renderStringify(v3) + suffix :
14881
- NO_CHANGE;
14882
- }
14883
- /**
14884
- * Creates an interpolation binding with 5 expressions.
14885
- */
14886
- function interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix) {
14887
- const bindingIndex = getBindingIndex();
14888
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14889
- different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
14890
- incrementBindingIndex(5);
14891
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14892
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
14893
- NO_CHANGE;
14894
- }
14895
- /**
14896
- * Creates an interpolation binding with 6 expressions.
14897
- */
14898
- function interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix) {
14899
- const bindingIndex = getBindingIndex();
14900
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14901
- different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
14902
- incrementBindingIndex(6);
14903
- return different ?
14904
- prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
14905
- renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
14906
- NO_CHANGE;
14907
- }
14908
- /**
14909
- * Creates an interpolation binding with 7 expressions.
14910
- */
14911
- function interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix) {
14912
- const bindingIndex = getBindingIndex();
14913
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14914
- different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
14915
- incrementBindingIndex(7);
14916
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14917
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14918
- renderStringify(v5) + i5 + renderStringify(v6) + suffix :
14919
- NO_CHANGE;
14920
- }
14921
- /**
14922
- * Creates an interpolation binding with 8 expressions.
14923
- */
14924
- function interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix) {
14925
- const bindingIndex = getBindingIndex();
14926
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14927
- different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
14928
- incrementBindingIndex(8);
14929
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14930
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14931
- renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
14932
- NO_CHANGE;
14933
- }
14934
-
14935
- /**
14936
- *
14937
- * Update an interpolated attribute on an element with single bound value surrounded by text.
14938
- *
14939
- * Used when the value passed to a property has 1 interpolated value in it:
14940
- *
14941
- * ```html
14942
- * <div attr.title="prefix{{v0}}suffix"></div>
14943
- * ```
14944
- *
14945
- * Its compiled representation is::
14946
- *
14947
- * ```ts
14948
- * ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
14949
- * ```
14950
- *
14951
- * @param attrName The name of the attribute to update
14952
- * @param prefix Static value used for concatenation only.
14953
- * @param v0 Value checked for change.
14954
- * @param suffix Static value used for concatenation only.
14955
- * @param sanitizer An optional sanitizer function
14956
- * @returns itself, so that it may be chained.
14957
- * @codeGenApi
14958
- */
14959
- function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
14960
- const lView = getLView();
14961
- const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
14962
- if (interpolatedValue !== NO_CHANGE) {
14963
- const tNode = getSelectedTNode();
14964
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14965
- ngDevMode &&
14966
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
14967
- }
14968
- return ɵɵattributeInterpolate1;
14969
- }
14970
- /**
14971
- *
14972
- * Update an interpolated attribute on an element with 2 bound values surrounded by text.
14973
- *
14974
- * Used when the value passed to a property has 2 interpolated values in it:
14975
- *
14976
- * ```html
14977
- * <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
14978
- * ```
14979
- *
14980
- * Its compiled representation is::
14981
- *
14982
- * ```ts
14983
- * ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
14984
- * ```
14985
- *
14986
- * @param attrName The name of the attribute to update
14987
- * @param prefix Static value used for concatenation only.
14988
- * @param v0 Value checked for change.
14989
- * @param i0 Static value used for concatenation only.
14990
- * @param v1 Value checked for change.
14991
- * @param suffix Static value used for concatenation only.
14992
- * @param sanitizer An optional sanitizer function
14993
- * @returns itself, so that it may be chained.
14994
- * @codeGenApi
14995
- */
14996
- function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
14997
- const lView = getLView();
14998
- const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
14999
- if (interpolatedValue !== NO_CHANGE) {
15000
- const tNode = getSelectedTNode();
15001
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15002
- ngDevMode &&
15003
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
15004
- }
15005
- return ɵɵattributeInterpolate2;
15006
- }
15007
- /**
15008
- *
15009
- * Update an interpolated attribute on an element with 3 bound values surrounded by text.
15010
- *
15011
- * Used when the value passed to a property has 3 interpolated values in it:
15012
- *
15013
- * ```html
15014
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
15015
- * ```
15016
- *
15017
- * Its compiled representation is::
15018
- *
15019
- * ```ts
15020
- * ɵɵattributeInterpolate3(
15021
- * 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
15022
- * ```
15023
- *
15024
- * @param attrName The name of the attribute to update
15025
- * @param prefix Static value used for concatenation only.
15026
- * @param v0 Value checked for change.
15027
- * @param i0 Static value used for concatenation only.
15028
- * @param v1 Value checked for change.
15029
- * @param i1 Static value used for concatenation only.
15030
- * @param v2 Value checked for change.
15031
- * @param suffix Static value used for concatenation only.
15032
- * @param sanitizer An optional sanitizer function
15033
- * @returns itself, so that it may be chained.
15034
- * @codeGenApi
15035
- */
15036
- function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
15037
- const lView = getLView();
15038
- const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
15039
- if (interpolatedValue !== NO_CHANGE) {
15040
- const tNode = getSelectedTNode();
15041
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15042
- ngDevMode &&
15043
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
15044
- }
15045
- return ɵɵattributeInterpolate3;
15046
- }
15047
- /**
15048
- *
15049
- * Update an interpolated attribute on an element with 4 bound values surrounded by text.
15050
- *
15051
- * Used when the value passed to a property has 4 interpolated values in it:
14314
+ * Used when the value passed to a property has 4 interpolated values in it:
15052
14315
  *
15053
14316
  * ```html
15054
14317
  * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}suffix"></div>
@@ -15324,26 +14587,77 @@ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
15324
14587
  * Use of this source code is governed by an MIT-style license that can be
15325
14588
  * found in the LICENSE file at https://angular.io/license
15326
14589
  */
15327
- function templateFirstCreatePass(index, tView, lView, templateFn, decls, vars, tagName, attrsIndex, localRefsIndex) {
15328
- ngDevMode && assertFirstCreatePass(tView);
15329
- ngDevMode && ngDevMode.firstCreatePass++;
15330
- const tViewConsts = tView.consts;
15331
- // TODO(pk): refactor getOrCreateTNode to have the "create" only version
15332
- const tNode = getOrCreateTNode(tView, index, 4 /* TNodeType.Container */, tagName || null, getConstant(tViewConsts, attrsIndex));
15333
- resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
15334
- registerPostOrderHooks(tView, tNode);
15335
- const embeddedTView = tNode.tViews = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
15336
- if (tView.queries !== null) {
15337
- tView.queries.template(tView, tNode);
15338
- embeddedTView.queries = tView.queries.embeddedTView(tNode);
15339
- }
15340
- return tNode;
15341
- }
15342
14590
  /**
15343
- * Creates an LContainer for an ng-template (dynamically-inserted view), e.g.
14591
+ * Synchronously perform change detection on a component (and possibly its sub-components).
15344
14592
  *
15345
- * <ng-template #foo>
15346
- * <div></div>
14593
+ * This function triggers change detection in a synchronous way on a component.
14594
+ *
14595
+ * @param component The component which the change detection should be performed on.
14596
+ */
14597
+ function detectChanges(component) {
14598
+ const view = getComponentViewByInstance(component);
14599
+ detectChangesInternal(view[TVIEW], view, component);
14600
+ }
14601
+ /**
14602
+ * Marks the component as dirty (needing change detection). Marking a component dirty will
14603
+ * schedule a change detection on it at some point in the future.
14604
+ *
14605
+ * Marking an already dirty component as dirty won't do anything. Only one outstanding change
14606
+ * detection can be scheduled per component tree.
14607
+ *
14608
+ * @param component Component to mark as dirty.
14609
+ */
14610
+ function markDirty(component) {
14611
+ ngDevMode && assertDefined(component, 'component');
14612
+ const rootView = markViewDirty(getComponentViewByInstance(component));
14613
+ ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
14614
+ scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
14615
+ }
14616
+ /**
14617
+ * Used to perform change detection on the whole application.
14618
+ *
14619
+ * This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
14620
+ * executes lifecycle hooks and conditionally checks components based on their
14621
+ * `ChangeDetectionStrategy` and dirtiness.
14622
+ *
14623
+ * The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
14624
+ * schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
14625
+ * single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
14626
+ * be changed when calling `renderComponent` and providing the `scheduler` option.
14627
+ */
14628
+ function tick(component) {
14629
+ const rootView = getRootView(component);
14630
+ const rootContext = rootView[CONTEXT];
14631
+ tickRootContext(rootContext);
14632
+ }
14633
+
14634
+ /**
14635
+ * @license
14636
+ * Copyright Google LLC All Rights Reserved.
14637
+ *
14638
+ * Use of this source code is governed by an MIT-style license that can be
14639
+ * found in the LICENSE file at https://angular.io/license
14640
+ */
14641
+ function templateFirstCreatePass(index, tView, lView, templateFn, decls, vars, tagName, attrsIndex, localRefsIndex) {
14642
+ ngDevMode && assertFirstCreatePass(tView);
14643
+ ngDevMode && ngDevMode.firstCreatePass++;
14644
+ const tViewConsts = tView.consts;
14645
+ // TODO(pk): refactor getOrCreateTNode to have the "create" only version
14646
+ const tNode = getOrCreateTNode(tView, index, 4 /* TNodeType.Container */, tagName || null, getConstant(tViewConsts, attrsIndex));
14647
+ resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
14648
+ registerPostOrderHooks(tView, tNode);
14649
+ const embeddedTView = tNode.tViews = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
14650
+ if (tView.queries !== null) {
14651
+ tView.queries.template(tView, tNode);
14652
+ embeddedTView.queries = tView.queries.embeddedTView(tNode);
14653
+ }
14654
+ return tNode;
14655
+ }
14656
+ /**
14657
+ * Creates an LContainer for an ng-template (dynamically-inserted view), e.g.
14658
+ *
14659
+ * <ng-template #foo>
14660
+ * <div></div>
15347
14661
  * </ng-template>
15348
14662
  *
15349
14663
  * @param index The index of the container in the data array
@@ -15861,51 +15175,42 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15861
15175
  tNode.index;
15862
15176
  // In order to match current behavior, native DOM event listeners must be added for all
15863
15177
  // events (including outputs).
15864
- if (isProceduralRenderer(renderer)) {
15865
- // There might be cases where multiple directives on the same element try to register an event
15866
- // handler function for the same event. In this situation we want to avoid registration of
15867
- // several native listeners as each registration would be intercepted by NgZone and
15868
- // trigger change detection. This would mean that a single user action would result in several
15869
- // change detections being invoked. To avoid this situation we want to have only one call to
15870
- // native handler registration (for the same element and same type of event).
15871
- //
15872
- // In order to have just one native event handler in presence of multiple handler functions,
15873
- // we just register a first handler function as a native event listener and then chain
15874
- // (coalesce) other handler functions on top of the first native handler function.
15875
- let existingListener = null;
15876
- // Please note that the coalescing described here doesn't happen for events specifying an
15877
- // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15878
- // view engine.
15879
- // Also, we don't have to search for existing listeners is there are no directives
15880
- // matching on a given node as we can't register multiple event handlers for the same event in
15881
- // a template (this would mean having duplicate attributes).
15882
- if (!eventTargetResolver && isTNodeDirectiveHost) {
15883
- existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15884
- }
15885
- if (existingListener !== null) {
15886
- // Attach a new listener to coalesced listeners list, maintaining the order in which
15887
- // listeners are registered. For performance reasons, we keep a reference to the last
15888
- // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15889
- // the entire set each time we need to add a new listener.
15890
- const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15891
- lastListenerFn.__ngNextListenerFn__ = listenerFn;
15892
- existingListener.__ngLastListenerFn__ = listenerFn;
15893
- processOutputs = false;
15894
- }
15895
- else {
15896
- listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15897
- const cleanupFn = renderer.listen(target, eventName, listenerFn);
15898
- ngDevMode && ngDevMode.rendererAddEventListener++;
15899
- lCleanup.push(listenerFn, cleanupFn);
15900
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15901
- }
15178
+ // There might be cases where multiple directives on the same element try to register an event
15179
+ // handler function for the same event. In this situation we want to avoid registration of
15180
+ // several native listeners as each registration would be intercepted by NgZone and
15181
+ // trigger change detection. This would mean that a single user action would result in several
15182
+ // change detections being invoked. To avoid this situation we want to have only one call to
15183
+ // native handler registration (for the same element and same type of event).
15184
+ //
15185
+ // In order to have just one native event handler in presence of multiple handler functions,
15186
+ // we just register a first handler function as a native event listener and then chain
15187
+ // (coalesce) other handler functions on top of the first native handler function.
15188
+ let existingListener = null;
15189
+ // Please note that the coalescing described here doesn't happen for events specifying an
15190
+ // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15191
+ // view engine.
15192
+ // Also, we don't have to search for existing listeners is there are no directives
15193
+ // matching on a given node as we can't register multiple event handlers for the same event in
15194
+ // a template (this would mean having duplicate attributes).
15195
+ if (!eventTargetResolver && isTNodeDirectiveHost) {
15196
+ existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15197
+ }
15198
+ if (existingListener !== null) {
15199
+ // Attach a new listener to coalesced listeners list, maintaining the order in which
15200
+ // listeners are registered. For performance reasons, we keep a reference to the last
15201
+ // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15202
+ // the entire set each time we need to add a new listener.
15203
+ const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15204
+ lastListenerFn.__ngNextListenerFn__ = listenerFn;
15205
+ existingListener.__ngLastListenerFn__ = listenerFn;
15206
+ processOutputs = false;
15902
15207
  }
15903
15208
  else {
15904
- listenerFn = wrapListener(tNode, lView, context, listenerFn, true /** preventDefault */);
15905
- target.addEventListener(eventName, listenerFn, useCapture);
15209
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15210
+ const cleanupFn = renderer.listen(target, eventName, listenerFn);
15906
15211
  ngDevMode && ngDevMode.rendererAddEventListener++;
15907
- lCleanup.push(listenerFn);
15908
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, useCapture);
15212
+ lCleanup.push(listenerFn, cleanupFn);
15213
+ tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15909
15214
  }
15910
15215
  }
15911
15216
  else {
@@ -17979,7 +17284,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
17979
17284
  valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
17980
17285
  }
17981
17286
  let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
17982
- key === prop ? valueAtLViewIndex : undefined;
17287
+ (key === prop ? valueAtLViewIndex : undefined);
17983
17288
  if (containsStatics && !isStylingValuePresent(currentValue)) {
17984
17289
  currentValue = keyValueArrayGet(rawKey, prop);
17985
17290
  }
@@ -21832,7 +21137,7 @@ function noComponentFactoryError(component) {
21832
21137
  return error;
21833
21138
  }
21834
21139
  const ERROR_COMPONENT = 'ngComponent';
21835
- function getComponent(error) {
21140
+ function getComponent$1(error) {
21836
21141
  return error[ERROR_COMPONENT];
21837
21142
  }
21838
21143
  class _NullComponentFactoryResolver {
@@ -22016,14 +21321,6 @@ class Renderer2 {
22016
21321
  * @nocollapse
22017
21322
  */
22018
21323
  Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
22019
- /** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */
22020
- function getOrCreateRenderer2(lView) {
22021
- const renderer = lView[RENDERER];
22022
- if (ngDevMode && !isProceduralRenderer(renderer)) {
22023
- throw new Error('Cannot inject Renderer2 when the application uses Renderer3!');
22024
- }
22025
- return renderer;
22026
- }
22027
21324
  /** Injects a Renderer2 for the current component. */
22028
21325
  function injectRenderer2() {
22029
21326
  // We need the Renderer to be based on the component that it's being injected into, however since
@@ -22031,7 +21328,7 @@ function injectRenderer2() {
22031
21328
  const lView = getLView();
22032
21329
  const tNode = getCurrentTNode();
22033
21330
  const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
22034
- return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
21331
+ return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
22035
21332
  }
22036
21333
 
22037
21334
  /**
@@ -22078,7 +21375,7 @@ class Version {
22078
21375
  /**
22079
21376
  * @publicApi
22080
21377
  */
22081
- const VERSION = new Version('14.0.4');
21378
+ const VERSION = new Version('14.0.5');
22082
21379
 
22083
21380
  /**
22084
21381
  * @license
@@ -22424,31 +21721,407 @@ class ViewRef {
22424
21721
  this._appRef = null;
22425
21722
  renderDetachView(this._lView[TVIEW], this._lView);
22426
21723
  }
22427
- attachToAppRef(appRef) {
22428
- if (this._attachedToViewContainer) {
22429
- throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
22430
- }
22431
- this._appRef = appRef;
21724
+ attachToAppRef(appRef) {
21725
+ if (this._attachedToViewContainer) {
21726
+ throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
21727
+ }
21728
+ this._appRef = appRef;
21729
+ }
21730
+ }
21731
+ /** @internal */
21732
+ class RootViewRef extends ViewRef {
21733
+ constructor(_view) {
21734
+ super(_view);
21735
+ this._view = _view;
21736
+ }
21737
+ detectChanges() {
21738
+ detectChangesInRootView(this._view);
21739
+ }
21740
+ checkNoChanges() {
21741
+ if (ngDevMode) {
21742
+ checkNoChangesInRootView(this._view);
21743
+ }
21744
+ }
21745
+ get context() {
21746
+ return null;
21747
+ }
21748
+ }
21749
+
21750
+ /**
21751
+ * @license
21752
+ * Copyright Google LLC All Rights Reserved.
21753
+ *
21754
+ * Use of this source code is governed by an MIT-style license that can be
21755
+ * found in the LICENSE file at https://angular.io/license
21756
+ */
21757
+ class ComponentFactoryResolver extends ComponentFactoryResolver$1 {
21758
+ /**
21759
+ * @param ngModule The NgModuleRef to which all resolved factories are bound.
21760
+ */
21761
+ constructor(ngModule) {
21762
+ super();
21763
+ this.ngModule = ngModule;
21764
+ }
21765
+ resolveComponentFactory(component) {
21766
+ ngDevMode && assertComponentType(component);
21767
+ const componentDef = getComponentDef$1(component);
21768
+ return new ComponentFactory(componentDef, this.ngModule);
21769
+ }
21770
+ }
21771
+ function toRefArray(map) {
21772
+ const array = [];
21773
+ for (let nonMinified in map) {
21774
+ if (map.hasOwnProperty(nonMinified)) {
21775
+ const minified = map[nonMinified];
21776
+ array.push({ propName: minified, templateName: nonMinified });
21777
+ }
21778
+ }
21779
+ return array;
21780
+ }
21781
+ function getNamespace(elementName) {
21782
+ const name = elementName.toLowerCase();
21783
+ return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
21784
+ }
21785
+ /**
21786
+ * Injector that looks up a value using a specific injector, before falling back to the module
21787
+ * injector. Used primarily when creating components or embedded views dynamically.
21788
+ */
21789
+ class ChainedInjector {
21790
+ constructor(injector, parentInjector) {
21791
+ this.injector = injector;
21792
+ this.parentInjector = parentInjector;
21793
+ }
21794
+ get(token, notFoundValue, flags) {
21795
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21796
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21797
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21798
+ // Return the value from the root element injector when
21799
+ // - it provides it
21800
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21801
+ // - the module injector should not be checked
21802
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21803
+ return value;
21804
+ }
21805
+ return this.parentInjector.get(token, notFoundValue, flags);
21806
+ }
21807
+ }
21808
+ /**
21809
+ * Render3 implementation of {@link viewEngine_ComponentFactory}.
21810
+ */
21811
+ class ComponentFactory extends ComponentFactory$1 {
21812
+ /**
21813
+ * @param componentDef The component definition.
21814
+ * @param ngModule The NgModuleRef to which the factory is bound.
21815
+ */
21816
+ constructor(componentDef, ngModule) {
21817
+ super();
21818
+ this.componentDef = componentDef;
21819
+ this.ngModule = ngModule;
21820
+ this.componentType = componentDef.type;
21821
+ this.selector = stringifyCSSSelectorList(componentDef.selectors);
21822
+ this.ngContentSelectors =
21823
+ componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
21824
+ this.isBoundToModule = !!ngModule;
21825
+ }
21826
+ get inputs() {
21827
+ return toRefArray(this.componentDef.inputs);
21828
+ }
21829
+ get outputs() {
21830
+ return toRefArray(this.componentDef.outputs);
21831
+ }
21832
+ create(injector, projectableNodes, rootSelectorOrNode, environmentInjector) {
21833
+ environmentInjector = environmentInjector || this.ngModule;
21834
+ let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ?
21835
+ environmentInjector :
21836
+ environmentInjector?.injector;
21837
+ if (realEnvironmentInjector && this.componentDef.getStandaloneInjector !== null) {
21838
+ realEnvironmentInjector = this.componentDef.getStandaloneInjector(realEnvironmentInjector) ||
21839
+ realEnvironmentInjector;
21840
+ }
21841
+ const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
21842
+ const rendererFactory = rootViewInjector.get(RendererFactory2, null);
21843
+ if (rendererFactory === null) {
21844
+ throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
21845
+ 'Angular was not able to inject a renderer (RendererFactory2). ' +
21846
+ 'Likely this is due to a broken DI hierarchy. ' +
21847
+ 'Make sure that any injector used to create this component has a correct parent.');
21848
+ }
21849
+ const sanitizer = rootViewInjector.get(Sanitizer, null);
21850
+ const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
21851
+ // Determine a tag name used for creating host elements when this component is created
21852
+ // dynamically. Default to 'div' if this component did not specify any tag name in its selector.
21853
+ const elementName = this.componentDef.selectors[0][0] || 'div';
21854
+ const hostRNode = rootSelectorOrNode ?
21855
+ locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) :
21856
+ createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
21857
+ const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
21858
+ 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
21859
+ const rootContext = createRootContext();
21860
+ // Create the root view. Uses empty TView and ContentTemplate.
21861
+ const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
21862
+ const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
21863
+ // rootView is the parent when bootstrapping
21864
+ // TODO(misko): it looks like we are entering view here but we don't really need to as
21865
+ // `renderView` does that. However as the code is written it is needed because
21866
+ // `createRootComponentView` and `createRootComponent` both read global state. Fixing those
21867
+ // issues would allow us to drop this.
21868
+ enterView(rootLView);
21869
+ let component;
21870
+ let tElementNode;
21871
+ try {
21872
+ const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
21873
+ if (hostRNode) {
21874
+ if (rootSelectorOrNode) {
21875
+ setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
21876
+ }
21877
+ else {
21878
+ // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
21879
+ // is not defined), also apply attributes and classes extracted from component selector.
21880
+ // Extract attributes and classes from the first selector only to match VE behavior.
21881
+ const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
21882
+ if (attrs) {
21883
+ setUpAttributes(hostRenderer, hostRNode, attrs);
21884
+ }
21885
+ if (classes && classes.length > 0) {
21886
+ writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
21887
+ }
21888
+ }
21889
+ }
21890
+ tElementNode = getTNode(rootTView, HEADER_OFFSET);
21891
+ if (projectableNodes !== undefined) {
21892
+ const projection = tElementNode.projection = [];
21893
+ for (let i = 0; i < this.ngContentSelectors.length; i++) {
21894
+ const nodesforSlot = projectableNodes[i];
21895
+ // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
21896
+ // case). Here we do normalize passed data structure to be an array of arrays to avoid
21897
+ // complex checks down the line.
21898
+ // We also normalize the length of the passed in projectable nodes (to match the number of
21899
+ // <ng-container> slots defined by a component).
21900
+ projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
21901
+ }
21902
+ }
21903
+ // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
21904
+ // executed here?
21905
+ // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
21906
+ component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
21907
+ renderView(rootTView, rootLView, null);
21908
+ }
21909
+ finally {
21910
+ leaveView();
21911
+ }
21912
+ return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
21913
+ }
21914
+ }
21915
+ const componentFactoryResolver = new ComponentFactoryResolver();
21916
+ /**
21917
+ * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
21918
+ * ComponentFactoryResolver
21919
+ * already exists, retrieves the existing ComponentFactoryResolver.
21920
+ *
21921
+ * @returns The ComponentFactoryResolver instance to use
21922
+ */
21923
+ function injectComponentFactoryResolver() {
21924
+ return componentFactoryResolver;
21925
+ }
21926
+ /**
21927
+ * Represents an instance of a Component created via a {@link ComponentFactory}.
21928
+ *
21929
+ * `ComponentRef` provides access to the Component Instance as well other objects related to this
21930
+ * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
21931
+ * method.
21932
+ *
21933
+ */
21934
+ class ComponentRef extends ComponentRef$1 {
21935
+ constructor(componentType, instance, location, _rootLView, _tNode) {
21936
+ super();
21937
+ this.location = location;
21938
+ this._rootLView = _rootLView;
21939
+ this._tNode = _tNode;
21940
+ this.instance = instance;
21941
+ this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
21942
+ this.componentType = componentType;
21943
+ }
21944
+ get injector() {
21945
+ return new NodeInjector(this._tNode, this._rootLView);
21946
+ }
21947
+ destroy() {
21948
+ this.hostView.destroy();
21949
+ }
21950
+ onDestroy(callback) {
21951
+ this.hostView.onDestroy(callback);
21952
+ }
21953
+ }
21954
+
21955
+ /**
21956
+ * @license
21957
+ * Copyright Google LLC All Rights Reserved.
21958
+ *
21959
+ * Use of this source code is governed by an MIT-style license that can be
21960
+ * found in the LICENSE file at https://angular.io/license
21961
+ */
21962
+ /**
21963
+ * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
21964
+ * @param ngModule NgModule class.
21965
+ * @param parentInjector Optional injector instance to use as a parent for the module injector. If
21966
+ * not provided, `NullInjector` will be used instead.
21967
+ * @publicApi
21968
+ */
21969
+ function createNgModuleRef(ngModule, parentInjector) {
21970
+ return new NgModuleRef(ngModule, parentInjector ?? null);
21971
+ }
21972
+ class NgModuleRef extends NgModuleRef$1 {
21973
+ constructor(ngModuleType, _parent) {
21974
+ super();
21975
+ this._parent = _parent;
21976
+ // tslint:disable-next-line:require-internal-with-underscore
21977
+ this._bootstrapComponents = [];
21978
+ this.injector = this;
21979
+ this.destroyCbs = [];
21980
+ // When bootstrapping a module we have a dependency graph that looks like this:
21981
+ // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
21982
+ // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
21983
+ // circular dependency which will result in a runtime error, because the injector doesn't
21984
+ // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
21985
+ // and providing it, rather than letting the injector resolve it.
21986
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
21987
+ const ngModuleDef = getNgModuleDef(ngModuleType);
21988
+ ngDevMode &&
21989
+ assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
21990
+ this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
21991
+ this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
21992
+ { provide: NgModuleRef$1, useValue: this }, {
21993
+ provide: ComponentFactoryResolver$1,
21994
+ useValue: this.componentFactoryResolver
21995
+ }
21996
+ ], stringify(ngModuleType), new Set(['environment']));
21997
+ // We need to resolve the injector types separately from the injector creation, because
21998
+ // the module might be trying to use this ref in its constructor for DI which will cause a
21999
+ // circular error that will eventually error out, because the injector isn't created yet.
22000
+ this._r3Injector.resolveInjectorInitializers();
22001
+ this.instance = this.get(ngModuleType);
22002
+ }
22003
+ get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
22004
+ if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
22005
+ return this;
22006
+ }
22007
+ return this._r3Injector.get(token, notFoundValue, injectFlags);
22008
+ }
22009
+ destroy() {
22010
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22011
+ const injector = this._r3Injector;
22012
+ !injector.destroyed && injector.destroy();
22013
+ this.destroyCbs.forEach(fn => fn());
22014
+ this.destroyCbs = null;
22015
+ }
22016
+ onDestroy(callback) {
22017
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22018
+ this.destroyCbs.push(callback);
22019
+ }
22020
+ }
22021
+ class NgModuleFactory extends NgModuleFactory$1 {
22022
+ constructor(moduleType) {
22023
+ super();
22024
+ this.moduleType = moduleType;
22025
+ }
22026
+ create(parentInjector) {
22027
+ return new NgModuleRef(this.moduleType, parentInjector);
22432
22028
  }
22433
22029
  }
22434
- /** @internal */
22435
- class RootViewRef extends ViewRef {
22436
- constructor(_view) {
22437
- super(_view);
22438
- this._view = _view;
22030
+ class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22031
+ constructor(providers, parent, source) {
22032
+ super();
22033
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
22034
+ this.instance = null;
22035
+ const injector = new R3Injector([
22036
+ ...providers,
22037
+ { provide: NgModuleRef$1, useValue: this },
22038
+ { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22039
+ ], parent || getNullInjector(), source, new Set(['environment']));
22040
+ this.injector = injector;
22041
+ injector.resolveInjectorInitializers();
22439
22042
  }
22440
- detectChanges() {
22441
- detectChangesInRootView(this._view);
22043
+ destroy() {
22044
+ this.injector.destroy();
22442
22045
  }
22443
- checkNoChanges() {
22444
- if (ngDevMode) {
22445
- checkNoChangesInRootView(this._view);
22046
+ onDestroy(callback) {
22047
+ this.injector.onDestroy(callback);
22048
+ }
22049
+ }
22050
+ /**
22051
+ * Create a new environment injector.
22052
+ *
22053
+ * @publicApi
22054
+ * @developerPreview
22055
+ */
22056
+ function createEnvironmentInjector(providers, parent = null, debugName = null) {
22057
+ const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22058
+ return adapter.injector;
22059
+ }
22060
+
22061
+ /**
22062
+ * @license
22063
+ * Copyright Google LLC All Rights Reserved.
22064
+ *
22065
+ * Use of this source code is governed by an MIT-style license that can be
22066
+ * found in the LICENSE file at https://angular.io/license
22067
+ */
22068
+ /**
22069
+ * A service used by the framework to create instances of standalone injectors. Those injectors are
22070
+ * created on demand in case of dynamic component instantiation and contain ambient providers
22071
+ * collected from the imports graph rooted at a given standalone component.
22072
+ */
22073
+ class StandaloneService {
22074
+ constructor(_injector) {
22075
+ this._injector = _injector;
22076
+ this.cachedInjectors = new Map();
22077
+ }
22078
+ getOrCreateStandaloneInjector(componentDef) {
22079
+ if (!componentDef.standalone) {
22080
+ return null;
22081
+ }
22082
+ if (!this.cachedInjectors.has(componentDef.id)) {
22083
+ const providers = internalImportProvidersFrom(false, componentDef.type);
22084
+ const standaloneInjector = providers.length > 0 ?
22085
+ createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22086
+ null;
22087
+ this.cachedInjectors.set(componentDef.id, standaloneInjector);
22446
22088
  }
22089
+ return this.cachedInjectors.get(componentDef.id);
22447
22090
  }
22448
- get context() {
22449
- return null;
22091
+ ngOnDestroy() {
22092
+ try {
22093
+ for (const injector of this.cachedInjectors.values()) {
22094
+ if (injector !== null) {
22095
+ injector.destroy();
22096
+ }
22097
+ }
22098
+ }
22099
+ finally {
22100
+ this.cachedInjectors.clear();
22101
+ }
22450
22102
  }
22451
22103
  }
22104
+ /** @nocollapse */
22105
+ StandaloneService.ɵprov = ɵɵdefineInjectable({
22106
+ token: StandaloneService,
22107
+ providedIn: 'environment',
22108
+ factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22109
+ });
22110
+ /**
22111
+ * A feature that acts as a setup code for the {@link StandaloneService}.
22112
+ *
22113
+ * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
22114
+ * function (an entry points to a standalone injector creation) on a component definition object. We
22115
+ * go through the features infrastructure to make sure that the standalone injector creation logic
22116
+ * is tree-shakable and not included in applications that don't use standalone components.
22117
+ *
22118
+ * @codeGenApi
22119
+ */
22120
+ function ɵɵStandaloneFeature(definition) {
22121
+ definition.getStandaloneInjector = (parentInjector) => {
22122
+ return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22123
+ };
22124
+ }
22452
22125
 
22453
22126
  /**
22454
22127
  * @license
@@ -22457,367 +22130,407 @@ class RootViewRef extends ViewRef {
22457
22130
  * Use of this source code is governed by an MIT-style license that can be
22458
22131
  * found in the LICENSE file at https://angular.io/license
22459
22132
  */
22460
- class ComponentFactoryResolver extends ComponentFactoryResolver$1 {
22461
- /**
22462
- * @param ngModule The NgModuleRef to which all resolved factories are bound.
22463
- */
22464
- constructor(ngModule) {
22465
- super();
22466
- this.ngModule = ngModule;
22133
+ /**
22134
+ * Retrieves the component instance associated with a given DOM element.
22135
+ *
22136
+ * @usageNotes
22137
+ * Given the following DOM structure:
22138
+ *
22139
+ * ```html
22140
+ * <app-root>
22141
+ * <div>
22142
+ * <child-comp></child-comp>
22143
+ * </div>
22144
+ * </app-root>
22145
+ * ```
22146
+ *
22147
+ * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
22148
+ * associated with this DOM element.
22149
+ *
22150
+ * Calling the function on `<app-root>` will return the `MyApp` instance.
22151
+ *
22152
+ *
22153
+ * @param element DOM element from which the component should be retrieved.
22154
+ * @returns Component instance associated with the element or `null` if there
22155
+ * is no component associated with it.
22156
+ *
22157
+ * @publicApi
22158
+ * @globalApi ng
22159
+ */
22160
+ function getComponent(element) {
22161
+ ngDevMode && assertDomElement(element);
22162
+ const context = getLContext(element);
22163
+ if (context === null)
22164
+ return null;
22165
+ if (context.component === undefined) {
22166
+ const lView = context.lView;
22167
+ if (lView === null) {
22168
+ return null;
22169
+ }
22170
+ context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
22467
22171
  }
22468
- resolveComponentFactory(component) {
22469
- ngDevMode && assertComponentType(component);
22470
- const componentDef = getComponentDef$1(component);
22471
- return new ComponentFactory(componentDef, this.ngModule);
22172
+ return context.component;
22173
+ }
22174
+ /**
22175
+ * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
22176
+ * view that the element is part of. Otherwise retrieves the instance of the component whose view
22177
+ * owns the element (in this case, the result is the same as calling `getOwningComponent`).
22178
+ *
22179
+ * @param element Element for which to get the surrounding component instance.
22180
+ * @returns Instance of the component that is around the element or null if the element isn't
22181
+ * inside any component.
22182
+ *
22183
+ * @publicApi
22184
+ * @globalApi ng
22185
+ */
22186
+ function getContext(element) {
22187
+ assertDomElement(element);
22188
+ const context = getLContext(element);
22189
+ const lView = context ? context.lView : null;
22190
+ return lView === null ? null : lView[CONTEXT];
22191
+ }
22192
+ /**
22193
+ * Retrieves the component instance whose view contains the DOM element.
22194
+ *
22195
+ * For example, if `<child-comp>` is used in the template of `<app-comp>`
22196
+ * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
22197
+ * would return `<app-comp>`.
22198
+ *
22199
+ * @param elementOrDir DOM element, component or directive instance
22200
+ * for which to retrieve the root components.
22201
+ * @returns Component instance whose view owns the DOM element or null if the element is not
22202
+ * part of a component view.
22203
+ *
22204
+ * @publicApi
22205
+ * @globalApi ng
22206
+ */
22207
+ function getOwningComponent(elementOrDir) {
22208
+ const context = getLContext(elementOrDir);
22209
+ let lView = context ? context.lView : null;
22210
+ if (lView === null)
22211
+ return null;
22212
+ let parent;
22213
+ while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
22214
+ lView = parent;
22472
22215
  }
22216
+ return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
22473
22217
  }
22474
- function toRefArray(map) {
22475
- const array = [];
22476
- for (let nonMinified in map) {
22477
- if (map.hasOwnProperty(nonMinified)) {
22478
- const minified = map[nonMinified];
22479
- array.push({ propName: minified, templateName: nonMinified });
22218
+ /**
22219
+ * Retrieves all root components associated with a DOM element, directive or component instance.
22220
+ * Root components are those which have been bootstrapped by Angular.
22221
+ *
22222
+ * @param elementOrDir DOM element, component or directive instance
22223
+ * for which to retrieve the root components.
22224
+ * @returns Root components associated with the target object.
22225
+ *
22226
+ * @publicApi
22227
+ * @globalApi ng
22228
+ */
22229
+ function getRootComponents(elementOrDir) {
22230
+ const lView = readPatchedLView(elementOrDir);
22231
+ return lView !== null ? [...getRootContext(lView).components] : [];
22232
+ }
22233
+ /**
22234
+ * Retrieves an `Injector` associated with an element, component or directive instance.
22235
+ *
22236
+ * @param elementOrDir DOM element, component or directive instance for which to
22237
+ * retrieve the injector.
22238
+ * @returns Injector associated with the element, component or directive instance.
22239
+ *
22240
+ * @publicApi
22241
+ * @globalApi ng
22242
+ */
22243
+ function getInjector(elementOrDir) {
22244
+ const context = getLContext(elementOrDir);
22245
+ const lView = context ? context.lView : null;
22246
+ if (lView === null)
22247
+ return Injector.NULL;
22248
+ const tNode = lView[TVIEW].data[context.nodeIndex];
22249
+ return new NodeInjector(tNode, lView);
22250
+ }
22251
+ /**
22252
+ * Retrieve a set of injection tokens at a given DOM node.
22253
+ *
22254
+ * @param element Element for which the injection tokens should be retrieved.
22255
+ */
22256
+ function getInjectionTokens(element) {
22257
+ const context = getLContext(element);
22258
+ const lView = context ? context.lView : null;
22259
+ if (lView === null)
22260
+ return [];
22261
+ const tView = lView[TVIEW];
22262
+ const tNode = tView.data[context.nodeIndex];
22263
+ const providerTokens = [];
22264
+ const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
22265
+ const endIndex = tNode.directiveEnd;
22266
+ for (let i = startIndex; i < endIndex; i++) {
22267
+ let value = tView.data[i];
22268
+ if (isDirectiveDefHack(value)) {
22269
+ // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
22270
+ // design flaw. We should always store same type so that we can be monomorphic. The issue
22271
+ // is that for Components/Directives we store the def instead the type. The correct behavior
22272
+ // is that we should always be storing injectable type in this location.
22273
+ value = value.type;
22480
22274
  }
22275
+ providerTokens.push(value);
22481
22276
  }
22482
- return array;
22483
- }
22484
- function getNamespace(elementName) {
22485
- const name = elementName.toLowerCase();
22486
- return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
22277
+ return providerTokens;
22487
22278
  }
22488
22279
  /**
22489
- * Injector that looks up a value using a specific injector, before falling back to the module
22490
- * injector. Used primarily when creating components or embedded views dynamically.
22280
+ * Retrieves directive instances associated with a given DOM node. Does not include
22281
+ * component instances.
22282
+ *
22283
+ * @usageNotes
22284
+ * Given the following DOM structure:
22285
+ *
22286
+ * ```html
22287
+ * <app-root>
22288
+ * <button my-button></button>
22289
+ * <my-comp></my-comp>
22290
+ * </app-root>
22291
+ * ```
22292
+ *
22293
+ * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
22294
+ * directive that is associated with the DOM node.
22295
+ *
22296
+ * Calling `getDirectives` on `<my-comp>` will return an empty array.
22297
+ *
22298
+ * @param node DOM node for which to get the directives.
22299
+ * @returns Array of directives associated with the node.
22300
+ *
22301
+ * @publicApi
22302
+ * @globalApi ng
22491
22303
  */
22492
- class ChainedInjector {
22493
- constructor(injector, parentInjector) {
22494
- this.injector = injector;
22495
- this.parentInjector = parentInjector;
22304
+ function getDirectives(node) {
22305
+ // Skip text nodes because we can't have directives associated with them.
22306
+ if (node instanceof Text) {
22307
+ return [];
22496
22308
  }
22497
- get(token, notFoundValue, flags) {
22498
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
22499
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
22500
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
22501
- // Return the value from the root element injector when
22502
- // - it provides it
22503
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
22504
- // - the module injector should not be checked
22505
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
22506
- return value;
22507
- }
22508
- return this.parentInjector.get(token, notFoundValue, flags);
22309
+ const context = getLContext(node);
22310
+ const lView = context ? context.lView : null;
22311
+ if (lView === null) {
22312
+ return [];
22313
+ }
22314
+ const tView = lView[TVIEW];
22315
+ const nodeIndex = context.nodeIndex;
22316
+ if (!tView?.data[nodeIndex]) {
22317
+ return [];
22318
+ }
22319
+ if (context.directives === undefined) {
22320
+ context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
22509
22321
  }
22322
+ // The `directives` in this case are a named array called `LComponentView`. Clone the
22323
+ // result so we don't expose an internal data structure in the user's console.
22324
+ return context.directives === null ? [] : [...context.directives];
22510
22325
  }
22511
22326
  /**
22512
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
22327
+ * Returns the debug (partial) metadata for a particular directive or component instance.
22328
+ * The function accepts an instance of a directive or component and returns the corresponding
22329
+ * metadata.
22330
+ *
22331
+ * @param directiveOrComponentInstance Instance of a directive or component
22332
+ * @returns metadata of the passed directive or component
22333
+ *
22334
+ * @publicApi
22335
+ * @globalApi ng
22513
22336
  */
22514
- class ComponentFactory extends ComponentFactory$1 {
22515
- /**
22516
- * @param componentDef The component definition.
22517
- * @param ngModule The NgModuleRef to which the factory is bound.
22518
- */
22519
- constructor(componentDef, ngModule) {
22520
- super();
22521
- this.componentDef = componentDef;
22522
- this.ngModule = ngModule;
22523
- this.componentType = componentDef.type;
22524
- this.selector = stringifyCSSSelectorList(componentDef.selectors);
22525
- this.ngContentSelectors =
22526
- componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
22527
- this.isBoundToModule = !!ngModule;
22528
- }
22529
- get inputs() {
22530
- return toRefArray(this.componentDef.inputs);
22337
+ function getDirectiveMetadata(directiveOrComponentInstance) {
22338
+ const { constructor } = directiveOrComponentInstance;
22339
+ if (!constructor) {
22340
+ throw new Error('Unable to find the instance constructor');
22531
22341
  }
22532
- get outputs() {
22533
- return toRefArray(this.componentDef.outputs);
22342
+ // In case a component inherits from a directive, we may have component and directive metadata
22343
+ // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
22344
+ const componentDef = getComponentDef$1(constructor);
22345
+ if (componentDef) {
22346
+ return {
22347
+ inputs: componentDef.inputs,
22348
+ outputs: componentDef.outputs,
22349
+ encapsulation: componentDef.encapsulation,
22350
+ changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
22351
+ ChangeDetectionStrategy.Default
22352
+ };
22534
22353
  }
22535
- create(injector, projectableNodes, rootSelectorOrNode, environmentInjector) {
22536
- environmentInjector = environmentInjector || this.ngModule;
22537
- let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ?
22538
- environmentInjector :
22539
- environmentInjector?.injector;
22540
- if (realEnvironmentInjector && this.componentDef.getStandaloneInjector !== null) {
22541
- realEnvironmentInjector = this.componentDef.getStandaloneInjector(realEnvironmentInjector) ||
22542
- realEnvironmentInjector;
22543
- }
22544
- const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
22545
- const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
22546
- const sanitizer = rootViewInjector.get(Sanitizer, null);
22547
- const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
22548
- // Determine a tag name used for creating host elements when this component is created
22549
- // dynamically. Default to 'div' if this component did not specify any tag name in its selector.
22550
- const elementName = this.componentDef.selectors[0][0] || 'div';
22551
- const hostRNode = rootSelectorOrNode ?
22552
- locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) :
22553
- createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
22554
- const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
22555
- 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
22556
- const rootContext = createRootContext();
22557
- // Create the root view. Uses empty TView and ContentTemplate.
22558
- const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
22559
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
22560
- // rootView is the parent when bootstrapping
22561
- // TODO(misko): it looks like we are entering view here but we don't really need to as
22562
- // `renderView` does that. However as the code is written it is needed because
22563
- // `createRootComponentView` and `createRootComponent` both read global state. Fixing those
22564
- // issues would allow us to drop this.
22565
- enterView(rootLView);
22566
- let component;
22567
- let tElementNode;
22568
- try {
22569
- const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
22570
- if (hostRNode) {
22571
- if (rootSelectorOrNode) {
22572
- setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
22573
- }
22574
- else {
22575
- // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
22576
- // is not defined), also apply attributes and classes extracted from component selector.
22577
- // Extract attributes and classes from the first selector only to match VE behavior.
22578
- const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
22579
- if (attrs) {
22580
- setUpAttributes(hostRenderer, hostRNode, attrs);
22581
- }
22582
- if (classes && classes.length > 0) {
22583
- writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
22584
- }
22585
- }
22586
- }
22587
- tElementNode = getTNode(rootTView, HEADER_OFFSET);
22588
- if (projectableNodes !== undefined) {
22589
- const projection = tElementNode.projection = [];
22590
- for (let i = 0; i < this.ngContentSelectors.length; i++) {
22591
- const nodesforSlot = projectableNodes[i];
22592
- // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
22593
- // case). Here we do normalize passed data structure to be an array of arrays to avoid
22594
- // complex checks down the line.
22595
- // We also normalize the length of the passed in projectable nodes (to match the number of
22596
- // <ng-container> slots defined by a component).
22597
- projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
22598
- }
22599
- }
22600
- // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
22601
- // executed here?
22602
- // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
22603
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
22604
- renderView(rootTView, rootLView, null);
22605
- }
22606
- finally {
22607
- leaveView();
22608
- }
22609
- return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
22354
+ const directiveDef = getDirectiveDef(constructor);
22355
+ if (directiveDef) {
22356
+ return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
22610
22357
  }
22358
+ return null;
22611
22359
  }
22612
- const componentFactoryResolver = new ComponentFactoryResolver();
22613
22360
  /**
22614
- * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
22615
- * ComponentFactoryResolver
22616
- * already exists, retrieves the existing ComponentFactoryResolver.
22361
+ * Retrieve map of local references.
22617
22362
  *
22618
- * @returns The ComponentFactoryResolver instance to use
22363
+ * The references are retrieved as a map of local reference name to element or directive instance.
22364
+ *
22365
+ * @param target DOM element, component or directive instance for which to retrieve
22366
+ * the local references.
22619
22367
  */
22620
- function injectComponentFactoryResolver() {
22621
- return componentFactoryResolver;
22368
+ function getLocalRefs(target) {
22369
+ const context = getLContext(target);
22370
+ if (context === null)
22371
+ return {};
22372
+ if (context.localRefs === undefined) {
22373
+ const lView = context.lView;
22374
+ if (lView === null) {
22375
+ return {};
22376
+ }
22377
+ context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
22378
+ }
22379
+ return context.localRefs || {};
22622
22380
  }
22623
22381
  /**
22624
- * Represents an instance of a Component created via a {@link ComponentFactory}.
22382
+ * Retrieves the host element of a component or directive instance.
22383
+ * The host element is the DOM element that matched the selector of the directive.
22625
22384
  *
22626
- * `ComponentRef` provides access to the Component Instance as well other objects related to this
22627
- * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
22628
- * method.
22385
+ * @param componentOrDirective Component or directive instance for which the host
22386
+ * element should be retrieved.
22387
+ * @returns Host element of the target.
22629
22388
  *
22389
+ * @publicApi
22390
+ * @globalApi ng
22630
22391
  */
22631
- class ComponentRef extends ComponentRef$1 {
22632
- constructor(componentType, instance, location, _rootLView, _tNode) {
22633
- super();
22634
- this.location = location;
22635
- this._rootLView = _rootLView;
22636
- this._tNode = _tNode;
22637
- this.instance = instance;
22638
- this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
22639
- this.componentType = componentType;
22640
- }
22641
- get injector() {
22642
- return new NodeInjector(this._tNode, this._rootLView);
22643
- }
22644
- destroy() {
22645
- this.hostView.destroy();
22646
- }
22647
- onDestroy(callback) {
22648
- this.hostView.onDestroy(callback);
22649
- }
22392
+ function getHostElement(componentOrDirective) {
22393
+ return getLContext(componentOrDirective).native;
22650
22394
  }
22651
-
22652
22395
  /**
22653
- * @license
22654
- * Copyright Google LLC All Rights Reserved.
22396
+ * Retrieves the rendered text for a given component.
22655
22397
  *
22656
- * Use of this source code is governed by an MIT-style license that can be
22657
- * found in the LICENSE file at https://angular.io/license
22398
+ * This function retrieves the host element of a component and
22399
+ * and then returns the `textContent` for that element. This implies
22400
+ * that the text returned will include re-projected content of
22401
+ * the component as well.
22402
+ *
22403
+ * @param component The component to return the content text for.
22658
22404
  */
22405
+ function getRenderedText(component) {
22406
+ const hostElement = getHostElement(component);
22407
+ return hostElement.textContent || '';
22408
+ }
22659
22409
  /**
22660
- * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
22661
- * @param ngModule NgModule class.
22662
- * @param parentInjector Optional injector instance to use as a parent for the module injector. If
22663
- * not provided, `NullInjector` will be used instead.
22410
+ * Retrieves a list of event listeners associated with a DOM element. The list does include host
22411
+ * listeners, but it does not include event listeners defined outside of the Angular context
22412
+ * (e.g. through `addEventListener`).
22413
+ *
22414
+ * @usageNotes
22415
+ * Given the following DOM structure:
22416
+ *
22417
+ * ```html
22418
+ * <app-root>
22419
+ * <div (click)="doSomething()"></div>
22420
+ * </app-root>
22421
+ * ```
22422
+ *
22423
+ * Calling `getListeners` on `<div>` will return an object that looks as follows:
22424
+ *
22425
+ * ```ts
22426
+ * {
22427
+ * name: 'click',
22428
+ * element: <div>,
22429
+ * callback: () => doSomething(),
22430
+ * useCapture: false
22431
+ * }
22432
+ * ```
22433
+ *
22434
+ * @param element Element for which the DOM listeners should be retrieved.
22435
+ * @returns Array of event listeners on the DOM element.
22436
+ *
22664
22437
  * @publicApi
22438
+ * @globalApi ng
22665
22439
  */
22666
- function createNgModuleRef(ngModule, parentInjector) {
22667
- return new NgModuleRef(ngModule, parentInjector ?? null);
22668
- }
22669
- class NgModuleRef extends NgModuleRef$1 {
22670
- constructor(ngModuleType, _parent) {
22671
- super();
22672
- this._parent = _parent;
22673
- // tslint:disable-next-line:require-internal-with-underscore
22674
- this._bootstrapComponents = [];
22675
- this.injector = this;
22676
- this.destroyCbs = [];
22677
- // When bootstrapping a module we have a dependency graph that looks like this:
22678
- // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
22679
- // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
22680
- // circular dependency which will result in a runtime error, because the injector doesn't
22681
- // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
22682
- // and providing it, rather than letting the injector resolve it.
22683
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22684
- const ngModuleDef = getNgModuleDef(ngModuleType);
22685
- ngDevMode &&
22686
- assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
22687
- this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
22688
- this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
22689
- { provide: NgModuleRef$1, useValue: this }, {
22690
- provide: ComponentFactoryResolver$1,
22691
- useValue: this.componentFactoryResolver
22440
+ function getListeners(element) {
22441
+ ngDevMode && assertDomElement(element);
22442
+ const lContext = getLContext(element);
22443
+ const lView = lContext === null ? null : lContext.lView;
22444
+ if (lView === null)
22445
+ return [];
22446
+ const tView = lView[TVIEW];
22447
+ const lCleanup = lView[CLEANUP];
22448
+ const tCleanup = tView.cleanup;
22449
+ const listeners = [];
22450
+ if (tCleanup && lCleanup) {
22451
+ for (let i = 0; i < tCleanup.length;) {
22452
+ const firstParam = tCleanup[i++];
22453
+ const secondParam = tCleanup[i++];
22454
+ if (typeof firstParam === 'string') {
22455
+ const name = firstParam;
22456
+ const listenerElement = unwrapRNode(lView[secondParam]);
22457
+ const callback = lCleanup[tCleanup[i++]];
22458
+ const useCaptureOrIndx = tCleanup[i++];
22459
+ // if useCaptureOrIndx is boolean then report it as is.
22460
+ // if useCaptureOrIndx is positive number then it in unsubscribe method
22461
+ // if useCaptureOrIndx is negative number then it is a Subscription
22462
+ const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
22463
+ const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
22464
+ if (element == listenerElement) {
22465
+ listeners.push({ element, name, callback, useCapture, type });
22466
+ }
22692
22467
  }
22693
- ], stringify(ngModuleType), new Set(['environment']));
22694
- // We need to resolve the injector types separately from the injector creation, because
22695
- // the module might be trying to use this ref in its constructor for DI which will cause a
22696
- // circular error that will eventually error out, because the injector isn't created yet.
22697
- this._r3Injector.resolveInjectorInitializers();
22698
- this.instance = this.get(ngModuleType);
22699
- }
22700
- get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
22701
- if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
22702
- return this;
22703
22468
  }
22704
- return this._r3Injector.get(token, notFoundValue, injectFlags);
22705
- }
22706
- destroy() {
22707
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22708
- const injector = this._r3Injector;
22709
- !injector.destroyed && injector.destroy();
22710
- this.destroyCbs.forEach(fn => fn());
22711
- this.destroyCbs = null;
22712
- }
22713
- onDestroy(callback) {
22714
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22715
- this.destroyCbs.push(callback);
22716
- }
22717
- }
22718
- class NgModuleFactory extends NgModuleFactory$1 {
22719
- constructor(moduleType) {
22720
- super();
22721
- this.moduleType = moduleType;
22722
- }
22723
- create(parentInjector) {
22724
- return new NgModuleRef(this.moduleType, parentInjector);
22725
22469
  }
22470
+ listeners.sort(sortListeners);
22471
+ return listeners;
22726
22472
  }
22727
- class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22728
- constructor(providers, parent, source) {
22729
- super();
22730
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22731
- this.instance = null;
22732
- const injector = new R3Injector([
22733
- ...providers,
22734
- { provide: NgModuleRef$1, useValue: this },
22735
- { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22736
- ], parent || getNullInjector(), source, new Set(['environment']));
22737
- this.injector = injector;
22738
- injector.resolveInjectorInitializers();
22739
- }
22740
- destroy() {
22741
- this.injector.destroy();
22742
- }
22743
- onDestroy(callback) {
22744
- this.injector.onDestroy(callback);
22745
- }
22473
+ function sortListeners(a, b) {
22474
+ if (a.name == b.name)
22475
+ return 0;
22476
+ return a.name < b.name ? -1 : 1;
22746
22477
  }
22747
22478
  /**
22748
- * Create a new environment injector.
22479
+ * This function should not exist because it is megamorphic and only mostly correct.
22749
22480
  *
22750
- * @publicApi
22751
- * @developerPreview
22481
+ * See call site for more info.
22752
22482
  */
22753
- function createEnvironmentInjector(providers, parent = null, debugName = null) {
22754
- const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22755
- return adapter.injector;
22483
+ function isDirectiveDefHack(obj) {
22484
+ return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
22756
22485
  }
22757
-
22758
22486
  /**
22759
- * @license
22760
- * Copyright Google LLC All Rights Reserved.
22487
+ * Returns the attached `DebugNode` instance for an element in the DOM.
22761
22488
  *
22762
- * Use of this source code is governed by an MIT-style license that can be
22763
- * found in the LICENSE file at https://angular.io/license
22764
- */
22765
- /**
22766
- * A service used by the framework to create instances of standalone injectors. Those injectors are
22767
- * created on demand in case of dynamic component instantiation and contain ambient providers
22768
- * collected from the imports graph rooted at a given standalone component.
22489
+ * @param element DOM element which is owned by an existing component's view.
22769
22490
  */
22770
- class StandaloneService {
22771
- constructor(_injector) {
22772
- this._injector = _injector;
22773
- this.cachedInjectors = new Map();
22491
+ function getDebugNode(element) {
22492
+ if (ngDevMode && !(element instanceof Node)) {
22493
+ throw new Error('Expecting instance of DOM Element');
22774
22494
  }
22775
- getOrCreateStandaloneInjector(componentDef) {
22776
- if (!componentDef.standalone) {
22777
- return null;
22778
- }
22779
- if (!this.cachedInjectors.has(componentDef.id)) {
22780
- const providers = internalImportProvidersFrom(false, componentDef.type);
22781
- const standaloneInjector = providers.length > 0 ?
22782
- createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22783
- null;
22784
- this.cachedInjectors.set(componentDef.id, standaloneInjector);
22785
- }
22786
- return this.cachedInjectors.get(componentDef.id);
22495
+ const lContext = getLContext(element);
22496
+ const lView = lContext ? lContext.lView : null;
22497
+ if (lView === null) {
22498
+ return null;
22787
22499
  }
22788
- ngOnDestroy() {
22789
- try {
22790
- for (const injector of this.cachedInjectors.values()) {
22791
- if (injector !== null) {
22792
- injector.destroy();
22793
- }
22794
- }
22795
- }
22796
- finally {
22797
- this.cachedInjectors.clear();
22798
- }
22500
+ const nodeIndex = lContext.nodeIndex;
22501
+ if (nodeIndex !== -1) {
22502
+ const valueInLView = lView[nodeIndex];
22503
+ // this means that value in the lView is a component with its own
22504
+ // data. In this situation the TNode is not accessed at the same spot.
22505
+ const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
22506
+ ngDevMode &&
22507
+ assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
22508
+ return buildDebugNode(tNode, lView);
22799
22509
  }
22510
+ return null;
22800
22511
  }
22801
- /** @nocollapse */
22802
- StandaloneService.ɵprov = ɵɵdefineInjectable({
22803
- token: StandaloneService,
22804
- providedIn: 'environment',
22805
- factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22806
- });
22807
22512
  /**
22808
- * A feature that acts as a setup code for the {@link StandaloneService}.
22513
+ * Retrieve the component `LView` from component/element.
22809
22514
  *
22810
- * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
22811
- * function (an entry points to a standalone injector creation) on a component definition object. We
22812
- * go through the features infrastructure to make sure that the standalone injector creation logic
22813
- * is tree-shakable and not included in applications that don't use standalone components.
22515
+ * NOTE: `LView` is a private and should not be leaked outside.
22516
+ * Don't export this method to `ng.*` on window.
22814
22517
  *
22815
- * @codeGenApi
22518
+ * @param target DOM element or component instance for which to retrieve the LView.
22816
22519
  */
22817
- function ɵɵStandaloneFeature(definition) {
22818
- definition.getStandaloneInjector = (parentInjector) => {
22819
- return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22820
- };
22520
+ function getComponentLView(target) {
22521
+ const lContext = getLContext(target);
22522
+ const nodeIndx = lContext.nodeIndex;
22523
+ const lView = lContext.lView;
22524
+ ngDevMode && assertLView(lView);
22525
+ const componentLView = lView[nodeIndx];
22526
+ ngDevMode && assertLView(componentLView);
22527
+ return componentLView;
22528
+ }
22529
+ /** Asserts that a value is a DOM Element. */
22530
+ function assertDomElement(value) {
22531
+ if (typeof Element !== 'undefined' && !(value instanceof Element)) {
22532
+ throw new Error('Expecting instance of DOM Element');
22533
+ }
22821
22534
  }
22822
22535
 
22823
22536
  /**
@@ -24037,7 +23750,7 @@ const unusedValueExportToPlacateAjd = 1;
24037
23750
  * Use of this source code is governed by an MIT-style license that can be
24038
23751
  * found in the LICENSE file at https://angular.io/license
24039
23752
  */
24040
- const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd;
23753
+ const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
24041
23754
  class LQuery_ {
24042
23755
  constructor(queryList) {
24043
23756
  this.queryList = queryList;