@angular/core 14.0.4 → 14.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2020/src/application_ref.mjs +2 -2
  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/di/r3_injector.mjs +7 -1
  6. package/esm2020/src/errors.mjs +1 -1
  7. package/esm2020/src/render/api.mjs +2 -11
  8. package/esm2020/src/render3/component.mjs +3 -58
  9. package/esm2020/src/render3/component_ref.mjs +9 -3
  10. package/esm2020/src/render3/index.mjs +4 -4
  11. package/esm2020/src/render3/instructions/change_detection.mjs +2 -20
  12. package/esm2020/src/render3/instructions/listener.mjs +34 -44
  13. package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
  14. package/esm2020/src/render3/instructions/shared.mjs +19 -57
  15. package/esm2020/src/render3/instructions/styling.mjs +2 -2
  16. package/esm2020/src/render3/interfaces/renderer.mjs +1 -26
  17. package/esm2020/src/render3/interfaces/view.mjs +1 -1
  18. package/esm2020/src/render3/node_manipulation.mjs +24 -87
  19. package/esm2020/src/render3/node_manipulation_i18n.mjs +1 -1
  20. package/esm2020/src/render3/util/attrs_utils.mjs +4 -12
  21. package/esm2020/src/render3/util/view_utils.mjs +3 -6
  22. package/esm2020/src/version.mjs +1 -1
  23. package/esm2020/testing/src/logger.mjs +3 -3
  24. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  25. package/esm2020/testing/src/test_bed_common.mjs +1 -1
  26. package/fesm2015/core.mjs +1671 -1877
  27. package/fesm2015/core.mjs.map +1 -1
  28. package/fesm2015/testing.mjs +1702 -2000
  29. package/fesm2015/testing.mjs.map +1 -1
  30. package/fesm2020/core.mjs +1671 -1877
  31. package/fesm2020/core.mjs.map +1 -1
  32. package/fesm2020/testing.mjs +1702 -2000
  33. package/fesm2020/testing.mjs.map +1 -1
  34. package/index.d.ts +57 -129
  35. package/package.json +1 -1
  36. package/testing/index.d.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.4
2
+ * @license Angular v14.0.7
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -366,7 +366,7 @@ function fakeAsync(fn) {
366
366
  *
367
367
  * @publicApi
368
368
  */
369
- function tick$1(millis = 0, tickOptions = {
369
+ function tick(millis = 0, tickOptions = {
370
370
  processNewMacroTasksSynchronously: true
371
371
  }) {
372
372
  if (fakeAsyncTestModule) {
@@ -3183,96 +3183,6 @@ function getNamespaceUri(namespace) {
3183
3183
  (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
3184
3184
  }
3185
3185
 
3186
- /**
3187
- * @license
3188
- * Copyright Google LLC All Rights Reserved.
3189
- *
3190
- * Use of this source code is governed by an MIT-style license that can be
3191
- * found in the LICENSE file at https://angular.io/license
3192
- */
3193
- /**
3194
- * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
3195
- * inject the `DOCUMENT` token and are done.
3196
- *
3197
- * Ivy is special because it does not rely upon the DI and must get hold of the document some other
3198
- * way.
3199
- *
3200
- * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
3201
- * Wherever ivy needs the global document, it calls `getDocument()` instead.
3202
- *
3203
- * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
3204
- * tell ivy what the global `document` is.
3205
- *
3206
- * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
3207
- * by calling `setDocument()` when providing the `DOCUMENT` token.
3208
- */
3209
- let DOCUMENT = undefined;
3210
- /**
3211
- * Tell ivy what the `document` is for this platform.
3212
- *
3213
- * It is only necessary to call this if the current platform is not a browser.
3214
- *
3215
- * @param document The object representing the global `document` in this environment.
3216
- */
3217
- function setDocument(document) {
3218
- DOCUMENT = document;
3219
- }
3220
- /**
3221
- * Access the object that represents the `document` for this platform.
3222
- *
3223
- * Ivy calls this whenever it needs to access the `document` object.
3224
- * For example to create the renderer or to do sanitization.
3225
- */
3226
- function getDocument() {
3227
- if (DOCUMENT !== undefined) {
3228
- return DOCUMENT;
3229
- }
3230
- else if (typeof document !== 'undefined') {
3231
- return document;
3232
- }
3233
- // No "document" can be found. This should only happen if we are running ivy outside Angular and
3234
- // the current platform is not a browser. Since this is not a supported scenario at the moment
3235
- // this should not happen in Angular apps.
3236
- // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
3237
- // public API. Meanwhile we just return `undefined` and let the application fail.
3238
- return undefined;
3239
- }
3240
-
3241
- /**
3242
- * @license
3243
- * Copyright Google LLC All Rights Reserved.
3244
- *
3245
- * Use of this source code is governed by an MIT-style license that can be
3246
- * found in the LICENSE file at https://angular.io/license
3247
- */
3248
- // TODO: cleanup once the code is merged in angular/angular
3249
- var RendererStyleFlags3;
3250
- (function (RendererStyleFlags3) {
3251
- RendererStyleFlags3[RendererStyleFlags3["Important"] = 1] = "Important";
3252
- RendererStyleFlags3[RendererStyleFlags3["DashCase"] = 2] = "DashCase";
3253
- })(RendererStyleFlags3 || (RendererStyleFlags3 = {}));
3254
- /** Returns whether the `renderer` is a `ProceduralRenderer3` */
3255
- function isProceduralRenderer(renderer) {
3256
- return !!(renderer.listen);
3257
- }
3258
- let renderer3Enabled = false;
3259
- function enableRenderer3() {
3260
- renderer3Enabled = true;
3261
- }
3262
- const domRendererFactory3 = {
3263
- createRenderer: (hostElement, rendererType) => {
3264
- if (!renderer3Enabled) {
3265
- throw new Error(ngDevMode ?
3266
- `Renderer3 is not supported. This problem is likely caused by some component in the hierarchy was constructed without a correct parent injector.` :
3267
- 'Renderer3 disabled');
3268
- }
3269
- return getDocument();
3270
- }
3271
- };
3272
- // Note: This hack is necessary so we don't erroneously get a circular dependency
3273
- // failure based on types.
3274
- const unusedValueExportToPlacateAjd$6 = 1;
3275
-
3276
3186
  /**
3277
3187
  * @license
3278
3188
  * Copyright Google LLC All Rights Reserved.
@@ -3355,7 +3265,6 @@ function getNativeByTNode(tNode, lView) {
3355
3265
  ngDevMode && assertTNodeForLView(tNode, lView);
3356
3266
  ngDevMode && assertIndexInRange(lView, tNode.index);
3357
3267
  const node = unwrapRNode(lView[tNode.index]);
3358
- ngDevMode && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3359
3268
  return node;
3360
3269
  }
3361
3270
  /**
@@ -3371,7 +3280,6 @@ function getNativeByTNodeOrNull(tNode, lView) {
3371
3280
  if (index !== -1) {
3372
3281
  ngDevMode && assertTNodeForLView(tNode, lView);
3373
3282
  const node = unwrapRNode(lView[index]);
3374
- ngDevMode && node !== null && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3375
3283
  return node;
3376
3284
  }
3377
3285
  return null;
@@ -4320,7 +4228,7 @@ function isFactory(obj) {
4320
4228
  }
4321
4229
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4322
4230
  // failure based on types.
4323
- const unusedValueExportToPlacateAjd$5 = 1;
4231
+ const unusedValueExportToPlacateAjd$6 = 1;
4324
4232
 
4325
4233
  /**
4326
4234
  * Converts `TNodeType` into human readable text.
@@ -4339,7 +4247,7 @@ function toTNodeTypeAsString(tNodeType) {
4339
4247
  }
4340
4248
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4341
4249
  // failure based on types.
4342
- const unusedValueExportToPlacateAjd$4 = 1;
4250
+ const unusedValueExportToPlacateAjd$5 = 1;
4343
4251
  /**
4344
4252
  * Returns `true` if the `TNode` has a directive which has `@Input()` for `class` binding.
4345
4253
  *
@@ -4443,7 +4351,6 @@ function assertPureTNodeType(type) {
4443
4351
  * @returns the index value that was last accessed in the attributes array
4444
4352
  */
4445
4353
  function setUpAttributes(renderer, native, attrs) {
4446
- const isProc = isProceduralRenderer(renderer);
4447
4354
  let i = 0;
4448
4355
  while (i < attrs.length) {
4449
4356
  const value = attrs[i];
@@ -4460,9 +4367,7 @@ function setUpAttributes(renderer, native, attrs) {
4460
4367
  const attrName = attrs[i++];
4461
4368
  const attrVal = attrs[i++];
4462
4369
  ngDevMode && ngDevMode.rendererSetAttribute++;
4463
- isProc ?
4464
- renderer.setAttribute(native, attrName, attrVal, namespaceURI) :
4465
- native.setAttributeNS(namespaceURI, attrName, attrVal);
4370
+ renderer.setAttribute(native, attrName, attrVal, namespaceURI);
4466
4371
  }
4467
4372
  else {
4468
4373
  // attrName is string;
@@ -4471,14 +4376,10 @@ function setUpAttributes(renderer, native, attrs) {
4471
4376
  // Standard attributes
4472
4377
  ngDevMode && ngDevMode.rendererSetAttribute++;
4473
4378
  if (isAnimationProp(attrName)) {
4474
- if (isProc) {
4475
- renderer.setProperty(native, attrName, attrVal);
4476
- }
4379
+ renderer.setProperty(native, attrName, attrVal);
4477
4380
  }
4478
4381
  else {
4479
- isProc ?
4480
- renderer.setAttribute(native, attrName, attrVal) :
4481
- native.setAttribute(attrName, attrVal);
4382
+ renderer.setAttribute(native, attrName, attrVal);
4482
4383
  }
4483
4384
  i++;
4484
4385
  }
@@ -5612,6 +5513,61 @@ function maybeUnwrapFn$1(value) {
5612
5513
  }
5613
5514
  }
5614
5515
 
5516
+ /**
5517
+ * @license
5518
+ * Copyright Google LLC All Rights Reserved.
5519
+ *
5520
+ * Use of this source code is governed by an MIT-style license that can be
5521
+ * found in the LICENSE file at https://angular.io/license
5522
+ */
5523
+ /**
5524
+ * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
5525
+ * inject the `DOCUMENT` token and are done.
5526
+ *
5527
+ * Ivy is special because it does not rely upon the DI and must get hold of the document some other
5528
+ * way.
5529
+ *
5530
+ * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
5531
+ * Wherever ivy needs the global document, it calls `getDocument()` instead.
5532
+ *
5533
+ * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
5534
+ * tell ivy what the global `document` is.
5535
+ *
5536
+ * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
5537
+ * by calling `setDocument()` when providing the `DOCUMENT` token.
5538
+ */
5539
+ let DOCUMENT = undefined;
5540
+ /**
5541
+ * Tell ivy what the `document` is for this platform.
5542
+ *
5543
+ * It is only necessary to call this if the current platform is not a browser.
5544
+ *
5545
+ * @param document The object representing the global `document` in this environment.
5546
+ */
5547
+ function setDocument(document) {
5548
+ DOCUMENT = document;
5549
+ }
5550
+ /**
5551
+ * Access the object that represents the `document` for this platform.
5552
+ *
5553
+ * Ivy calls this whenever it needs to access the `document` object.
5554
+ * For example to create the renderer or to do sanitization.
5555
+ */
5556
+ function getDocument() {
5557
+ if (DOCUMENT !== undefined) {
5558
+ return DOCUMENT;
5559
+ }
5560
+ else if (typeof document !== 'undefined') {
5561
+ return document;
5562
+ }
5563
+ // No "document" can be found. This should only happen if we are running ivy outside Angular and
5564
+ // the current platform is not a browser. Since this is not a supported scenario at the moment
5565
+ // this should not happen in Angular apps.
5566
+ // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
5567
+ // public API. Meanwhile we just return `undefined` and let the application fail.
5568
+ return undefined;
5569
+ }
5570
+
5615
5571
  /**
5616
5572
  * @license
5617
5573
  * 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$8 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$7;
7339
+ const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$8 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$7;
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)
@@ -9580,6 +9485,12 @@ class R3Injector extends EnvironmentInjector {
9580
9485
  const previousInjectImplementation = setInjectImplementation(undefined);
9581
9486
  try {
9582
9487
  const initializers = this.get(ENVIRONMENT_INITIALIZER.multi, EMPTY_ARRAY, InjectFlags.Self);
9488
+ if (ngDevMode && !Array.isArray(initializers)) {
9489
+ throw new RuntimeError(209 /* RuntimeErrorCode.INVALID_MULTI_PROVIDER */, 'Unexpected type of the `ENVIRONMENT_INITIALIZER` token value ' +
9490
+ `(expected an array, but got ${typeof initializers}). ` +
9491
+ 'Please check that the `ENVIRONMENT_INITIALIZER` token is configured as a ' +
9492
+ '`multi: true` provider.');
9493
+ }
9583
9494
  for (const initializer of initializers) {
9584
9495
  initializer();
9585
9496
  }
@@ -11814,6 +11725,13 @@ class LContainerDebug {
11814
11725
  }
11815
11726
  }
11816
11727
 
11728
+ /**
11729
+ * @license
11730
+ * Copyright Google LLC All Rights Reserved.
11731
+ *
11732
+ * Use of this source code is governed by an MIT-style license that can be
11733
+ * found in the LICENSE file at https://angular.io/license
11734
+ */
11817
11735
  /**
11818
11736
  * A permanent marker promise which signifies that the current CD tree is
11819
11737
  * clean.
@@ -11881,7 +11799,7 @@ function refreshChildComponents(hostLView, components) {
11881
11799
  /** Renders child components in the current view (creation mode). */
11882
11800
  function renderChildComponents(hostLView, components) {
11883
11801
  for (let i = 0; i < components.length; i++) {
11884
- renderComponent$1(hostLView, components[i]);
11802
+ renderComponent(hostLView, components[i]);
11885
11803
  }
11886
11804
  }
11887
11805
  function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
@@ -12399,16 +12317,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
12399
12317
  function createError(text, token) {
12400
12318
  return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
12401
12319
  }
12402
- function assertHostNodeExists(rElement, elementOrSelector) {
12403
- if (!rElement) {
12404
- if (typeof elementOrSelector === 'string') {
12405
- throw createError('Host node with selector not found:', elementOrSelector);
12406
- }
12407
- else {
12408
- throw createError('Host node is required:', elementOrSelector);
12409
- }
12410
- }
12411
- }
12412
12320
  /**
12413
12321
  * Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
12414
12322
  *
@@ -12417,21 +12325,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
12417
12325
  * @param encapsulation View Encapsulation defined for component that requests host element.
12418
12326
  */
12419
12327
  function locateHostElement(renderer, elementOrSelector, encapsulation) {
12420
- if (isProceduralRenderer(renderer)) {
12421
- // When using native Shadow DOM, do not clear host element to allow native slot projection
12422
- const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12423
- return renderer.selectRootElement(elementOrSelector, preserveContent);
12424
- }
12425
- let rElement = typeof elementOrSelector === 'string' ?
12426
- renderer.querySelector(elementOrSelector) :
12427
- elementOrSelector;
12428
- ngDevMode && assertHostNodeExists(rElement, elementOrSelector);
12429
- // Always clear host element's content when Renderer3 is in use. For procedural renderer case we
12430
- // make it depend on whether ShadowDom encapsulation is used (in which case the content should be
12431
- // preserved to allow native slot projection). ShadowDom encapsulation requires procedural
12432
- // renderer, and procedural renderer case is handled above.
12433
- rElement.textContent = '';
12434
- return rElement;
12328
+ // When using native Shadow DOM, do not clear host element to allow native slot projection
12329
+ const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12330
+ return renderer.selectRootElement(elementOrSelector, preserveContent);
12435
12331
  }
12436
12332
  /**
12437
12333
  * Saves context for this cleanup function in LView.cleanupInstances.
@@ -12646,13 +12542,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
12646
12542
  // It is assumed that the sanitizer is only added when the compiler determines that the
12647
12543
  // property is risky, so sanitization can be done without further checks.
12648
12544
  value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
12649
- if (isProceduralRenderer(renderer)) {
12650
- renderer.setProperty(element, propName, value);
12651
- }
12652
- else if (!isAnimationProp(propName)) {
12653
- element.setProperty ? element.setProperty(propName, value) :
12654
- element[propName] = value;
12655
- }
12545
+ renderer.setProperty(element, propName, value);
12656
12546
  }
12657
12547
  else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
12658
12548
  // If the node is a container and the property didn't
@@ -12676,23 +12566,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
12676
12566
  const debugValue = normalizeDebugBindingValue(value);
12677
12567
  if (type & 3 /* TNodeType.AnyRNode */) {
12678
12568
  if (value == null) {
12679
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, attrName) :
12680
- element.removeAttribute(attrName);
12569
+ renderer.removeAttribute(element, attrName);
12681
12570
  }
12682
12571
  else {
12683
- isProceduralRenderer(renderer) ?
12684
- renderer.setAttribute(element, attrName, debugValue) :
12685
- element.setAttribute(attrName, debugValue);
12572
+ renderer.setAttribute(element, attrName, debugValue);
12686
12573
  }
12687
12574
  }
12688
12575
  else {
12689
12576
  const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
12690
- if (isProceduralRenderer(renderer)) {
12691
- renderer.setValue(element, textContent);
12692
- }
12693
- else {
12694
- element.textContent = textContent;
12695
- }
12577
+ renderer.setValue(element, textContent);
12696
12578
  }
12697
12579
  }
12698
12580
  function setNgReflectProperties(lView, element, type, dataValue, value) {
@@ -13046,19 +12928,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
13046
12928
  function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
13047
12929
  if (value == null) {
13048
12930
  ngDevMode && ngDevMode.rendererRemoveAttribute++;
13049
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, name, namespace) :
13050
- element.removeAttribute(name);
12931
+ renderer.removeAttribute(element, name, namespace);
13051
12932
  }
13052
12933
  else {
13053
12934
  ngDevMode && ngDevMode.rendererSetAttribute++;
13054
12935
  const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
13055
- if (isProceduralRenderer(renderer)) {
13056
- renderer.setAttribute(element, name, strValue, namespace);
13057
- }
13058
- else {
13059
- namespace ? element.setAttributeNS(namespace, name, strValue) :
13060
- element.setAttribute(name, strValue);
13061
- }
12936
+ renderer.setAttribute(element, name, strValue, namespace);
13062
12937
  }
13063
12938
  }
13064
12939
  /**
@@ -13150,7 +13025,6 @@ const LContainerArray = class LContainer extends Array {
13150
13025
  */
13151
13026
  function createLContainer(hostNative, currentView, native, tNode) {
13152
13027
  ngDevMode && assertLView(currentView);
13153
- ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
13154
13028
  // https://jsperf.com/array-literal-vs-new-array-really
13155
13029
  const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
13156
13030
  true, // Boolean `true` in this position signifies that this is an `LContainer`
@@ -13266,7 +13140,7 @@ function refreshContainsDirtyView(lView) {
13266
13140
  }
13267
13141
  }
13268
13142
  }
13269
- function renderComponent$1(hostLView, componentHostIdx) {
13143
+ function renderComponent(hostLView, componentHostIdx) {
13270
13144
  ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
13271
13145
  const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
13272
13146
  const componentTView = componentView[TVIEW];
@@ -13618,458 +13492,450 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
13618
13492
  * Use of this source code is governed by an MIT-style license that can be
13619
13493
  * found in the LICENSE file at https://angular.io/license
13620
13494
  */
13495
+ // TODO: A hack to not pull in the NullInjector from @angular/core.
13496
+ const NULL_INJECTOR = {
13497
+ get: (token, notFoundValue) => {
13498
+ throwProviderNotFoundError(token, 'NullInjector');
13499
+ }
13500
+ };
13621
13501
  /**
13622
- * Synchronously perform change detection on a component (and possibly its sub-components).
13502
+ * Creates the root component view and the root component node.
13623
13503
  *
13624
- * This function triggers change detection in a synchronous way on a component.
13504
+ * @param rNode Render host element.
13505
+ * @param def ComponentDef
13506
+ * @param rootView The parent view where the host node is stored
13507
+ * @param rendererFactory Factory to be used for creating child renderers.
13508
+ * @param hostRenderer The current renderer
13509
+ * @param sanitizer The sanitizer, if provided
13625
13510
  *
13626
- * @param component The component which the change detection should be performed on.
13511
+ * @returns Component view created
13627
13512
  */
13628
- function detectChanges(component) {
13629
- const view = getComponentViewByInstance(component);
13630
- detectChangesInternal(view[TVIEW], view, component);
13513
+ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
13514
+ const tView = rootView[TVIEW];
13515
+ const index = HEADER_OFFSET;
13516
+ ngDevMode && assertIndexInRange(rootView, index);
13517
+ rootView[index] = rNode;
13518
+ // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
13519
+ // the same time we want to communicate the debug `TNode` that this is a special `TNode`
13520
+ // representing a host element.
13521
+ const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
13522
+ const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
13523
+ if (mergedAttrs !== null) {
13524
+ computeStaticStyling(tNode, mergedAttrs, true);
13525
+ if (rNode !== null) {
13526
+ setUpAttributes(hostRenderer, rNode, mergedAttrs);
13527
+ if (tNode.classes !== null) {
13528
+ writeDirectClass(hostRenderer, rNode, tNode.classes);
13529
+ }
13530
+ if (tNode.styles !== null) {
13531
+ writeDirectStyle(hostRenderer, rNode, tNode.styles);
13532
+ }
13533
+ }
13534
+ }
13535
+ const viewRenderer = rendererFactory.createRenderer(rNode, def);
13536
+ const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13537
+ if (tView.firstCreatePass) {
13538
+ diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
13539
+ markAsComponentHost(tView, tNode);
13540
+ initTNodeFlags(tNode, rootView.length, 1);
13541
+ }
13542
+ addToViewTree(rootView, componentView);
13543
+ // Store component view at node index, with node as the HOST
13544
+ return rootView[index] = componentView;
13631
13545
  }
13632
13546
  /**
13633
- * Marks the component as dirty (needing change detection). Marking a component dirty will
13634
- * schedule a change detection on it at some point in the future.
13635
- *
13636
- * Marking an already dirty component as dirty won't do anything. Only one outstanding change
13637
- * detection can be scheduled per component tree.
13638
- *
13639
- * @param component Component to mark as dirty.
13547
+ * Creates a root component and sets it up with features and host bindings. Shared by
13548
+ * renderComponent() and ViewContainerRef.createComponent().
13640
13549
  */
13641
- function markDirty(component) {
13642
- ngDevMode && assertDefined(component, 'component');
13643
- const rootView = markViewDirty(getComponentViewByInstance(component));
13644
- ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
13645
- scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
13550
+ function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
13551
+ const tView = rootLView[TVIEW];
13552
+ // Create directive instance with factory() and store at next index in viewData
13553
+ const component = instantiateRootComponent(tView, rootLView, componentDef);
13554
+ rootContext.components.push(component);
13555
+ componentView[CONTEXT] = component;
13556
+ if (hostFeatures !== null) {
13557
+ for (const feature of hostFeatures) {
13558
+ feature(component, componentDef);
13559
+ }
13560
+ }
13561
+ // We want to generate an empty QueryList for root content queries for backwards
13562
+ // compatibility with ViewEngine.
13563
+ if (componentDef.contentQueries) {
13564
+ const tNode = getCurrentTNode();
13565
+ ngDevMode && assertDefined(tNode, 'TNode expected');
13566
+ componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
13567
+ }
13568
+ const rootTNode = getCurrentTNode();
13569
+ ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
13570
+ if (tView.firstCreatePass &&
13571
+ (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
13572
+ setSelectedIndex(rootTNode.index);
13573
+ const rootTView = rootLView[TVIEW];
13574
+ registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
13575
+ invokeHostBindingsInCreationMode(componentDef, component);
13576
+ }
13577
+ return component;
13646
13578
  }
13647
- /**
13648
- * Used to perform change detection on the whole application.
13649
- *
13650
- * This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
13651
- * executes lifecycle hooks and conditionally checks components based on their
13652
- * `ChangeDetectionStrategy` and dirtiness.
13653
- *
13654
- * The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
13655
- * schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
13656
- * single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
13657
- * be changed when calling `renderComponent` and providing the `scheduler` option.
13658
- */
13659
- function tick(component) {
13660
- const rootView = getRootView(component);
13661
- const rootContext = rootView[CONTEXT];
13662
- tickRootContext(rootContext);
13579
+ function createRootContext(scheduler, playerHandler) {
13580
+ return {
13581
+ components: [],
13582
+ scheduler: scheduler || defaultScheduler,
13583
+ clean: CLEAN_PROMISE,
13584
+ playerHandler: playerHandler || null,
13585
+ flags: 0 /* RootContextFlags.Empty */
13586
+ };
13663
13587
  }
13664
-
13665
13588
  /**
13666
- * @license
13667
- * Copyright Google LLC All Rights Reserved.
13589
+ * Used to enable lifecycle hooks on the root component.
13668
13590
  *
13669
- * Use of this source code is governed by an MIT-style license that can be
13670
- * found in the LICENSE file at https://angular.io/license
13671
- */
13672
- /**
13673
- * Retrieves the component instance associated with a given DOM element.
13591
+ * Include this feature when calling `renderComponent` if the root component
13592
+ * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
13593
+ * be called properly.
13674
13594
  *
13675
- * @usageNotes
13676
- * Given the following DOM structure:
13595
+ * Example:
13677
13596
  *
13678
- * ```html
13679
- * <app-root>
13680
- * <div>
13681
- * <child-comp></child-comp>
13682
- * </div>
13683
- * </app-root>
13684
13597
  * ```
13685
- *
13686
- * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
13687
- * associated with this DOM element.
13688
- *
13689
- * Calling the function on `<app-root>` will return the `MyApp` instance.
13690
- *
13691
- *
13692
- * @param element DOM element from which the component should be retrieved.
13693
- * @returns Component instance associated with the element or `null` if there
13694
- * is no component associated with it.
13695
- *
13696
- * @publicApi
13697
- * @globalApi ng
13698
- */
13699
- function getComponent$1(element) {
13700
- ngDevMode && assertDomElement(element);
13701
- const context = getLContext(element);
13702
- if (context === null)
13703
- return null;
13704
- if (context.component === undefined) {
13705
- const lView = context.lView;
13706
- if (lView === null) {
13707
- return null;
13708
- }
13709
- context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
13710
- }
13711
- return context.component;
13712
- }
13713
- /**
13714
- * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
13715
- * view that the element is part of. Otherwise retrieves the instance of the component whose view
13716
- * owns the element (in this case, the result is the same as calling `getOwningComponent`).
13717
- *
13718
- * @param element Element for which to get the surrounding component instance.
13719
- * @returns Instance of the component that is around the element or null if the element isn't
13720
- * inside any component.
13721
- *
13722
- * @publicApi
13723
- * @globalApi ng
13598
+ * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
13599
+ * ```
13724
13600
  */
13725
- function getContext(element) {
13726
- assertDomElement(element);
13727
- const context = getLContext(element);
13728
- const lView = context ? context.lView : null;
13729
- return lView === null ? null : lView[CONTEXT];
13601
+ function LifecycleHooksFeature() {
13602
+ const tNode = getCurrentTNode();
13603
+ ngDevMode && assertDefined(tNode, 'TNode is required');
13604
+ registerPostOrderHooks(getLView()[TVIEW], tNode);
13730
13605
  }
13731
13606
  /**
13732
- * Retrieves the component instance whose view contains the DOM element.
13607
+ * Wait on component until it is rendered.
13733
13608
  *
13734
- * For example, if `<child-comp>` is used in the template of `<app-comp>`
13735
- * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
13736
- * would return `<app-comp>`.
13609
+ * This function returns a `Promise` which is resolved when the component's
13610
+ * change detection is executed. This is determined by finding the scheduler
13611
+ * associated with the `component`'s render tree and waiting until the scheduler
13612
+ * flushes. If nothing is scheduled, the function returns a resolved promise.
13737
13613
  *
13738
- * @param elementOrDir DOM element, component or directive instance
13739
- * for which to retrieve the root components.
13740
- * @returns Component instance whose view owns the DOM element or null if the element is not
13741
- * part of a component view.
13614
+ * Example:
13615
+ * ```
13616
+ * await whenRendered(myComponent);
13617
+ * ```
13742
13618
  *
13743
- * @publicApi
13744
- * @globalApi ng
13619
+ * @param component Component to wait upon
13620
+ * @returns Promise which resolves when the component is rendered.
13745
13621
  */
13746
- function getOwningComponent(elementOrDir) {
13747
- const context = getLContext(elementOrDir);
13748
- let lView = context ? context.lView : null;
13749
- if (lView === null)
13750
- return null;
13751
- let parent;
13752
- while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
13753
- lView = parent;
13754
- }
13755
- return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
13622
+ function whenRendered(component) {
13623
+ return getRootContext(component).clean;
13756
13624
  }
13625
+
13757
13626
  /**
13758
- * Retrieves all root components associated with a DOM element, directive or component instance.
13759
- * Root components are those which have been bootstrapped by Angular.
13760
- *
13761
- * @param elementOrDir DOM element, component or directive instance
13762
- * for which to retrieve the root components.
13763
- * @returns Root components associated with the target object.
13627
+ * @license
13628
+ * Copyright Google LLC All Rights Reserved.
13764
13629
  *
13765
- * @publicApi
13766
- * @globalApi ng
13630
+ * Use of this source code is governed by an MIT-style license that can be
13631
+ * found in the LICENSE file at https://angular.io/license
13767
13632
  */
13768
- function getRootComponents(elementOrDir) {
13769
- const lView = readPatchedLView(elementOrDir);
13770
- return lView !== null ? [...getRootContext(lView).components] : [];
13633
+ function getSuperType(type) {
13634
+ return Object.getPrototypeOf(type.prototype).constructor;
13771
13635
  }
13772
13636
  /**
13773
- * Retrieves an `Injector` associated with an element, component or directive instance.
13774
- *
13775
- * @param elementOrDir DOM element, component or directive instance for which to
13776
- * retrieve the injector.
13777
- * @returns Injector associated with the element, component or directive instance.
13637
+ * Merges the definition from a super class to a sub class.
13638
+ * @param definition The definition that is a SubClass of another directive of component
13778
13639
  *
13779
- * @publicApi
13780
- * @globalApi ng
13640
+ * @codeGenApi
13781
13641
  */
13782
- function getInjector(elementOrDir) {
13783
- const context = getLContext(elementOrDir);
13784
- const lView = context ? context.lView : null;
13785
- if (lView === null)
13786
- return Injector.NULL;
13787
- const tNode = lView[TVIEW].data[context.nodeIndex];
13788
- return new NodeInjector(tNode, lView);
13642
+ function ɵɵInheritDefinitionFeature(definition) {
13643
+ let superType = getSuperType(definition.type);
13644
+ let shouldInheritFields = true;
13645
+ const inheritanceChain = [definition];
13646
+ while (superType) {
13647
+ let superDef = undefined;
13648
+ if (isComponentDef(definition)) {
13649
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13650
+ superDef = superType.ɵcmp || superType.ɵdir;
13651
+ }
13652
+ else {
13653
+ if (superType.ɵcmp) {
13654
+ throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
13655
+ `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
13656
+ }
13657
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13658
+ superDef = superType.ɵdir;
13659
+ }
13660
+ if (superDef) {
13661
+ if (shouldInheritFields) {
13662
+ inheritanceChain.push(superDef);
13663
+ // Some fields in the definition may be empty, if there were no values to put in them that
13664
+ // would've justified object creation. Unwrap them if necessary.
13665
+ const writeableDef = definition;
13666
+ writeableDef.inputs = maybeUnwrapEmpty(definition.inputs);
13667
+ writeableDef.declaredInputs = maybeUnwrapEmpty(definition.declaredInputs);
13668
+ writeableDef.outputs = maybeUnwrapEmpty(definition.outputs);
13669
+ // Merge hostBindings
13670
+ const superHostBindings = superDef.hostBindings;
13671
+ superHostBindings && inheritHostBindings(definition, superHostBindings);
13672
+ // Merge queries
13673
+ const superViewQuery = superDef.viewQuery;
13674
+ const superContentQueries = superDef.contentQueries;
13675
+ superViewQuery && inheritViewQuery(definition, superViewQuery);
13676
+ superContentQueries && inheritContentQueries(definition, superContentQueries);
13677
+ // Merge inputs and outputs
13678
+ fillProperties(definition.inputs, superDef.inputs);
13679
+ fillProperties(definition.declaredInputs, superDef.declaredInputs);
13680
+ fillProperties(definition.outputs, superDef.outputs);
13681
+ // Merge animations metadata.
13682
+ // If `superDef` is a Component, the `data` field is present (defaults to an empty object).
13683
+ if (isComponentDef(superDef) && superDef.data.animation) {
13684
+ // If super def is a Component, the `definition` is also a Component, since Directives can
13685
+ // not inherit Components (we throw an error above and cannot reach this code).
13686
+ const defData = definition.data;
13687
+ defData.animation = (defData.animation || []).concat(superDef.data.animation);
13688
+ }
13689
+ }
13690
+ // Run parent features
13691
+ const features = superDef.features;
13692
+ if (features) {
13693
+ for (let i = 0; i < features.length; i++) {
13694
+ const feature = features[i];
13695
+ if (feature && feature.ngInherit) {
13696
+ feature(definition);
13697
+ }
13698
+ // If `InheritDefinitionFeature` is a part of the current `superDef`, it means that this
13699
+ // def already has all the necessary information inherited from its super class(es), so we
13700
+ // can stop merging fields from super classes. However we need to iterate through the
13701
+ // prototype chain to look for classes that might contain other "features" (like
13702
+ // NgOnChanges), which we should invoke for the original `definition`. We set the
13703
+ // `shouldInheritFields` flag to indicate that, essentially skipping fields inheritance
13704
+ // logic and only invoking functions from the "features" list.
13705
+ if (feature === ɵɵInheritDefinitionFeature) {
13706
+ shouldInheritFields = false;
13707
+ }
13708
+ }
13709
+ }
13710
+ }
13711
+ superType = Object.getPrototypeOf(superType);
13712
+ }
13713
+ mergeHostAttrsAcrossInheritance(inheritanceChain);
13789
13714
  }
13790
13715
  /**
13791
- * Retrieve a set of injection tokens at a given DOM node.
13716
+ * Merge the `hostAttrs` and `hostVars` from the inherited parent to the base class.
13792
13717
  *
13793
- * @param element Element for which the injection tokens should be retrieved.
13718
+ * @param inheritanceChain A list of `WritableDefs` starting at the top most type and listing
13719
+ * sub-types in order. For each type take the `hostAttrs` and `hostVars` and merge it with the child
13720
+ * type.
13794
13721
  */
13795
- function getInjectionTokens(element) {
13796
- const context = getLContext(element);
13797
- const lView = context ? context.lView : null;
13798
- if (lView === null)
13799
- return [];
13800
- const tView = lView[TVIEW];
13801
- const tNode = tView.data[context.nodeIndex];
13802
- const providerTokens = [];
13803
- const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
13804
- const endIndex = tNode.directiveEnd;
13805
- for (let i = startIndex; i < endIndex; i++) {
13806
- let value = tView.data[i];
13807
- if (isDirectiveDefHack(value)) {
13808
- // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
13809
- // design flaw. We should always store same type so that we can be monomorphic. The issue
13810
- // is that for Components/Directives we store the def instead the type. The correct behavior
13811
- // is that we should always be storing injectable type in this location.
13812
- value = value.type;
13813
- }
13814
- providerTokens.push(value);
13722
+ function mergeHostAttrsAcrossInheritance(inheritanceChain) {
13723
+ let hostVars = 0;
13724
+ let hostAttrs = null;
13725
+ // We process the inheritance order from the base to the leaves here.
13726
+ for (let i = inheritanceChain.length - 1; i >= 0; i--) {
13727
+ const def = inheritanceChain[i];
13728
+ // For each `hostVars`, we need to add the superclass amount.
13729
+ def.hostVars = (hostVars += def.hostVars);
13730
+ // for each `hostAttrs` we need to merge it with superclass.
13731
+ def.hostAttrs =
13732
+ mergeHostAttrs(def.hostAttrs, hostAttrs = mergeHostAttrs(hostAttrs, def.hostAttrs));
13815
13733
  }
13816
- return providerTokens;
13817
13734
  }
13818
- /**
13819
- * Retrieves directive instances associated with a given DOM node. Does not include
13820
- * component instances.
13821
- *
13822
- * @usageNotes
13823
- * Given the following DOM structure:
13824
- *
13825
- * ```html
13826
- * <app-root>
13827
- * <button my-button></button>
13828
- * <my-comp></my-comp>
13829
- * </app-root>
13830
- * ```
13831
- *
13832
- * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
13833
- * directive that is associated with the DOM node.
13834
- *
13835
- * Calling `getDirectives` on `<my-comp>` will return an empty array.
13836
- *
13837
- * @param node DOM node for which to get the directives.
13838
- * @returns Array of directives associated with the node.
13839
- *
13840
- * @publicApi
13841
- * @globalApi ng
13842
- */
13843
- function getDirectives(node) {
13844
- // Skip text nodes because we can't have directives associated with them.
13845
- if (node instanceof Text) {
13846
- return [];
13735
+ function maybeUnwrapEmpty(value) {
13736
+ if (value === EMPTY_OBJ) {
13737
+ return {};
13847
13738
  }
13848
- const context = getLContext(node);
13849
- const lView = context ? context.lView : null;
13850
- if (lView === null) {
13739
+ else if (value === EMPTY_ARRAY) {
13851
13740
  return [];
13852
13741
  }
13853
- const tView = lView[TVIEW];
13854
- const nodeIndex = context.nodeIndex;
13855
- if (!(tView === null || tView === void 0 ? void 0 : tView.data[nodeIndex])) {
13856
- return [];
13742
+ else {
13743
+ return value;
13857
13744
  }
13858
- if (context.directives === undefined) {
13859
- context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
13745
+ }
13746
+ function inheritViewQuery(definition, superViewQuery) {
13747
+ const prevViewQuery = definition.viewQuery;
13748
+ if (prevViewQuery) {
13749
+ definition.viewQuery = (rf, ctx) => {
13750
+ superViewQuery(rf, ctx);
13751
+ prevViewQuery(rf, ctx);
13752
+ };
13753
+ }
13754
+ else {
13755
+ definition.viewQuery = superViewQuery;
13860
13756
  }
13861
- // The `directives` in this case are a named array called `LComponentView`. Clone the
13862
- // result so we don't expose an internal data structure in the user's console.
13863
- return context.directives === null ? [] : [...context.directives];
13864
13757
  }
13865
- /**
13866
- * Returns the debug (partial) metadata for a particular directive or component instance.
13867
- * The function accepts an instance of a directive or component and returns the corresponding
13868
- * metadata.
13869
- *
13870
- * @param directiveOrComponentInstance Instance of a directive or component
13871
- * @returns metadata of the passed directive or component
13872
- *
13873
- * @publicApi
13874
- * @globalApi ng
13875
- */
13876
- function getDirectiveMetadata(directiveOrComponentInstance) {
13877
- const { constructor } = directiveOrComponentInstance;
13878
- if (!constructor) {
13879
- throw new Error('Unable to find the instance constructor');
13758
+ function inheritContentQueries(definition, superContentQueries) {
13759
+ const prevContentQueries = definition.contentQueries;
13760
+ if (prevContentQueries) {
13761
+ definition.contentQueries = (rf, ctx, directiveIndex) => {
13762
+ superContentQueries(rf, ctx, directiveIndex);
13763
+ prevContentQueries(rf, ctx, directiveIndex);
13764
+ };
13880
13765
  }
13881
- // In case a component inherits from a directive, we may have component and directive metadata
13882
- // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
13883
- const componentDef = getComponentDef$1(constructor);
13884
- if (componentDef) {
13885
- return {
13886
- inputs: componentDef.inputs,
13887
- outputs: componentDef.outputs,
13888
- encapsulation: componentDef.encapsulation,
13889
- changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
13890
- ChangeDetectionStrategy.Default
13766
+ else {
13767
+ definition.contentQueries = superContentQueries;
13768
+ }
13769
+ }
13770
+ function inheritHostBindings(definition, superHostBindings) {
13771
+ const prevHostBindings = definition.hostBindings;
13772
+ if (prevHostBindings) {
13773
+ definition.hostBindings = (rf, ctx) => {
13774
+ superHostBindings(rf, ctx);
13775
+ prevHostBindings(rf, ctx);
13891
13776
  };
13892
13777
  }
13893
- const directiveDef = getDirectiveDef(constructor);
13894
- if (directiveDef) {
13895
- return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
13778
+ else {
13779
+ definition.hostBindings = superHostBindings;
13896
13780
  }
13897
- return null;
13898
13781
  }
13782
+
13899
13783
  /**
13900
- * Retrieve map of local references.
13901
- *
13902
- * The references are retrieved as a map of local reference name to element or directive instance.
13784
+ * @license
13785
+ * Copyright Google LLC All Rights Reserved.
13903
13786
  *
13904
- * @param target DOM element, component or directive instance for which to retrieve
13905
- * the local references.
13787
+ * Use of this source code is governed by an MIT-style license that can be
13788
+ * found in the LICENSE file at https://angular.io/license
13906
13789
  */
13907
- function getLocalRefs(target) {
13908
- const context = getLContext(target);
13909
- if (context === null)
13910
- return {};
13911
- if (context.localRefs === undefined) {
13912
- const lView = context.lView;
13913
- if (lView === null) {
13914
- return {};
13915
- }
13916
- context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
13917
- }
13918
- return context.localRefs || {};
13919
- }
13920
13790
  /**
13921
- * Retrieves the host element of a component or directive instance.
13922
- * The host element is the DOM element that matched the selector of the directive.
13923
- *
13924
- * @param componentOrDirective Component or directive instance for which the host
13925
- * element should be retrieved.
13926
- * @returns Host element of the target.
13927
- *
13928
- * @publicApi
13929
- * @globalApi ng
13791
+ * Fields which exist on either directive or component definitions, and need to be copied from
13792
+ * parent to child classes by the `ɵɵCopyDefinitionFeature`.
13930
13793
  */
13931
- function getHostElement(componentOrDirective) {
13932
- return getLContext(componentOrDirective).native;
13933
- }
13794
+ const COPY_DIRECTIVE_FIELDS = [
13795
+ // The child class should use the providers of its parent.
13796
+ 'providersResolver',
13797
+ // Not listed here are any fields which are handled by the `ɵɵInheritDefinitionFeature`, such
13798
+ // as inputs, outputs, and host binding functions.
13799
+ ];
13934
13800
  /**
13935
- * Retrieves the rendered text for a given component.
13936
- *
13937
- * This function retrieves the host element of a component and
13938
- * and then returns the `textContent` for that element. This implies
13939
- * that the text returned will include re-projected content of
13940
- * the component as well.
13801
+ * Fields which exist only on component definitions, and need to be copied from parent to child
13802
+ * classes by the `ɵɵCopyDefinitionFeature`.
13941
13803
  *
13942
- * @param component The component to return the content text for.
13804
+ * The type here allows any field of `ComponentDef` which is not also a property of `DirectiveDef`,
13805
+ * since those should go in `COPY_DIRECTIVE_FIELDS` above.
13943
13806
  */
13944
- function getRenderedText(component) {
13945
- const hostElement = getHostElement(component);
13946
- return hostElement.textContent || '';
13947
- }
13807
+ const COPY_COMPONENT_FIELDS = [
13808
+ // The child class should use the template function of its parent, including all template
13809
+ // semantics.
13810
+ 'template',
13811
+ 'decls',
13812
+ 'consts',
13813
+ 'vars',
13814
+ 'onPush',
13815
+ 'ngContentSelectors',
13816
+ // The child class should use the CSS styles of its parent, including all styling semantics.
13817
+ 'styles',
13818
+ 'encapsulation',
13819
+ // The child class should be checked by the runtime in the same way as its parent.
13820
+ 'schemas',
13821
+ ];
13948
13822
  /**
13949
- * Retrieves a list of event listeners associated with a DOM element. The list does include host
13950
- * listeners, but it does not include event listeners defined outside of the Angular context
13951
- * (e.g. through `addEventListener`).
13952
- *
13953
- * @usageNotes
13954
- * Given the following DOM structure:
13955
- *
13956
- * ```html
13957
- * <app-root>
13958
- * <div (click)="doSomething()"></div>
13959
- * </app-root>
13960
- * ```
13823
+ * Copies the fields not handled by the `ɵɵInheritDefinitionFeature` from the supertype of a
13824
+ * definition.
13961
13825
  *
13962
- * Calling `getListeners` on `<div>` will return an object that looks as follows:
13826
+ * This exists primarily to support ngcc migration of an existing View Engine pattern, where an
13827
+ * entire decorator is inherited from a parent to a child class. When ngcc detects this case, it
13828
+ * generates a skeleton definition on the child class, and applies this feature.
13963
13829
  *
13964
- * ```ts
13965
- * {
13966
- * name: 'click',
13967
- * element: <div>,
13968
- * callback: () => doSomething(),
13969
- * useCapture: false
13970
- * }
13971
- * ```
13830
+ * The `ɵɵCopyDefinitionFeature` then copies any needed fields from the parent class' definition,
13831
+ * including things like the component template function.
13972
13832
  *
13973
- * @param element Element for which the DOM listeners should be retrieved.
13974
- * @returns Array of event listeners on the DOM element.
13833
+ * @param definition The definition of a child class which inherits from a parent class with its
13834
+ * own definition.
13975
13835
  *
13976
- * @publicApi
13977
- * @globalApi ng
13836
+ * @codeGenApi
13978
13837
  */
13979
- function getListeners(element) {
13980
- ngDevMode && assertDomElement(element);
13981
- const lContext = getLContext(element);
13982
- const lView = lContext === null ? null : lContext.lView;
13983
- if (lView === null)
13984
- return [];
13985
- const tView = lView[TVIEW];
13986
- const lCleanup = lView[CLEANUP];
13987
- const tCleanup = tView.cleanup;
13988
- const listeners = [];
13989
- if (tCleanup && lCleanup) {
13990
- for (let i = 0; i < tCleanup.length;) {
13991
- const firstParam = tCleanup[i++];
13992
- const secondParam = tCleanup[i++];
13993
- if (typeof firstParam === 'string') {
13994
- const name = firstParam;
13995
- const listenerElement = unwrapRNode(lView[secondParam]);
13996
- const callback = lCleanup[tCleanup[i++]];
13997
- const useCaptureOrIndx = tCleanup[i++];
13998
- // if useCaptureOrIndx is boolean then report it as is.
13999
- // if useCaptureOrIndx is positive number then it in unsubscribe method
14000
- // if useCaptureOrIndx is negative number then it is a Subscription
14001
- const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
14002
- const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
14003
- if (element == listenerElement) {
14004
- listeners.push({ element, name, callback, useCapture, type });
14005
- }
14006
- }
13838
+ function ɵɵCopyDefinitionFeature(definition) {
13839
+ let superType = getSuperType(definition.type);
13840
+ let superDef = undefined;
13841
+ if (isComponentDef(definition)) {
13842
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13843
+ superDef = superType.ɵcmp;
13844
+ }
13845
+ else {
13846
+ // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
13847
+ superDef = superType.ɵdir;
13848
+ }
13849
+ // Needed because `definition` fields are readonly.
13850
+ const defAny = definition;
13851
+ // Copy over any fields that apply to either directives or components.
13852
+ for (const field of COPY_DIRECTIVE_FIELDS) {
13853
+ defAny[field] = superDef[field];
13854
+ }
13855
+ if (isComponentDef(superDef)) {
13856
+ // Copy over any component-specific fields.
13857
+ for (const field of COPY_COMPONENT_FIELDS) {
13858
+ defAny[field] = superDef[field];
14007
13859
  }
14008
13860
  }
14009
- listeners.sort(sortListeners);
14010
- return listeners;
14011
- }
14012
- function sortListeners(a, b) {
14013
- if (a.name == b.name)
14014
- return 0;
14015
- return a.name < b.name ? -1 : 1;
14016
13861
  }
13862
+
14017
13863
  /**
14018
- * This function should not exist because it is megamorphic and only mostly correct.
13864
+ * @license
13865
+ * Copyright Google LLC All Rights Reserved.
14019
13866
  *
14020
- * See call site for more info.
13867
+ * Use of this source code is governed by an MIT-style license that can be
13868
+ * found in the LICENSE file at https://angular.io/license
14021
13869
  */
14022
- function isDirectiveDefHack(obj) {
14023
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
13870
+ let _symbolIterator = null;
13871
+ function getSymbolIterator() {
13872
+ if (!_symbolIterator) {
13873
+ const Symbol = _global$1['Symbol'];
13874
+ if (Symbol && Symbol.iterator) {
13875
+ _symbolIterator = Symbol.iterator;
13876
+ }
13877
+ else {
13878
+ // es6-shim specific logic
13879
+ const keys = Object.getOwnPropertyNames(Map.prototype);
13880
+ for (let i = 0; i < keys.length; ++i) {
13881
+ const key = keys[i];
13882
+ if (key !== 'entries' && key !== 'size' &&
13883
+ Map.prototype[key] === Map.prototype['entries']) {
13884
+ _symbolIterator = key;
13885
+ }
13886
+ }
13887
+ }
13888
+ }
13889
+ return _symbolIterator;
14024
13890
  }
13891
+
14025
13892
  /**
14026
- * Returns the attached `DebugNode` instance for an element in the DOM.
13893
+ * @license
13894
+ * Copyright Google LLC All Rights Reserved.
14027
13895
  *
14028
- * @param element DOM element which is owned by an existing component's view.
13896
+ * Use of this source code is governed by an MIT-style license that can be
13897
+ * found in the LICENSE file at https://angular.io/license
14029
13898
  */
14030
- function getDebugNode(element) {
14031
- if (ngDevMode && !(element instanceof Node)) {
14032
- throw new Error('Expecting instance of DOM Element');
13899
+ function isIterable(obj) {
13900
+ return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
13901
+ }
13902
+ function isListLikeIterable(obj) {
13903
+ if (!isJsObject(obj))
13904
+ return false;
13905
+ return Array.isArray(obj) ||
13906
+ (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
13907
+ getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
13908
+ }
13909
+ function areIterablesEqual(a, b, comparator) {
13910
+ const iterator1 = a[getSymbolIterator()]();
13911
+ const iterator2 = b[getSymbolIterator()]();
13912
+ while (true) {
13913
+ const item1 = iterator1.next();
13914
+ const item2 = iterator2.next();
13915
+ if (item1.done && item2.done)
13916
+ return true;
13917
+ if (item1.done || item2.done)
13918
+ return false;
13919
+ if (!comparator(item1.value, item2.value))
13920
+ return false;
14033
13921
  }
14034
- const lContext = getLContext(element);
14035
- const lView = lContext ? lContext.lView : null;
14036
- if (lView === null) {
14037
- return null;
13922
+ }
13923
+ function iterateListLike(obj, fn) {
13924
+ if (Array.isArray(obj)) {
13925
+ for (let i = 0; i < obj.length; i++) {
13926
+ fn(obj[i]);
13927
+ }
14038
13928
  }
14039
- const nodeIndex = lContext.nodeIndex;
14040
- if (nodeIndex !== -1) {
14041
- const valueInLView = lView[nodeIndex];
14042
- // this means that value in the lView is a component with its own
14043
- // data. In this situation the TNode is not accessed at the same spot.
14044
- const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
14045
- ngDevMode &&
14046
- assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
14047
- return buildDebugNode(tNode, lView);
13929
+ else {
13930
+ const iterator = obj[getSymbolIterator()]();
13931
+ let item;
13932
+ while (!((item = iterator.next()).done)) {
13933
+ fn(item.value);
13934
+ }
14048
13935
  }
14049
- return null;
14050
- }
14051
- /**
14052
- * Retrieve the component `LView` from component/element.
14053
- *
14054
- * NOTE: `LView` is a private and should not be leaked outside.
14055
- * Don't export this method to `ng.*` on window.
14056
- *
14057
- * @param target DOM element or component instance for which to retrieve the LView.
14058
- */
14059
- function getComponentLView(target) {
14060
- const lContext = getLContext(target);
14061
- const nodeIndx = lContext.nodeIndex;
14062
- const lView = lContext.lView;
14063
- ngDevMode && assertLView(lView);
14064
- const componentLView = lView[nodeIndx];
14065
- ngDevMode && assertLView(componentLView);
14066
- return componentLView;
14067
13936
  }
14068
- /** Asserts that a value is a DOM Element. */
14069
- function assertDomElement(value) {
14070
- if (typeof Element !== 'undefined' && !(value instanceof Element)) {
14071
- throw new Error('Expecting instance of DOM Element');
14072
- }
13937
+ function isJsObject(o) {
13938
+ return o !== null && (typeof o === 'function' || typeof o === 'object');
14073
13939
  }
14074
13940
 
14075
13941
  /**
@@ -14079,18 +13945,22 @@ function assertDomElement(value) {
14079
13945
  * Use of this source code is governed by an MIT-style license that can be
14080
13946
  * found in the LICENSE file at https://angular.io/license
14081
13947
  */
14082
- /**
14083
- * Marks a component for check (in case of OnPush components) and synchronously
14084
- * performs change detection on the application this component belongs to.
14085
- *
14086
- * @param component Component to {@link ChangeDetectorRef#markForCheck mark for check}.
14087
- *
14088
- * @publicApi
14089
- * @globalApi ng
14090
- */
14091
- function applyChanges(component) {
14092
- markDirty(component);
14093
- getRootComponents(component).forEach(rootComponent => detectChanges(rootComponent));
13948
+ function devModeEqual(a, b) {
13949
+ const isListLikeIterableA = isListLikeIterable(a);
13950
+ const isListLikeIterableB = isListLikeIterable(b);
13951
+ if (isListLikeIterableA && isListLikeIterableB) {
13952
+ return areIterablesEqual(a, b, devModeEqual);
13953
+ }
13954
+ else {
13955
+ const isAObject = a && (typeof a === 'object' || typeof a === 'function');
13956
+ const isBObject = b && (typeof b === 'object' || typeof b === 'function');
13957
+ if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
13958
+ return true;
13959
+ }
13960
+ else {
13961
+ return Object.is(a, b);
13962
+ }
13963
+ }
14094
13964
  }
14095
13965
 
14096
13966
  /**
@@ -14100,70 +13970,73 @@ function applyChanges(component) {
14100
13970
  * Use of this source code is governed by an MIT-style license that can be
14101
13971
  * found in the LICENSE file at https://angular.io/license
14102
13972
  */
13973
+ // TODO(misko): consider inlining
13974
+ /** Updates binding and returns the value. */
13975
+ function updateBinding(lView, bindingIndex, value) {
13976
+ return lView[bindingIndex] = value;
13977
+ }
13978
+ /** Gets the current binding value. */
13979
+ function getBinding(lView, bindingIndex) {
13980
+ ngDevMode && assertIndexInRange(lView, bindingIndex);
13981
+ ngDevMode &&
13982
+ assertNotSame(lView[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
13983
+ return lView[bindingIndex];
13984
+ }
14103
13985
  /**
14104
- * This file introduces series of globally accessible debug tools
14105
- * to allow for the Angular debugging story to function.
14106
- *
14107
- * To see this in action run the following command:
14108
- *
14109
- * bazel run //packages/core/test/bundling/todo:devserver
13986
+ * Updates binding if changed, then returns whether it was updated.
14110
13987
  *
14111
- * Then load `localhost:5432` and start using the console tools.
14112
- */
14113
- /**
14114
- * This value reflects the property on the window where the dev
14115
- * tools are patched (window.ng).
14116
- * */
14117
- const GLOBAL_PUBLISH_EXPANDO_KEY = 'ng';
14118
- let _published = false;
14119
- /**
14120
- * Publishes a collection of default debug tools onto`window.ng`.
13988
+ * This function also checks the `CheckNoChangesMode` and throws if changes are made.
13989
+ * Some changes (Objects/iterables) during `CheckNoChangesMode` are exempt to comply with VE
13990
+ * behavior.
14121
13991
  *
14122
- * These functions are available globally when Angular is in development
14123
- * mode and are automatically stripped away from prod mode is on.
13992
+ * @param lView current `LView`
13993
+ * @param bindingIndex The binding in the `LView` to check
13994
+ * @param value New value to check against `lView[bindingIndex]`
13995
+ * @returns `true` if the bindings has changed. (Throws if binding has changed during
13996
+ * `CheckNoChangesMode`)
14124
13997
  */
14125
- function publishDefaultGlobalUtils() {
14126
- if (!_published) {
14127
- _published = true;
14128
- /**
14129
- * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
14130
- * The contract of the function might be changed in any release and/or the function can be
14131
- * removed completely.
14132
- */
14133
- publishGlobalUtil('ɵsetProfiler', setProfiler);
14134
- publishGlobalUtil('getDirectiveMetadata', getDirectiveMetadata);
14135
- publishGlobalUtil('getComponent', getComponent$1);
14136
- publishGlobalUtil('getContext', getContext);
14137
- publishGlobalUtil('getListeners', getListeners);
14138
- publishGlobalUtil('getOwningComponent', getOwningComponent);
14139
- publishGlobalUtil('getHostElement', getHostElement);
14140
- publishGlobalUtil('getInjector', getInjector);
14141
- publishGlobalUtil('getRootComponents', getRootComponents);
14142
- publishGlobalUtil('getDirectives', getDirectives);
14143
- publishGlobalUtil('applyChanges', applyChanges);
13998
+ function bindingUpdated(lView, bindingIndex, value) {
13999
+ ngDevMode && assertNotSame(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
14000
+ ngDevMode &&
14001
+ assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
14002
+ const oldValue = lView[bindingIndex];
14003
+ if (Object.is(oldValue, value)) {
14004
+ return false;
14144
14005
  }
14145
- }
14146
- /**
14147
- * Publishes the given function to `window.ng` so that it can be
14148
- * used from the browser console when an application is not in production.
14149
- */
14150
- function publishGlobalUtil(name, fn) {
14151
- if (typeof COMPILED === 'undefined' || !COMPILED) {
14152
- // Note: we can't export `ng` when using closure enhanced optimization as:
14153
- // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
14154
- // - we can't declare a closure extern as the namespace `ng` is already used within Google
14155
- // for typings for AngularJS (via `goog.provide('ng....')`).
14156
- const w = _global$1;
14157
- ngDevMode && assertDefined(fn, 'function not defined');
14158
- if (w) {
14159
- let container = w[GLOBAL_PUBLISH_EXPANDO_KEY];
14160
- if (!container) {
14161
- container = w[GLOBAL_PUBLISH_EXPANDO_KEY] = {};
14006
+ else {
14007
+ if (ngDevMode && isInCheckNoChangesMode()) {
14008
+ // View engine didn't report undefined values as changed on the first checkNoChanges pass
14009
+ // (before the change detection was run).
14010
+ const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined;
14011
+ if (!devModeEqual(oldValueToCompare, value)) {
14012
+ const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
14013
+ throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName);
14162
14014
  }
14163
- container[name] = fn;
14015
+ // There was a change, but the `devModeEqual` decided that the change is exempt from an error.
14016
+ // For this reason we exit as if no change. The early exit is needed to prevent the changed
14017
+ // value to be written into `LView` (If we would write the new value that we would not see it
14018
+ // as change on next CD.)
14019
+ return false;
14164
14020
  }
14021
+ lView[bindingIndex] = value;
14022
+ return true;
14165
14023
  }
14166
14024
  }
14025
+ /** Updates 2 bindings if changed, then returns whether either was updated. */
14026
+ function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
14027
+ const different = bindingUpdated(lView, bindingIndex, exp1);
14028
+ return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
14029
+ }
14030
+ /** Updates 3 bindings if changed, then returns whether any was updated. */
14031
+ function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
14032
+ const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14033
+ return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
14034
+ }
14035
+ /** Updates 4 bindings if changed, then returns whether any was updated. */
14036
+ function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
14037
+ const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14038
+ return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
14039
+ }
14167
14040
 
14168
14041
  /**
14169
14042
  * @license
@@ -14172,817 +14045,377 @@ function publishGlobalUtil(name, fn) {
14172
14045
  * Use of this source code is governed by an MIT-style license that can be
14173
14046
  * found in the LICENSE file at https://angular.io/license
14174
14047
  */
14175
- // TODO: A hack to not pull in the NullInjector from @angular/core.
14176
- const NULL_INJECTOR = {
14177
- get: (token, notFoundValue) => {
14178
- throwProviderNotFoundError(token, 'NullInjector');
14179
- }
14180
- };
14181
14048
  /**
14182
- * Bootstraps a Component into an existing host element and returns an instance
14183
- * of the component.
14184
- *
14185
- * Use this function to bootstrap a component into the DOM tree. Each invocation
14186
- * of this function will create a separate tree of components, injectors and
14187
- * change detection cycles and lifetimes. To dynamically insert a new component
14188
- * into an existing tree such that it shares the same injection, change detection
14189
- * and object lifetime, use {@link ViewContainer#createComponent}.
14190
- *
14191
- * @param componentType Component to bootstrap
14192
- * @param options Optional parameters which control bootstrapping
14193
- */
14194
- function renderComponent(componentType /* Type as workaround for: Microsoft/TypeScript/issues/4881 */, opts = {}) {
14195
- ngDevMode && publishDefaultGlobalUtils();
14196
- ngDevMode && assertComponentType(componentType);
14197
- enableRenderer3();
14198
- const rendererFactory = opts.rendererFactory || domRendererFactory3;
14199
- const sanitizer = opts.sanitizer || null;
14200
- const componentDef = getComponentDef$1(componentType);
14201
- if (componentDef.type != componentType)
14202
- componentDef.type = componentType;
14203
- // The first index of the first selector is the tag name.
14204
- const componentTag = componentDef.selectors[0][0];
14205
- const hostRenderer = rendererFactory.createRenderer(null, null);
14206
- const hostRNode = locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
14207
- const rootFlags = componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
14208
- 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
14209
- const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
14210
- const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
14211
- const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
14212
- const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
14213
- enterView(rootView);
14214
- let component;
14215
- try {
14216
- if (rendererFactory.begin)
14217
- rendererFactory.begin();
14218
- const componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
14219
- component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
14220
- // create mode pass
14221
- renderView(rootTView, rootView, null);
14222
- // update mode pass
14223
- refreshView(rootTView, rootView, null, null);
14224
- }
14225
- finally {
14226
- leaveView();
14227
- if (rendererFactory.end)
14228
- rendererFactory.end();
14049
+ * Updates the value of or removes a bound attribute on an Element.
14050
+ *
14051
+ * Used in the case of `[attr.title]="value"`
14052
+ *
14053
+ * @param name name The name of the attribute.
14054
+ * @param value value The attribute is removed when value is `null` or `undefined`.
14055
+ * Otherwise the attribute value is set to the stringified value.
14056
+ * @param sanitizer An optional function used to sanitize the value.
14057
+ * @param namespace Optional namespace to use when setting the attribute.
14058
+ *
14059
+ * @codeGenApi
14060
+ */
14061
+ function ɵɵattribute(name, value, sanitizer, namespace) {
14062
+ const lView = getLView();
14063
+ const bindingIndex = nextBindingIndex();
14064
+ if (bindingUpdated(lView, bindingIndex, value)) {
14065
+ const tView = getTView();
14066
+ const tNode = getSelectedTNode();
14067
+ elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace);
14068
+ ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex);
14229
14069
  }
14230
- return component;
14070
+ return ɵɵattribute;
14231
14071
  }
14072
+
14232
14073
  /**
14233
- * Creates the root component view and the root component node.
14074
+ * @license
14075
+ * Copyright Google LLC All Rights Reserved.
14234
14076
  *
14235
- * @param rNode Render host element.
14236
- * @param def ComponentDef
14237
- * @param rootView The parent view where the host node is stored
14238
- * @param rendererFactory Factory to be used for creating child renderers.
14239
- * @param hostRenderer The current renderer
14240
- * @param sanitizer The sanitizer, if provided
14077
+ * Use of this source code is governed by an MIT-style license that can be
14078
+ * found in the LICENSE file at https://angular.io/license
14079
+ */
14080
+ /**
14081
+ * Create interpolation bindings with a variable number of expressions.
14241
14082
  *
14242
- * @returns Component view created
14083
+ * If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
14084
+ * Those are faster because there is no need to create an array of expressions and iterate over it.
14085
+ *
14086
+ * `values`:
14087
+ * - has static text at even indexes,
14088
+ * - has evaluated expressions at odd indexes.
14089
+ *
14090
+ * Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
14243
14091
  */
14244
- function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
14245
- const tView = rootView[TVIEW];
14246
- const index = HEADER_OFFSET;
14247
- ngDevMode && assertIndexInRange(rootView, index);
14248
- rootView[index] = rNode;
14249
- // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
14250
- // the same time we want to communicate the debug `TNode` that this is a special `TNode`
14251
- // representing a host element.
14252
- const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
14253
- const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
14254
- if (mergedAttrs !== null) {
14255
- computeStaticStyling(tNode, mergedAttrs, true);
14256
- if (rNode !== null) {
14257
- setUpAttributes(hostRenderer, rNode, mergedAttrs);
14258
- if (tNode.classes !== null) {
14259
- writeDirectClass(hostRenderer, rNode, tNode.classes);
14260
- }
14261
- if (tNode.styles !== null) {
14262
- writeDirectStyle(hostRenderer, rNode, tNode.styles);
14263
- }
14264
- }
14092
+ function interpolationV(lView, values) {
14093
+ ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
14094
+ ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
14095
+ let isBindingUpdated = false;
14096
+ let bindingIndex = getBindingIndex();
14097
+ for (let i = 1; i < values.length; i += 2) {
14098
+ // Check if bindings (odd indexes) have changed
14099
+ isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
14265
14100
  }
14266
- const viewRenderer = rendererFactory.createRenderer(rNode, def);
14267
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14268
- if (tView.firstCreatePass) {
14269
- diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14270
- markAsComponentHost(tView, tNode);
14271
- initTNodeFlags(tNode, rootView.length, 1);
14101
+ setBindingIndex(bindingIndex);
14102
+ if (!isBindingUpdated) {
14103
+ return NO_CHANGE;
14272
14104
  }
14273
- addToViewTree(rootView, componentView);
14274
- // Store component view at node index, with node as the HOST
14275
- return rootView[index] = componentView;
14105
+ // Build the updated content
14106
+ let content = values[0];
14107
+ for (let i = 1; i < values.length; i += 2) {
14108
+ content += renderStringify(values[i]) + values[i + 1];
14109
+ }
14110
+ return content;
14276
14111
  }
14277
14112
  /**
14278
- * Creates a root component and sets it up with features and host bindings. Shared by
14279
- * renderComponent() and ViewContainerRef.createComponent().
14113
+ * Creates an interpolation binding with 1 expression.
14114
+ *
14115
+ * @param prefix static value used for concatenation only.
14116
+ * @param v0 value checked for change.
14117
+ * @param suffix static value used for concatenation only.
14280
14118
  */
14281
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
14282
- const tView = rootLView[TVIEW];
14283
- // Create directive instance with factory() and store at next index in viewData
14284
- const component = instantiateRootComponent(tView, rootLView, componentDef);
14285
- rootContext.components.push(component);
14286
- componentView[CONTEXT] = component;
14287
- if (hostFeatures !== null) {
14288
- for (const feature of hostFeatures) {
14289
- feature(component, componentDef);
14290
- }
14291
- }
14292
- // We want to generate an empty QueryList for root content queries for backwards
14293
- // compatibility with ViewEngine.
14294
- if (componentDef.contentQueries) {
14295
- const tNode = getCurrentTNode();
14296
- ngDevMode && assertDefined(tNode, 'TNode expected');
14297
- componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
14298
- }
14299
- const rootTNode = getCurrentTNode();
14300
- ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
14301
- if (tView.firstCreatePass &&
14302
- (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
14303
- setSelectedIndex(rootTNode.index);
14304
- const rootTView = rootLView[TVIEW];
14305
- registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
14306
- invokeHostBindingsInCreationMode(componentDef, component);
14307
- }
14308
- return component;
14119
+ function interpolation1(lView, prefix, v0, suffix) {
14120
+ const different = bindingUpdated(lView, nextBindingIndex(), v0);
14121
+ return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
14309
14122
  }
14310
- function createRootContext(scheduler, playerHandler) {
14311
- return {
14312
- components: [],
14313
- scheduler: scheduler || defaultScheduler,
14314
- clean: CLEAN_PROMISE,
14315
- playerHandler: playerHandler || null,
14316
- flags: 0 /* RootContextFlags.Empty */
14317
- };
14123
+ /**
14124
+ * Creates an interpolation binding with 2 expressions.
14125
+ */
14126
+ function interpolation2(lView, prefix, v0, i0, v1, suffix) {
14127
+ const bindingIndex = getBindingIndex();
14128
+ const different = bindingUpdated2(lView, bindingIndex, v0, v1);
14129
+ incrementBindingIndex(2);
14130
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
14318
14131
  }
14319
14132
  /**
14320
- * Used to enable lifecycle hooks on the root component.
14321
- *
14322
- * Include this feature when calling `renderComponent` if the root component
14323
- * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
14324
- * be called properly.
14325
- *
14326
- * Example:
14327
- *
14328
- * ```
14329
- * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
14330
- * ```
14133
+ * Creates an interpolation binding with 3 expressions.
14331
14134
  */
14332
- function LifecycleHooksFeature() {
14333
- const tNode = getCurrentTNode();
14334
- ngDevMode && assertDefined(tNode, 'TNode is required');
14335
- registerPostOrderHooks(getLView()[TVIEW], tNode);
14135
+ function interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix) {
14136
+ const bindingIndex = getBindingIndex();
14137
+ const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
14138
+ incrementBindingIndex(3);
14139
+ return different ?
14140
+ prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
14141
+ NO_CHANGE;
14336
14142
  }
14337
14143
  /**
14338
- * Wait on component until it is rendered.
14339
- *
14340
- * This function returns a `Promise` which is resolved when the component's
14341
- * change detection is executed. This is determined by finding the scheduler
14342
- * associated with the `component`'s render tree and waiting until the scheduler
14343
- * flushes. If nothing is scheduled, the function returns a resolved promise.
14344
- *
14345
- * Example:
14346
- * ```
14347
- * await whenRendered(myComponent);
14348
- * ```
14349
- *
14350
- * @param component Component to wait upon
14351
- * @returns Promise which resolves when the component is rendered.
14144
+ * Create an interpolation binding with 4 expressions.
14352
14145
  */
14353
- function whenRendered(component) {
14354
- return getRootContext(component).clean;
14146
+ function interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix) {
14147
+ const bindingIndex = getBindingIndex();
14148
+ const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14149
+ incrementBindingIndex(4);
14150
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14151
+ renderStringify(v2) + i2 + renderStringify(v3) + suffix :
14152
+ NO_CHANGE;
14355
14153
  }
14356
-
14357
14154
  /**
14358
- * @license
14359
- * Copyright Google LLC All Rights Reserved.
14360
- *
14361
- * Use of this source code is governed by an MIT-style license that can be
14362
- * found in the LICENSE file at https://angular.io/license
14155
+ * Creates an interpolation binding with 5 expressions.
14363
14156
  */
14364
- function getSuperType(type) {
14365
- return Object.getPrototypeOf(type.prototype).constructor;
14157
+ function interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix) {
14158
+ const bindingIndex = getBindingIndex();
14159
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14160
+ different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
14161
+ incrementBindingIndex(5);
14162
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14163
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
14164
+ NO_CHANGE;
14366
14165
  }
14367
14166
  /**
14368
- * Merges the definition from a super class to a sub class.
14369
- * @param definition The definition that is a SubClass of another directive of component
14370
- *
14371
- * @codeGenApi
14167
+ * Creates an interpolation binding with 6 expressions.
14372
14168
  */
14373
- function ɵɵInheritDefinitionFeature(definition) {
14374
- let superType = getSuperType(definition.type);
14375
- let shouldInheritFields = true;
14376
- const inheritanceChain = [definition];
14377
- while (superType) {
14378
- let superDef = undefined;
14379
- if (isComponentDef(definition)) {
14380
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14381
- superDef = superType.ɵcmp || superType.ɵdir;
14382
- }
14383
- else {
14384
- if (superType.ɵcmp) {
14385
- throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
14386
- `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
14387
- }
14388
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14389
- superDef = superType.ɵdir;
14390
- }
14391
- if (superDef) {
14392
- if (shouldInheritFields) {
14393
- inheritanceChain.push(superDef);
14394
- // Some fields in the definition may be empty, if there were no values to put in them that
14395
- // would've justified object creation. Unwrap them if necessary.
14396
- const writeableDef = definition;
14397
- writeableDef.inputs = maybeUnwrapEmpty(definition.inputs);
14398
- writeableDef.declaredInputs = maybeUnwrapEmpty(definition.declaredInputs);
14399
- writeableDef.outputs = maybeUnwrapEmpty(definition.outputs);
14400
- // Merge hostBindings
14401
- const superHostBindings = superDef.hostBindings;
14402
- superHostBindings && inheritHostBindings(definition, superHostBindings);
14403
- // Merge queries
14404
- const superViewQuery = superDef.viewQuery;
14405
- const superContentQueries = superDef.contentQueries;
14406
- superViewQuery && inheritViewQuery(definition, superViewQuery);
14407
- superContentQueries && inheritContentQueries(definition, superContentQueries);
14408
- // Merge inputs and outputs
14409
- fillProperties(definition.inputs, superDef.inputs);
14410
- fillProperties(definition.declaredInputs, superDef.declaredInputs);
14411
- fillProperties(definition.outputs, superDef.outputs);
14412
- // Merge animations metadata.
14413
- // If `superDef` is a Component, the `data` field is present (defaults to an empty object).
14414
- if (isComponentDef(superDef) && superDef.data.animation) {
14415
- // If super def is a Component, the `definition` is also a Component, since Directives can
14416
- // not inherit Components (we throw an error above and cannot reach this code).
14417
- const defData = definition.data;
14418
- defData.animation = (defData.animation || []).concat(superDef.data.animation);
14419
- }
14420
- }
14421
- // Run parent features
14422
- const features = superDef.features;
14423
- if (features) {
14424
- for (let i = 0; i < features.length; i++) {
14425
- const feature = features[i];
14426
- if (feature && feature.ngInherit) {
14427
- feature(definition);
14428
- }
14429
- // If `InheritDefinitionFeature` is a part of the current `superDef`, it means that this
14430
- // def already has all the necessary information inherited from its super class(es), so we
14431
- // can stop merging fields from super classes. However we need to iterate through the
14432
- // prototype chain to look for classes that might contain other "features" (like
14433
- // NgOnChanges), which we should invoke for the original `definition`. We set the
14434
- // `shouldInheritFields` flag to indicate that, essentially skipping fields inheritance
14435
- // logic and only invoking functions from the "features" list.
14436
- if (feature === ɵɵInheritDefinitionFeature) {
14437
- shouldInheritFields = false;
14438
- }
14439
- }
14440
- }
14441
- }
14442
- superType = Object.getPrototypeOf(superType);
14443
- }
14444
- mergeHostAttrsAcrossInheritance(inheritanceChain);
14169
+ function interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix) {
14170
+ const bindingIndex = getBindingIndex();
14171
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14172
+ different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
14173
+ incrementBindingIndex(6);
14174
+ return different ?
14175
+ prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
14176
+ renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
14177
+ NO_CHANGE;
14445
14178
  }
14446
14179
  /**
14447
- * Merge the `hostAttrs` and `hostVars` from the inherited parent to the base class.
14448
- *
14449
- * @param inheritanceChain A list of `WritableDefs` starting at the top most type and listing
14450
- * sub-types in order. For each type take the `hostAttrs` and `hostVars` and merge it with the child
14451
- * type.
14180
+ * Creates an interpolation binding with 7 expressions.
14452
14181
  */
14453
- function mergeHostAttrsAcrossInheritance(inheritanceChain) {
14454
- let hostVars = 0;
14455
- let hostAttrs = null;
14456
- // We process the inheritance order from the base to the leaves here.
14457
- for (let i = inheritanceChain.length - 1; i >= 0; i--) {
14458
- const def = inheritanceChain[i];
14459
- // For each `hostVars`, we need to add the superclass amount.
14460
- def.hostVars = (hostVars += def.hostVars);
14461
- // for each `hostAttrs` we need to merge it with superclass.
14462
- def.hostAttrs =
14463
- mergeHostAttrs(def.hostAttrs, hostAttrs = mergeHostAttrs(hostAttrs, def.hostAttrs));
14464
- }
14465
- }
14466
- function maybeUnwrapEmpty(value) {
14467
- if (value === EMPTY_OBJ) {
14468
- return {};
14469
- }
14470
- else if (value === EMPTY_ARRAY) {
14471
- return [];
14472
- }
14473
- else {
14474
- return value;
14475
- }
14476
- }
14477
- function inheritViewQuery(definition, superViewQuery) {
14478
- const prevViewQuery = definition.viewQuery;
14479
- if (prevViewQuery) {
14480
- definition.viewQuery = (rf, ctx) => {
14481
- superViewQuery(rf, ctx);
14482
- prevViewQuery(rf, ctx);
14483
- };
14484
- }
14485
- else {
14486
- definition.viewQuery = superViewQuery;
14487
- }
14488
- }
14489
- function inheritContentQueries(definition, superContentQueries) {
14490
- const prevContentQueries = definition.contentQueries;
14491
- if (prevContentQueries) {
14492
- definition.contentQueries = (rf, ctx, directiveIndex) => {
14493
- superContentQueries(rf, ctx, directiveIndex);
14494
- prevContentQueries(rf, ctx, directiveIndex);
14495
- };
14496
- }
14497
- else {
14498
- definition.contentQueries = superContentQueries;
14499
- }
14182
+ function interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix) {
14183
+ const bindingIndex = getBindingIndex();
14184
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14185
+ different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
14186
+ incrementBindingIndex(7);
14187
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14188
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14189
+ renderStringify(v5) + i5 + renderStringify(v6) + suffix :
14190
+ NO_CHANGE;
14500
14191
  }
14501
- function inheritHostBindings(definition, superHostBindings) {
14502
- const prevHostBindings = definition.hostBindings;
14503
- if (prevHostBindings) {
14504
- definition.hostBindings = (rf, ctx) => {
14505
- superHostBindings(rf, ctx);
14506
- prevHostBindings(rf, ctx);
14507
- };
14508
- }
14509
- else {
14510
- definition.hostBindings = superHostBindings;
14511
- }
14192
+ /**
14193
+ * Creates an interpolation binding with 8 expressions.
14194
+ */
14195
+ function interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix) {
14196
+ const bindingIndex = getBindingIndex();
14197
+ let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14198
+ different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
14199
+ incrementBindingIndex(8);
14200
+ return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14201
+ renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14202
+ renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
14203
+ NO_CHANGE;
14512
14204
  }
14513
14205
 
14514
14206
  /**
14515
- * @license
14516
- * Copyright Google LLC All Rights Reserved.
14517
14207
  *
14518
- * Use of this source code is governed by an MIT-style license that can be
14519
- * found in the LICENSE file at https://angular.io/license
14520
- */
14521
- /**
14522
- * Fields which exist on either directive or component definitions, and need to be copied from
14523
- * parent to child classes by the `ɵɵCopyDefinitionFeature`.
14524
- */
14525
- const COPY_DIRECTIVE_FIELDS = [
14526
- // The child class should use the providers of its parent.
14527
- 'providersResolver',
14528
- // Not listed here are any fields which are handled by the `ɵɵInheritDefinitionFeature`, such
14529
- // as inputs, outputs, and host binding functions.
14530
- ];
14531
- /**
14532
- * Fields which exist only on component definitions, and need to be copied from parent to child
14533
- * classes by the `ɵɵCopyDefinitionFeature`.
14208
+ * Update an interpolated attribute on an element with single bound value surrounded by text.
14534
14209
  *
14535
- * The type here allows any field of `ComponentDef` which is not also a property of `DirectiveDef`,
14536
- * since those should go in `COPY_DIRECTIVE_FIELDS` above.
14537
- */
14538
- const COPY_COMPONENT_FIELDS = [
14539
- // The child class should use the template function of its parent, including all template
14540
- // semantics.
14541
- 'template',
14542
- 'decls',
14543
- 'consts',
14544
- 'vars',
14545
- 'onPush',
14546
- 'ngContentSelectors',
14547
- // The child class should use the CSS styles of its parent, including all styling semantics.
14548
- 'styles',
14549
- 'encapsulation',
14550
- // The child class should be checked by the runtime in the same way as its parent.
14551
- 'schemas',
14552
- ];
14553
- /**
14554
- * Copies the fields not handled by the `ɵɵInheritDefinitionFeature` from the supertype of a
14555
- * definition.
14210
+ * Used when the value passed to a property has 1 interpolated value in it:
14556
14211
  *
14557
- * This exists primarily to support ngcc migration of an existing View Engine pattern, where an
14558
- * entire decorator is inherited from a parent to a child class. When ngcc detects this case, it
14559
- * generates a skeleton definition on the child class, and applies this feature.
14212
+ * ```html
14213
+ * <div attr.title="prefix{{v0}}suffix"></div>
14214
+ * ```
14560
14215
  *
14561
- * The `ɵɵCopyDefinitionFeature` then copies any needed fields from the parent class' definition,
14562
- * including things like the component template function.
14216
+ * Its compiled representation is::
14563
14217
  *
14564
- * @param definition The definition of a child class which inherits from a parent class with its
14565
- * own definition.
14218
+ * ```ts
14219
+ * ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
14220
+ * ```
14566
14221
  *
14222
+ * @param attrName The name of the attribute to update
14223
+ * @param prefix Static value used for concatenation only.
14224
+ * @param v0 Value checked for change.
14225
+ * @param suffix Static value used for concatenation only.
14226
+ * @param sanitizer An optional sanitizer function
14227
+ * @returns itself, so that it may be chained.
14567
14228
  * @codeGenApi
14568
14229
  */
14569
- function ɵɵCopyDefinitionFeature(definition) {
14570
- let superType = getSuperType(definition.type);
14571
- let superDef = undefined;
14572
- if (isComponentDef(definition)) {
14573
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14574
- superDef = superType.ɵcmp;
14575
- }
14576
- else {
14577
- // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
14578
- superDef = superType.ɵdir;
14579
- }
14580
- // Needed because `definition` fields are readonly.
14581
- const defAny = definition;
14582
- // Copy over any fields that apply to either directives or components.
14583
- for (const field of COPY_DIRECTIVE_FIELDS) {
14584
- defAny[field] = superDef[field];
14585
- }
14586
- if (isComponentDef(superDef)) {
14587
- // Copy over any component-specific fields.
14588
- for (const field of COPY_COMPONENT_FIELDS) {
14589
- defAny[field] = superDef[field];
14590
- }
14230
+ function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
14231
+ const lView = getLView();
14232
+ const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
14233
+ if (interpolatedValue !== NO_CHANGE) {
14234
+ const tNode = getSelectedTNode();
14235
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14236
+ ngDevMode &&
14237
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
14591
14238
  }
14239
+ return ɵɵattributeInterpolate1;
14592
14240
  }
14593
-
14594
14241
  /**
14595
- * @license
14596
- * Copyright Google LLC All Rights Reserved.
14597
14242
  *
14598
- * Use of this source code is governed by an MIT-style license that can be
14599
- * found in the LICENSE file at https://angular.io/license
14600
- */
14601
- let _symbolIterator = null;
14602
- function getSymbolIterator() {
14603
- if (!_symbolIterator) {
14604
- const Symbol = _global$1['Symbol'];
14605
- if (Symbol && Symbol.iterator) {
14606
- _symbolIterator = Symbol.iterator;
14607
- }
14608
- else {
14609
- // es6-shim specific logic
14610
- const keys = Object.getOwnPropertyNames(Map.prototype);
14611
- for (let i = 0; i < keys.length; ++i) {
14612
- const key = keys[i];
14613
- if (key !== 'entries' && key !== 'size' &&
14614
- Map.prototype[key] === Map.prototype['entries']) {
14615
- _symbolIterator = key;
14616
- }
14617
- }
14618
- }
14619
- }
14620
- return _symbolIterator;
14621
- }
14622
-
14623
- /**
14624
- * @license
14625
- * Copyright Google LLC All Rights Reserved.
14243
+ * Update an interpolated attribute on an element with 2 bound values surrounded by text.
14626
14244
  *
14627
- * Use of this source code is governed by an MIT-style license that can be
14628
- * found in the LICENSE file at https://angular.io/license
14629
- */
14630
- function isIterable(obj) {
14631
- return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
14632
- }
14633
- function isListLikeIterable(obj) {
14634
- if (!isJsObject(obj))
14635
- return false;
14636
- return Array.isArray(obj) ||
14637
- (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
14638
- getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
14639
- }
14640
- function areIterablesEqual(a, b, comparator) {
14641
- const iterator1 = a[getSymbolIterator()]();
14642
- const iterator2 = b[getSymbolIterator()]();
14643
- while (true) {
14644
- const item1 = iterator1.next();
14645
- const item2 = iterator2.next();
14646
- if (item1.done && item2.done)
14647
- return true;
14648
- if (item1.done || item2.done)
14649
- return false;
14650
- if (!comparator(item1.value, item2.value))
14651
- return false;
14652
- }
14653
- }
14654
- function iterateListLike(obj, fn) {
14655
- if (Array.isArray(obj)) {
14656
- for (let i = 0; i < obj.length; i++) {
14657
- fn(obj[i]);
14658
- }
14659
- }
14660
- else {
14661
- const iterator = obj[getSymbolIterator()]();
14662
- let item;
14663
- while (!((item = iterator.next()).done)) {
14664
- fn(item.value);
14665
- }
14666
- }
14667
- }
14668
- function isJsObject(o) {
14669
- return o !== null && (typeof o === 'function' || typeof o === 'object');
14670
- }
14671
-
14672
- /**
14673
- * @license
14674
- * Copyright Google LLC All Rights Reserved.
14245
+ * Used when the value passed to a property has 2 interpolated values in it:
14675
14246
  *
14676
- * Use of this source code is governed by an MIT-style license that can be
14677
- * found in the LICENSE file at https://angular.io/license
14247
+ * ```html
14248
+ * <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
14249
+ * ```
14250
+ *
14251
+ * Its compiled representation is::
14252
+ *
14253
+ * ```ts
14254
+ * ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
14255
+ * ```
14256
+ *
14257
+ * @param attrName The name of the attribute to update
14258
+ * @param prefix Static value used for concatenation only.
14259
+ * @param v0 Value checked for change.
14260
+ * @param i0 Static value used for concatenation only.
14261
+ * @param v1 Value checked for change.
14262
+ * @param suffix Static value used for concatenation only.
14263
+ * @param sanitizer An optional sanitizer function
14264
+ * @returns itself, so that it may be chained.
14265
+ * @codeGenApi
14678
14266
  */
14679
- function devModeEqual(a, b) {
14680
- const isListLikeIterableA = isListLikeIterable(a);
14681
- const isListLikeIterableB = isListLikeIterable(b);
14682
- if (isListLikeIterableA && isListLikeIterableB) {
14683
- return areIterablesEqual(a, b, devModeEqual);
14684
- }
14685
- else {
14686
- const isAObject = a && (typeof a === 'object' || typeof a === 'function');
14687
- const isBObject = b && (typeof b === 'object' || typeof b === 'function');
14688
- if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
14689
- return true;
14690
- }
14691
- else {
14692
- return Object.is(a, b);
14693
- }
14267
+ function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
14268
+ const lView = getLView();
14269
+ const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
14270
+ if (interpolatedValue !== NO_CHANGE) {
14271
+ const tNode = getSelectedTNode();
14272
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14273
+ ngDevMode &&
14274
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
14694
14275
  }
14276
+ return ɵɵattributeInterpolate2;
14695
14277
  }
14696
-
14697
14278
  /**
14698
- * @license
14699
- * Copyright Google LLC All Rights Reserved.
14700
14279
  *
14701
- * Use of this source code is governed by an MIT-style license that can be
14702
- * found in the LICENSE file at https://angular.io/license
14703
- */
14704
- // TODO(misko): consider inlining
14705
- /** Updates binding and returns the value. */
14706
- function updateBinding(lView, bindingIndex, value) {
14707
- return lView[bindingIndex] = value;
14708
- }
14709
- /** Gets the current binding value. */
14710
- function getBinding(lView, bindingIndex) {
14711
- ngDevMode && assertIndexInRange(lView, bindingIndex);
14712
- ngDevMode &&
14713
- assertNotSame(lView[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
14714
- return lView[bindingIndex];
14715
- }
14716
- /**
14717
- * Updates binding if changed, then returns whether it was updated.
14280
+ * Update an interpolated attribute on an element with 3 bound values surrounded by text.
14718
14281
  *
14719
- * This function also checks the `CheckNoChangesMode` and throws if changes are made.
14720
- * Some changes (Objects/iterables) during `CheckNoChangesMode` are exempt to comply with VE
14721
- * behavior.
14282
+ * Used when the value passed to a property has 3 interpolated values in it:
14722
14283
  *
14723
- * @param lView current `LView`
14724
- * @param bindingIndex The binding in the `LView` to check
14725
- * @param value New value to check against `lView[bindingIndex]`
14726
- * @returns `true` if the bindings has changed. (Throws if binding has changed during
14727
- * `CheckNoChangesMode`)
14284
+ * ```html
14285
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
14286
+ * ```
14287
+ *
14288
+ * Its compiled representation is::
14289
+ *
14290
+ * ```ts
14291
+ * ɵɵattributeInterpolate3(
14292
+ * 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
14293
+ * ```
14294
+ *
14295
+ * @param attrName The name of the attribute to update
14296
+ * @param prefix Static value used for concatenation only.
14297
+ * @param v0 Value checked for change.
14298
+ * @param i0 Static value used for concatenation only.
14299
+ * @param v1 Value checked for change.
14300
+ * @param i1 Static value used for concatenation only.
14301
+ * @param v2 Value checked for change.
14302
+ * @param suffix Static value used for concatenation only.
14303
+ * @param sanitizer An optional sanitizer function
14304
+ * @returns itself, so that it may be chained.
14305
+ * @codeGenApi
14728
14306
  */
14729
- function bindingUpdated(lView, bindingIndex, value) {
14730
- ngDevMode && assertNotSame(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
14731
- ngDevMode &&
14732
- assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
14733
- const oldValue = lView[bindingIndex];
14734
- if (Object.is(oldValue, value)) {
14735
- return false;
14736
- }
14737
- else {
14738
- if (ngDevMode && isInCheckNoChangesMode()) {
14739
- // View engine didn't report undefined values as changed on the first checkNoChanges pass
14740
- // (before the change detection was run).
14741
- const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined;
14742
- if (!devModeEqual(oldValueToCompare, value)) {
14743
- const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
14744
- throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName);
14745
- }
14746
- // There was a change, but the `devModeEqual` decided that the change is exempt from an error.
14747
- // For this reason we exit as if no change. The early exit is needed to prevent the changed
14748
- // value to be written into `LView` (If we would write the new value that we would not see it
14749
- // as change on next CD.)
14750
- return false;
14751
- }
14752
- lView[bindingIndex] = value;
14753
- return true;
14307
+ function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
14308
+ const lView = getLView();
14309
+ const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
14310
+ if (interpolatedValue !== NO_CHANGE) {
14311
+ const tNode = getSelectedTNode();
14312
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14313
+ ngDevMode &&
14314
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
14754
14315
  }
14316
+ return ɵɵattributeInterpolate3;
14755
14317
  }
14756
- /** Updates 2 bindings if changed, then returns whether either was updated. */
14757
- function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
14758
- const different = bindingUpdated(lView, bindingIndex, exp1);
14759
- return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
14760
- }
14761
- /** Updates 3 bindings if changed, then returns whether any was updated. */
14762
- function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
14763
- const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14764
- return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
14765
- }
14766
- /** Updates 4 bindings if changed, then returns whether any was updated. */
14767
- function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
14768
- const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
14769
- return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
14770
- }
14771
-
14772
14318
  /**
14773
- * @license
14774
- * Copyright Google LLC All Rights Reserved.
14775
14319
  *
14776
- * Use of this source code is governed by an MIT-style license that can be
14777
- * found in the LICENSE file at https://angular.io/license
14778
- */
14779
- /**
14780
- * Updates the value of or removes a bound attribute on an Element.
14320
+ * Update an interpolated attribute on an element with 4 bound values surrounded by text.
14781
14321
  *
14782
- * Used in the case of `[attr.title]="value"`
14322
+ * Used when the value passed to a property has 4 interpolated values in it:
14783
14323
  *
14784
- * @param name name The name of the attribute.
14785
- * @param value value The attribute is removed when value is `null` or `undefined`.
14786
- * Otherwise the attribute value is set to the stringified value.
14787
- * @param sanitizer An optional function used to sanitize the value.
14788
- * @param namespace Optional namespace to use when setting the attribute.
14324
+ * ```html
14325
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}suffix"></div>
14326
+ * ```
14327
+ *
14328
+ * Its compiled representation is::
14329
+ *
14330
+ * ```ts
14331
+ * ɵɵattributeInterpolate4(
14332
+ * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, 'suffix');
14333
+ * ```
14789
14334
  *
14335
+ * @param attrName The name of the attribute to update
14336
+ * @param prefix Static value used for concatenation only.
14337
+ * @param v0 Value checked for change.
14338
+ * @param i0 Static value used for concatenation only.
14339
+ * @param v1 Value checked for change.
14340
+ * @param i1 Static value used for concatenation only.
14341
+ * @param v2 Value checked for change.
14342
+ * @param i2 Static value used for concatenation only.
14343
+ * @param v3 Value checked for change.
14344
+ * @param suffix Static value used for concatenation only.
14345
+ * @param sanitizer An optional sanitizer function
14346
+ * @returns itself, so that it may be chained.
14790
14347
  * @codeGenApi
14791
14348
  */
14792
- function ɵɵattribute(name, value, sanitizer, namespace) {
14349
+ function ɵɵattributeInterpolate4(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, suffix, sanitizer, namespace) {
14793
14350
  const lView = getLView();
14794
- const bindingIndex = nextBindingIndex();
14795
- if (bindingUpdated(lView, bindingIndex, value)) {
14796
- const tView = getTView();
14351
+ const interpolatedValue = interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix);
14352
+ if (interpolatedValue !== NO_CHANGE) {
14797
14353
  const tNode = getSelectedTNode();
14798
- elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace);
14799
- ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex);
14354
+ elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14355
+ ngDevMode &&
14356
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0, i1, i2, suffix);
14800
14357
  }
14801
- return ɵɵattribute;
14358
+ return ɵɵattributeInterpolate4;
14802
14359
  }
14803
-
14804
14360
  /**
14805
- * @license
14806
- * Copyright Google LLC All Rights Reserved.
14807
14361
  *
14808
- * Use of this source code is governed by an MIT-style license that can be
14809
- * found in the LICENSE file at https://angular.io/license
14810
- */
14811
- /**
14812
- * Create interpolation bindings with a variable number of expressions.
14362
+ * Update an interpolated attribute on an element with 5 bound values surrounded by text.
14813
14363
  *
14814
- * If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
14815
- * Those are faster because there is no need to create an array of expressions and iterate over it.
14816
- *
14817
- * `values`:
14818
- * - has static text at even indexes,
14819
- * - has evaluated expressions at odd indexes.
14820
- *
14821
- * Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
14822
- */
14823
- function interpolationV(lView, values) {
14824
- ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
14825
- ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
14826
- let isBindingUpdated = false;
14827
- let bindingIndex = getBindingIndex();
14828
- for (let i = 1; i < values.length; i += 2) {
14829
- // Check if bindings (odd indexes) have changed
14830
- isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
14831
- }
14832
- setBindingIndex(bindingIndex);
14833
- if (!isBindingUpdated) {
14834
- return NO_CHANGE;
14835
- }
14836
- // Build the updated content
14837
- let content = values[0];
14838
- for (let i = 1; i < values.length; i += 2) {
14839
- content += renderStringify(values[i]) + values[i + 1];
14840
- }
14841
- return content;
14842
- }
14843
- /**
14844
- * Creates an interpolation binding with 1 expression.
14845
- *
14846
- * @param prefix static value used for concatenation only.
14847
- * @param v0 value checked for change.
14848
- * @param suffix static value used for concatenation only.
14849
- */
14850
- function interpolation1(lView, prefix, v0, suffix) {
14851
- const different = bindingUpdated(lView, nextBindingIndex(), v0);
14852
- return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
14853
- }
14854
- /**
14855
- * Creates an interpolation binding with 2 expressions.
14856
- */
14857
- function interpolation2(lView, prefix, v0, i0, v1, suffix) {
14858
- const bindingIndex = getBindingIndex();
14859
- const different = bindingUpdated2(lView, bindingIndex, v0, v1);
14860
- incrementBindingIndex(2);
14861
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
14862
- }
14863
- /**
14864
- * Creates an interpolation binding with 3 expressions.
14865
- */
14866
- function interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix) {
14867
- const bindingIndex = getBindingIndex();
14868
- const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
14869
- incrementBindingIndex(3);
14870
- return different ?
14871
- prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
14872
- NO_CHANGE;
14873
- }
14874
- /**
14875
- * Create an interpolation binding with 4 expressions.
14876
- */
14877
- function interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix) {
14878
- const bindingIndex = getBindingIndex();
14879
- const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14880
- incrementBindingIndex(4);
14881
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14882
- renderStringify(v2) + i2 + renderStringify(v3) + suffix :
14883
- NO_CHANGE;
14884
- }
14885
- /**
14886
- * Creates an interpolation binding with 5 expressions.
14887
- */
14888
- function interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix) {
14889
- const bindingIndex = getBindingIndex();
14890
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14891
- different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
14892
- incrementBindingIndex(5);
14893
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14894
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
14895
- NO_CHANGE;
14896
- }
14897
- /**
14898
- * Creates an interpolation binding with 6 expressions.
14899
- */
14900
- function interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix) {
14901
- const bindingIndex = getBindingIndex();
14902
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14903
- different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
14904
- incrementBindingIndex(6);
14905
- return different ?
14906
- prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
14907
- renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
14908
- NO_CHANGE;
14909
- }
14910
- /**
14911
- * Creates an interpolation binding with 7 expressions.
14912
- */
14913
- function interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix) {
14914
- const bindingIndex = getBindingIndex();
14915
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14916
- different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
14917
- incrementBindingIndex(7);
14918
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14919
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14920
- renderStringify(v5) + i5 + renderStringify(v6) + suffix :
14921
- NO_CHANGE;
14922
- }
14923
- /**
14924
- * Creates an interpolation binding with 8 expressions.
14925
- */
14926
- function interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix) {
14927
- const bindingIndex = getBindingIndex();
14928
- let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
14929
- different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
14930
- incrementBindingIndex(8);
14931
- return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
14932
- renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
14933
- renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
14934
- NO_CHANGE;
14935
- }
14936
-
14937
- /**
14938
- *
14939
- * Update an interpolated attribute on an element with single bound value surrounded by text.
14940
- *
14941
- * Used when the value passed to a property has 1 interpolated value in it:
14364
+ * Used when the value passed to a property has 5 interpolated values in it:
14942
14365
  *
14943
14366
  * ```html
14944
- * <div attr.title="prefix{{v0}}suffix"></div>
14367
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}suffix"></div>
14945
14368
  * ```
14946
14369
  *
14947
14370
  * Its compiled representation is::
14948
14371
  *
14949
14372
  * ```ts
14950
- * ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
14373
+ * ɵɵattributeInterpolate5(
14374
+ * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, 'suffix');
14951
14375
  * ```
14952
14376
  *
14953
14377
  * @param attrName The name of the attribute to update
14954
14378
  * @param prefix Static value used for concatenation only.
14955
14379
  * @param v0 Value checked for change.
14380
+ * @param i0 Static value used for concatenation only.
14381
+ * @param v1 Value checked for change.
14382
+ * @param i1 Static value used for concatenation only.
14383
+ * @param v2 Value checked for change.
14384
+ * @param i2 Static value used for concatenation only.
14385
+ * @param v3 Value checked for change.
14386
+ * @param i3 Static value used for concatenation only.
14387
+ * @param v4 Value checked for change.
14956
14388
  * @param suffix Static value used for concatenation only.
14957
14389
  * @param sanitizer An optional sanitizer function
14958
14390
  * @returns itself, so that it may be chained.
14959
14391
  * @codeGenApi
14960
14392
  */
14961
- function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
14393
+ function ɵɵattributeInterpolate5(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix, sanitizer, namespace) {
14962
14394
  const lView = getLView();
14963
- const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
14395
+ const interpolatedValue = interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix);
14964
14396
  if (interpolatedValue !== NO_CHANGE) {
14965
14397
  const tNode = getSelectedTNode();
14966
14398
  elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
14967
14399
  ngDevMode &&
14968
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
14400
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0, i1, i2, i3, suffix);
14969
14401
  }
14970
- return ɵɵattributeInterpolate1;
14402
+ return ɵɵattributeInterpolate5;
14971
14403
  }
14972
14404
  /**
14973
14405
  *
14974
- * Update an interpolated attribute on an element with 2 bound values surrounded by text.
14406
+ * Update an interpolated attribute on an element with 6 bound values surrounded by text.
14975
14407
  *
14976
- * Used when the value passed to a property has 2 interpolated values in it:
14408
+ * Used when the value passed to a property has 6 interpolated values in it:
14977
14409
  *
14978
14410
  * ```html
14979
- * <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
14411
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}suffix"></div>
14980
14412
  * ```
14981
14413
  *
14982
14414
  * Its compiled representation is::
14983
14415
  *
14984
14416
  * ```ts
14985
- * ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
14417
+ * ɵɵattributeInterpolate6(
14418
+ * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, 'suffix');
14986
14419
  * ```
14987
14420
  *
14988
14421
  * @param attrName The name of the attribute to update
@@ -14990,37 +14423,45 @@ function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, name
14990
14423
  * @param v0 Value checked for change.
14991
14424
  * @param i0 Static value used for concatenation only.
14992
14425
  * @param v1 Value checked for change.
14426
+ * @param i1 Static value used for concatenation only.
14427
+ * @param v2 Value checked for change.
14428
+ * @param i2 Static value used for concatenation only.
14429
+ * @param v3 Value checked for change.
14430
+ * @param i3 Static value used for concatenation only.
14431
+ * @param v4 Value checked for change.
14432
+ * @param i4 Static value used for concatenation only.
14433
+ * @param v5 Value checked for change.
14993
14434
  * @param suffix Static value used for concatenation only.
14994
14435
  * @param sanitizer An optional sanitizer function
14995
14436
  * @returns itself, so that it may be chained.
14996
14437
  * @codeGenApi
14997
14438
  */
14998
- function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
14439
+ function ɵɵattributeInterpolate6(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix, sanitizer, namespace) {
14999
14440
  const lView = getLView();
15000
- const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
14441
+ const interpolatedValue = interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix);
15001
14442
  if (interpolatedValue !== NO_CHANGE) {
15002
14443
  const tNode = getSelectedTNode();
15003
14444
  elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15004
14445
  ngDevMode &&
15005
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
14446
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0, i1, i2, i3, i4, suffix);
15006
14447
  }
15007
- return ɵɵattributeInterpolate2;
14448
+ return ɵɵattributeInterpolate6;
15008
14449
  }
15009
14450
  /**
15010
14451
  *
15011
- * Update an interpolated attribute on an element with 3 bound values surrounded by text.
14452
+ * Update an interpolated attribute on an element with 7 bound values surrounded by text.
15012
14453
  *
15013
- * Used when the value passed to a property has 3 interpolated values in it:
14454
+ * Used when the value passed to a property has 7 interpolated values in it:
15014
14455
  *
15015
14456
  * ```html
15016
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
14457
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}suffix"></div>
15017
14458
  * ```
15018
14459
  *
15019
14460
  * Its compiled representation is::
15020
14461
  *
15021
14462
  * ```ts
15022
- * ɵɵattributeInterpolate3(
15023
- * 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
14463
+ * ɵɵattributeInterpolate7(
14464
+ * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, 'suffix');
15024
14465
  * ```
15025
14466
  *
15026
14467
  * @param attrName The name of the attribute to update
@@ -15030,37 +14471,45 @@ function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitiz
15030
14471
  * @param v1 Value checked for change.
15031
14472
  * @param i1 Static value used for concatenation only.
15032
14473
  * @param v2 Value checked for change.
14474
+ * @param i2 Static value used for concatenation only.
14475
+ * @param v3 Value checked for change.
14476
+ * @param i3 Static value used for concatenation only.
14477
+ * @param v4 Value checked for change.
14478
+ * @param i4 Static value used for concatenation only.
14479
+ * @param v5 Value checked for change.
14480
+ * @param i5 Static value used for concatenation only.
14481
+ * @param v6 Value checked for change.
15033
14482
  * @param suffix Static value used for concatenation only.
15034
14483
  * @param sanitizer An optional sanitizer function
15035
14484
  * @returns itself, so that it may be chained.
15036
14485
  * @codeGenApi
15037
14486
  */
15038
- function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
14487
+ function ɵɵattributeInterpolate7(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix, sanitizer, namespace) {
15039
14488
  const lView = getLView();
15040
- const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
14489
+ const interpolatedValue = interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix);
15041
14490
  if (interpolatedValue !== NO_CHANGE) {
15042
14491
  const tNode = getSelectedTNode();
15043
14492
  elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15044
14493
  ngDevMode &&
15045
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
14494
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4, i5, suffix);
15046
14495
  }
15047
- return ɵɵattributeInterpolate3;
14496
+ return ɵɵattributeInterpolate7;
15048
14497
  }
15049
14498
  /**
15050
14499
  *
15051
- * Update an interpolated attribute on an element with 4 bound values surrounded by text.
14500
+ * Update an interpolated attribute on an element with 8 bound values surrounded by text.
15052
14501
  *
15053
- * Used when the value passed to a property has 4 interpolated values in it:
14502
+ * Used when the value passed to a property has 8 interpolated values in it:
15054
14503
  *
15055
14504
  * ```html
15056
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}suffix"></div>
14505
+ * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}suffix"></div>
15057
14506
  * ```
15058
14507
  *
15059
14508
  * Its compiled representation is::
15060
14509
  *
15061
14510
  * ```ts
15062
- * ɵɵattributeInterpolate4(
15063
- * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, 'suffix');
14511
+ * ɵɵattributeInterpolate8(
14512
+ * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, 'suffix');
15064
14513
  * ```
15065
14514
  *
15066
14515
  * @param attrName The name of the attribute to update
@@ -15072,251 +14521,105 @@ function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix,
15072
14521
  * @param v2 Value checked for change.
15073
14522
  * @param i2 Static value used for concatenation only.
15074
14523
  * @param v3 Value checked for change.
14524
+ * @param i3 Static value used for concatenation only.
14525
+ * @param v4 Value checked for change.
14526
+ * @param i4 Static value used for concatenation only.
14527
+ * @param v5 Value checked for change.
14528
+ * @param i5 Static value used for concatenation only.
14529
+ * @param v6 Value checked for change.
14530
+ * @param i6 Static value used for concatenation only.
14531
+ * @param v7 Value checked for change.
15075
14532
  * @param suffix Static value used for concatenation only.
15076
14533
  * @param sanitizer An optional sanitizer function
15077
14534
  * @returns itself, so that it may be chained.
15078
14535
  * @codeGenApi
15079
14536
  */
15080
- function ɵɵattributeInterpolate4(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, suffix, sanitizer, namespace) {
14537
+ function ɵɵattributeInterpolate8(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix, sanitizer, namespace) {
15081
14538
  const lView = getLView();
15082
- const interpolatedValue = interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix);
14539
+ const interpolatedValue = interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix);
15083
14540
  if (interpolatedValue !== NO_CHANGE) {
15084
14541
  const tNode = getSelectedTNode();
15085
14542
  elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15086
14543
  ngDevMode &&
15087
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 4, prefix, i0, i1, i2, suffix);
14544
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4, i5, i6, suffix);
15088
14545
  }
15089
- return ɵɵattributeInterpolate4;
14546
+ return ɵɵattributeInterpolate8;
15090
14547
  }
15091
14548
  /**
14549
+ * Update an interpolated attribute on an element with 9 or more bound values surrounded by text.
15092
14550
  *
15093
- * Update an interpolated attribute on an element with 5 bound values surrounded by text.
15094
- *
15095
- * Used when the value passed to a property has 5 interpolated values in it:
14551
+ * Used when the number of interpolated values exceeds 8.
15096
14552
  *
15097
14553
  * ```html
15098
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}suffix"></div>
14554
+ * <div
14555
+ * title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}-{{v8}}-{{v9}}suffix"></div>
15099
14556
  * ```
15100
14557
  *
15101
14558
  * Its compiled representation is::
15102
14559
  *
15103
14560
  * ```ts
15104
- * ɵɵattributeInterpolate5(
15105
- * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, 'suffix');
14561
+ * ɵɵattributeInterpolateV(
14562
+ * 'title', ['prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, '-', v9,
14563
+ * 'suffix']);
15106
14564
  * ```
15107
14565
  *
15108
- * @param attrName The name of the attribute to update
15109
- * @param prefix Static value used for concatenation only.
15110
- * @param v0 Value checked for change.
15111
- * @param i0 Static value used for concatenation only.
15112
- * @param v1 Value checked for change.
15113
- * @param i1 Static value used for concatenation only.
15114
- * @param v2 Value checked for change.
15115
- * @param i2 Static value used for concatenation only.
15116
- * @param v3 Value checked for change.
15117
- * @param i3 Static value used for concatenation only.
15118
- * @param v4 Value checked for change.
15119
- * @param suffix Static value used for concatenation only.
14566
+ * @param attrName The name of the attribute to update.
14567
+ * @param values The collection of values and the strings in-between those values, beginning with
14568
+ * a string prefix and ending with a string suffix.
14569
+ * (e.g. `['prefix', value0, '-', value1, '-', value2, ..., value99, 'suffix']`)
15120
14570
  * @param sanitizer An optional sanitizer function
15121
14571
  * @returns itself, so that it may be chained.
15122
14572
  * @codeGenApi
15123
14573
  */
15124
- function ɵɵattributeInterpolate5(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix, sanitizer, namespace) {
15125
- const lView = getLView();
15126
- const interpolatedValue = interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix);
15127
- if (interpolatedValue !== NO_CHANGE) {
15128
- const tNode = getSelectedTNode();
15129
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15130
- ngDevMode &&
15131
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 5, prefix, i0, i1, i2, i3, suffix);
15132
- }
15133
- return ɵɵattributeInterpolate5;
15134
- }
15135
- /**
15136
- *
15137
- * Update an interpolated attribute on an element with 6 bound values surrounded by text.
15138
- *
15139
- * Used when the value passed to a property has 6 interpolated values in it:
15140
- *
15141
- * ```html
15142
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}suffix"></div>
15143
- * ```
15144
- *
15145
- * Its compiled representation is::
15146
- *
15147
- * ```ts
15148
- * ɵɵattributeInterpolate6(
15149
- * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, 'suffix');
15150
- * ```
15151
- *
15152
- * @param attrName The name of the attribute to update
15153
- * @param prefix Static value used for concatenation only.
15154
- * @param v0 Value checked for change.
15155
- * @param i0 Static value used for concatenation only.
15156
- * @param v1 Value checked for change.
15157
- * @param i1 Static value used for concatenation only.
15158
- * @param v2 Value checked for change.
15159
- * @param i2 Static value used for concatenation only.
15160
- * @param v3 Value checked for change.
15161
- * @param i3 Static value used for concatenation only.
15162
- * @param v4 Value checked for change.
15163
- * @param i4 Static value used for concatenation only.
15164
- * @param v5 Value checked for change.
15165
- * @param suffix Static value used for concatenation only.
15166
- * @param sanitizer An optional sanitizer function
15167
- * @returns itself, so that it may be chained.
15168
- * @codeGenApi
15169
- */
15170
- function ɵɵattributeInterpolate6(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix, sanitizer, namespace) {
14574
+ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
15171
14575
  const lView = getLView();
15172
- const interpolatedValue = interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix);
15173
- if (interpolatedValue !== NO_CHANGE) {
14576
+ const interpolated = interpolationV(lView, values);
14577
+ if (interpolated !== NO_CHANGE) {
15174
14578
  const tNode = getSelectedTNode();
15175
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15176
- ngDevMode &&
15177
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 6, prefix, i0, i1, i2, i3, i4, suffix);
14579
+ elementAttributeInternal(tNode, lView, attrName, interpolated, sanitizer, namespace);
14580
+ if (ngDevMode) {
14581
+ const interpolationInBetween = [values[0]]; // prefix
14582
+ for (let i = 2; i < values.length; i += 2) {
14583
+ interpolationInBetween.push(values[i]);
14584
+ }
14585
+ storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - interpolationInBetween.length + 1, ...interpolationInBetween);
14586
+ }
15178
14587
  }
15179
- return ɵɵattributeInterpolate6;
14588
+ return ɵɵattributeInterpolateV;
15180
14589
  }
14590
+
15181
14591
  /**
14592
+ * @license
14593
+ * Copyright Google LLC All Rights Reserved.
15182
14594
  *
15183
- * Update an interpolated attribute on an element with 7 bound values surrounded by text.
15184
- *
15185
- * Used when the value passed to a property has 7 interpolated values in it:
15186
- *
15187
- * ```html
15188
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}suffix"></div>
15189
- * ```
15190
- *
15191
- * Its compiled representation is::
15192
- *
15193
- * ```ts
15194
- * ɵɵattributeInterpolate7(
15195
- * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, 'suffix');
15196
- * ```
15197
- *
15198
- * @param attrName The name of the attribute to update
15199
- * @param prefix Static value used for concatenation only.
15200
- * @param v0 Value checked for change.
15201
- * @param i0 Static value used for concatenation only.
15202
- * @param v1 Value checked for change.
15203
- * @param i1 Static value used for concatenation only.
15204
- * @param v2 Value checked for change.
15205
- * @param i2 Static value used for concatenation only.
15206
- * @param v3 Value checked for change.
15207
- * @param i3 Static value used for concatenation only.
15208
- * @param v4 Value checked for change.
15209
- * @param i4 Static value used for concatenation only.
15210
- * @param v5 Value checked for change.
15211
- * @param i5 Static value used for concatenation only.
15212
- * @param v6 Value checked for change.
15213
- * @param suffix Static value used for concatenation only.
15214
- * @param sanitizer An optional sanitizer function
15215
- * @returns itself, so that it may be chained.
15216
- * @codeGenApi
14595
+ * Use of this source code is governed by an MIT-style license that can be
14596
+ * found in the LICENSE file at https://angular.io/license
15217
14597
  */
15218
- function ɵɵattributeInterpolate7(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix, sanitizer, namespace) {
15219
- const lView = getLView();
15220
- const interpolatedValue = interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix);
15221
- if (interpolatedValue !== NO_CHANGE) {
15222
- const tNode = getSelectedTNode();
15223
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15224
- ngDevMode &&
15225
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 7, prefix, i0, i1, i2, i3, i4, i5, suffix);
15226
- }
15227
- return ɵɵattributeInterpolate7;
15228
- }
15229
14598
  /**
14599
+ * Synchronously perform change detection on a component (and possibly its sub-components).
15230
14600
  *
15231
- * Update an interpolated attribute on an element with 8 bound values surrounded by text.
15232
- *
15233
- * Used when the value passed to a property has 8 interpolated values in it:
15234
- *
15235
- * ```html
15236
- * <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}suffix"></div>
15237
- * ```
15238
- *
15239
- * Its compiled representation is::
15240
- *
15241
- * ```ts
15242
- * ɵɵattributeInterpolate8(
15243
- * 'title', 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, 'suffix');
15244
- * ```
14601
+ * This function triggers change detection in a synchronous way on a component.
15245
14602
  *
15246
- * @param attrName The name of the attribute to update
15247
- * @param prefix Static value used for concatenation only.
15248
- * @param v0 Value checked for change.
15249
- * @param i0 Static value used for concatenation only.
15250
- * @param v1 Value checked for change.
15251
- * @param i1 Static value used for concatenation only.
15252
- * @param v2 Value checked for change.
15253
- * @param i2 Static value used for concatenation only.
15254
- * @param v3 Value checked for change.
15255
- * @param i3 Static value used for concatenation only.
15256
- * @param v4 Value checked for change.
15257
- * @param i4 Static value used for concatenation only.
15258
- * @param v5 Value checked for change.
15259
- * @param i5 Static value used for concatenation only.
15260
- * @param v6 Value checked for change.
15261
- * @param i6 Static value used for concatenation only.
15262
- * @param v7 Value checked for change.
15263
- * @param suffix Static value used for concatenation only.
15264
- * @param sanitizer An optional sanitizer function
15265
- * @returns itself, so that it may be chained.
15266
- * @codeGenApi
14603
+ * @param component The component which the change detection should be performed on.
15267
14604
  */
15268
- function ɵɵattributeInterpolate8(attrName, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix, sanitizer, namespace) {
15269
- const lView = getLView();
15270
- const interpolatedValue = interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix);
15271
- if (interpolatedValue !== NO_CHANGE) {
15272
- const tNode = getSelectedTNode();
15273
- elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
15274
- ngDevMode &&
15275
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 8, prefix, i0, i1, i2, i3, i4, i5, i6, suffix);
15276
- }
15277
- return ɵɵattributeInterpolate8;
14605
+ function detectChanges(component) {
14606
+ const view = getComponentViewByInstance(component);
14607
+ detectChangesInternal(view[TVIEW], view, component);
15278
14608
  }
15279
14609
  /**
15280
- * Update an interpolated attribute on an element with 9 or more bound values surrounded by text.
15281
- *
15282
- * Used when the number of interpolated values exceeds 8.
15283
- *
15284
- * ```html
15285
- * <div
15286
- * title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}-{{v8}}-{{v9}}suffix"></div>
15287
- * ```
15288
- *
15289
- * Its compiled representation is::
14610
+ * Marks the component as dirty (needing change detection). Marking a component dirty will
14611
+ * schedule a change detection on it at some point in the future.
15290
14612
  *
15291
- * ```ts
15292
- * ɵɵattributeInterpolateV(
15293
- * 'title', ['prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, '-', v9,
15294
- * 'suffix']);
15295
- * ```
14613
+ * Marking an already dirty component as dirty won't do anything. Only one outstanding change
14614
+ * detection can be scheduled per component tree.
15296
14615
  *
15297
- * @param attrName The name of the attribute to update.
15298
- * @param values The collection of values and the strings in-between those values, beginning with
15299
- * a string prefix and ending with a string suffix.
15300
- * (e.g. `['prefix', value0, '-', value1, '-', value2, ..., value99, 'suffix']`)
15301
- * @param sanitizer An optional sanitizer function
15302
- * @returns itself, so that it may be chained.
15303
- * @codeGenApi
14616
+ * @param component Component to mark as dirty.
15304
14617
  */
15305
- function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
15306
- const lView = getLView();
15307
- const interpolated = interpolationV(lView, values);
15308
- if (interpolated !== NO_CHANGE) {
15309
- const tNode = getSelectedTNode();
15310
- elementAttributeInternal(tNode, lView, attrName, interpolated, sanitizer, namespace);
15311
- if (ngDevMode) {
15312
- const interpolationInBetween = [values[0]]; // prefix
15313
- for (let i = 2; i < values.length; i += 2) {
15314
- interpolationInBetween.push(values[i]);
15315
- }
15316
- storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - interpolationInBetween.length + 1, ...interpolationInBetween);
15317
- }
15318
- }
15319
- return ɵɵattributeInterpolateV;
14618
+ function markDirty(component) {
14619
+ ngDevMode && assertDefined(component, 'component');
14620
+ const rootView = markViewDirty(getComponentViewByInstance(component));
14621
+ ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
14622
+ scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
15320
14623
  }
15321
14624
 
15322
14625
  /**
@@ -15863,51 +15166,42 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15863
15166
  tNode.index;
15864
15167
  // In order to match current behavior, native DOM event listeners must be added for all
15865
15168
  // events (including outputs).
15866
- if (isProceduralRenderer(renderer)) {
15867
- // There might be cases where multiple directives on the same element try to register an event
15868
- // handler function for the same event. In this situation we want to avoid registration of
15869
- // several native listeners as each registration would be intercepted by NgZone and
15870
- // trigger change detection. This would mean that a single user action would result in several
15871
- // change detections being invoked. To avoid this situation we want to have only one call to
15872
- // native handler registration (for the same element and same type of event).
15873
- //
15874
- // In order to have just one native event handler in presence of multiple handler functions,
15875
- // we just register a first handler function as a native event listener and then chain
15876
- // (coalesce) other handler functions on top of the first native handler function.
15877
- let existingListener = null;
15878
- // Please note that the coalescing described here doesn't happen for events specifying an
15879
- // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15880
- // view engine.
15881
- // Also, we don't have to search for existing listeners is there are no directives
15882
- // matching on a given node as we can't register multiple event handlers for the same event in
15883
- // a template (this would mean having duplicate attributes).
15884
- if (!eventTargetResolver && isTNodeDirectiveHost) {
15885
- existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15886
- }
15887
- if (existingListener !== null) {
15888
- // Attach a new listener to coalesced listeners list, maintaining the order in which
15889
- // listeners are registered. For performance reasons, we keep a reference to the last
15890
- // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15891
- // the entire set each time we need to add a new listener.
15892
- const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15893
- lastListenerFn.__ngNextListenerFn__ = listenerFn;
15894
- existingListener.__ngLastListenerFn__ = listenerFn;
15895
- processOutputs = false;
15896
- }
15897
- else {
15898
- listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15899
- const cleanupFn = renderer.listen(target, eventName, listenerFn);
15900
- ngDevMode && ngDevMode.rendererAddEventListener++;
15901
- lCleanup.push(listenerFn, cleanupFn);
15902
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15903
- }
15169
+ // There might be cases where multiple directives on the same element try to register an event
15170
+ // handler function for the same event. In this situation we want to avoid registration of
15171
+ // several native listeners as each registration would be intercepted by NgZone and
15172
+ // trigger change detection. This would mean that a single user action would result in several
15173
+ // change detections being invoked. To avoid this situation we want to have only one call to
15174
+ // native handler registration (for the same element and same type of event).
15175
+ //
15176
+ // In order to have just one native event handler in presence of multiple handler functions,
15177
+ // we just register a first handler function as a native event listener and then chain
15178
+ // (coalesce) other handler functions on top of the first native handler function.
15179
+ let existingListener = null;
15180
+ // Please note that the coalescing described here doesn't happen for events specifying an
15181
+ // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15182
+ // view engine.
15183
+ // Also, we don't have to search for existing listeners is there are no directives
15184
+ // matching on a given node as we can't register multiple event handlers for the same event in
15185
+ // a template (this would mean having duplicate attributes).
15186
+ if (!eventTargetResolver && isTNodeDirectiveHost) {
15187
+ existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15188
+ }
15189
+ if (existingListener !== null) {
15190
+ // Attach a new listener to coalesced listeners list, maintaining the order in which
15191
+ // listeners are registered. For performance reasons, we keep a reference to the last
15192
+ // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15193
+ // the entire set each time we need to add a new listener.
15194
+ const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15195
+ lastListenerFn.__ngNextListenerFn__ = listenerFn;
15196
+ existingListener.__ngLastListenerFn__ = listenerFn;
15197
+ processOutputs = false;
15904
15198
  }
15905
15199
  else {
15906
- listenerFn = wrapListener(tNode, lView, context, listenerFn, true /** preventDefault */);
15907
- target.addEventListener(eventName, listenerFn, useCapture);
15200
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15201
+ const cleanupFn = renderer.listen(target, eventName, listenerFn);
15908
15202
  ngDevMode && ngDevMode.rendererAddEventListener++;
15909
- lCleanup.push(listenerFn);
15910
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, useCapture);
15203
+ lCleanup.push(listenerFn, cleanupFn);
15204
+ tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15911
15205
  }
15912
15206
  }
15913
15207
  else {
@@ -17981,7 +17275,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
17981
17275
  valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
17982
17276
  }
17983
17277
  let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
17984
- key === prop ? valueAtLViewIndex : undefined;
17278
+ (key === prop ? valueAtLViewIndex : undefined);
17985
17279
  if (containsStatics && !isStylingValuePresent(currentValue)) {
17986
17280
  currentValue = keyValueArrayGet(rawKey, prop);
17987
17281
  }
@@ -21834,7 +21128,7 @@ function noComponentFactoryError(component) {
21834
21128
  return error;
21835
21129
  }
21836
21130
  const ERROR_COMPONENT = 'ngComponent';
21837
- function getComponent(error) {
21131
+ function getComponent$1(error) {
21838
21132
  return error[ERROR_COMPONENT];
21839
21133
  }
21840
21134
  class _NullComponentFactoryResolver {
@@ -22018,14 +21312,6 @@ class Renderer2 {
22018
21312
  * @nocollapse
22019
21313
  */
22020
21314
  Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
22021
- /** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */
22022
- function getOrCreateRenderer2(lView) {
22023
- const renderer = lView[RENDERER];
22024
- if (ngDevMode && !isProceduralRenderer(renderer)) {
22025
- throw new Error('Cannot inject Renderer2 when the application uses Renderer3!');
22026
- }
22027
- return renderer;
22028
- }
22029
21315
  /** Injects a Renderer2 for the current component. */
22030
21316
  function injectRenderer2() {
22031
21317
  // We need the Renderer to be based on the component that it's being injected into, however since
@@ -22033,7 +21319,7 @@ function injectRenderer2() {
22033
21319
  const lView = getLView();
22034
21320
  const tNode = getCurrentTNode();
22035
21321
  const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
22036
- return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
21322
+ return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
22037
21323
  }
22038
21324
 
22039
21325
  /**
@@ -22080,7 +21366,7 @@ class Version {
22080
21366
  /**
22081
21367
  * @publicApi
22082
21368
  */
22083
- const VERSION = new Version('14.0.4');
21369
+ const VERSION = new Version('14.0.7');
22084
21370
 
22085
21371
  /**
22086
21372
  * @license
@@ -22426,31 +21712,407 @@ class ViewRef {
22426
21712
  this._appRef = null;
22427
21713
  renderDetachView(this._lView[TVIEW], this._lView);
22428
21714
  }
22429
- attachToAppRef(appRef) {
22430
- if (this._attachedToViewContainer) {
22431
- throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
22432
- }
22433
- this._appRef = appRef;
21715
+ attachToAppRef(appRef) {
21716
+ if (this._attachedToViewContainer) {
21717
+ throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
21718
+ }
21719
+ this._appRef = appRef;
21720
+ }
21721
+ }
21722
+ /** @internal */
21723
+ class RootViewRef extends ViewRef {
21724
+ constructor(_view) {
21725
+ super(_view);
21726
+ this._view = _view;
21727
+ }
21728
+ detectChanges() {
21729
+ detectChangesInRootView(this._view);
21730
+ }
21731
+ checkNoChanges() {
21732
+ if (ngDevMode) {
21733
+ checkNoChangesInRootView(this._view);
21734
+ }
21735
+ }
21736
+ get context() {
21737
+ return null;
21738
+ }
21739
+ }
21740
+
21741
+ /**
21742
+ * @license
21743
+ * Copyright Google LLC All Rights Reserved.
21744
+ *
21745
+ * Use of this source code is governed by an MIT-style license that can be
21746
+ * found in the LICENSE file at https://angular.io/license
21747
+ */
21748
+ class ComponentFactoryResolver extends ComponentFactoryResolver$1 {
21749
+ /**
21750
+ * @param ngModule The NgModuleRef to which all resolved factories are bound.
21751
+ */
21752
+ constructor(ngModule) {
21753
+ super();
21754
+ this.ngModule = ngModule;
21755
+ }
21756
+ resolveComponentFactory(component) {
21757
+ ngDevMode && assertComponentType(component);
21758
+ const componentDef = getComponentDef$1(component);
21759
+ return new ComponentFactory(componentDef, this.ngModule);
21760
+ }
21761
+ }
21762
+ function toRefArray(map) {
21763
+ const array = [];
21764
+ for (let nonMinified in map) {
21765
+ if (map.hasOwnProperty(nonMinified)) {
21766
+ const minified = map[nonMinified];
21767
+ array.push({ propName: minified, templateName: nonMinified });
21768
+ }
21769
+ }
21770
+ return array;
21771
+ }
21772
+ function getNamespace(elementName) {
21773
+ const name = elementName.toLowerCase();
21774
+ return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
21775
+ }
21776
+ /**
21777
+ * Injector that looks up a value using a specific injector, before falling back to the module
21778
+ * injector. Used primarily when creating components or embedded views dynamically.
21779
+ */
21780
+ class ChainedInjector {
21781
+ constructor(injector, parentInjector) {
21782
+ this.injector = injector;
21783
+ this.parentInjector = parentInjector;
21784
+ }
21785
+ get(token, notFoundValue, flags) {
21786
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21787
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21788
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21789
+ // Return the value from the root element injector when
21790
+ // - it provides it
21791
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21792
+ // - the module injector should not be checked
21793
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21794
+ return value;
21795
+ }
21796
+ return this.parentInjector.get(token, notFoundValue, flags);
21797
+ }
21798
+ }
21799
+ /**
21800
+ * Render3 implementation of {@link viewEngine_ComponentFactory}.
21801
+ */
21802
+ class ComponentFactory extends ComponentFactory$1 {
21803
+ /**
21804
+ * @param componentDef The component definition.
21805
+ * @param ngModule The NgModuleRef to which the factory is bound.
21806
+ */
21807
+ constructor(componentDef, ngModule) {
21808
+ super();
21809
+ this.componentDef = componentDef;
21810
+ this.ngModule = ngModule;
21811
+ this.componentType = componentDef.type;
21812
+ this.selector = stringifyCSSSelectorList(componentDef.selectors);
21813
+ this.ngContentSelectors =
21814
+ componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
21815
+ this.isBoundToModule = !!ngModule;
21816
+ }
21817
+ get inputs() {
21818
+ return toRefArray(this.componentDef.inputs);
21819
+ }
21820
+ get outputs() {
21821
+ return toRefArray(this.componentDef.outputs);
21822
+ }
21823
+ create(injector, projectableNodes, rootSelectorOrNode, environmentInjector) {
21824
+ environmentInjector = environmentInjector || this.ngModule;
21825
+ let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ?
21826
+ environmentInjector :
21827
+ environmentInjector === null || environmentInjector === void 0 ? void 0 : environmentInjector.injector;
21828
+ if (realEnvironmentInjector && this.componentDef.getStandaloneInjector !== null) {
21829
+ realEnvironmentInjector = this.componentDef.getStandaloneInjector(realEnvironmentInjector) ||
21830
+ realEnvironmentInjector;
21831
+ }
21832
+ const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
21833
+ const rendererFactory = rootViewInjector.get(RendererFactory2, null);
21834
+ if (rendererFactory === null) {
21835
+ throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
21836
+ 'Angular was not able to inject a renderer (RendererFactory2). ' +
21837
+ 'Likely this is due to a broken DI hierarchy. ' +
21838
+ 'Make sure that any injector used to create this component has a correct parent.');
21839
+ }
21840
+ const sanitizer = rootViewInjector.get(Sanitizer, null);
21841
+ const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
21842
+ // Determine a tag name used for creating host elements when this component is created
21843
+ // dynamically. Default to 'div' if this component did not specify any tag name in its selector.
21844
+ const elementName = this.componentDef.selectors[0][0] || 'div';
21845
+ const hostRNode = rootSelectorOrNode ?
21846
+ locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) :
21847
+ createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
21848
+ const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
21849
+ 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
21850
+ const rootContext = createRootContext();
21851
+ // Create the root view. Uses empty TView and ContentTemplate.
21852
+ const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
21853
+ const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
21854
+ // rootView is the parent when bootstrapping
21855
+ // TODO(misko): it looks like we are entering view here but we don't really need to as
21856
+ // `renderView` does that. However as the code is written it is needed because
21857
+ // `createRootComponentView` and `createRootComponent` both read global state. Fixing those
21858
+ // issues would allow us to drop this.
21859
+ enterView(rootLView);
21860
+ let component;
21861
+ let tElementNode;
21862
+ try {
21863
+ const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
21864
+ if (hostRNode) {
21865
+ if (rootSelectorOrNode) {
21866
+ setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
21867
+ }
21868
+ else {
21869
+ // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
21870
+ // is not defined), also apply attributes and classes extracted from component selector.
21871
+ // Extract attributes and classes from the first selector only to match VE behavior.
21872
+ const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
21873
+ if (attrs) {
21874
+ setUpAttributes(hostRenderer, hostRNode, attrs);
21875
+ }
21876
+ if (classes && classes.length > 0) {
21877
+ writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
21878
+ }
21879
+ }
21880
+ }
21881
+ tElementNode = getTNode(rootTView, HEADER_OFFSET);
21882
+ if (projectableNodes !== undefined) {
21883
+ const projection = tElementNode.projection = [];
21884
+ for (let i = 0; i < this.ngContentSelectors.length; i++) {
21885
+ const nodesforSlot = projectableNodes[i];
21886
+ // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
21887
+ // case). Here we do normalize passed data structure to be an array of arrays to avoid
21888
+ // complex checks down the line.
21889
+ // We also normalize the length of the passed in projectable nodes (to match the number of
21890
+ // <ng-container> slots defined by a component).
21891
+ projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
21892
+ }
21893
+ }
21894
+ // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
21895
+ // executed here?
21896
+ // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
21897
+ component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
21898
+ renderView(rootTView, rootLView, null);
21899
+ }
21900
+ finally {
21901
+ leaveView();
21902
+ }
21903
+ return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
21904
+ }
21905
+ }
21906
+ const componentFactoryResolver = new ComponentFactoryResolver();
21907
+ /**
21908
+ * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
21909
+ * ComponentFactoryResolver
21910
+ * already exists, retrieves the existing ComponentFactoryResolver.
21911
+ *
21912
+ * @returns The ComponentFactoryResolver instance to use
21913
+ */
21914
+ function injectComponentFactoryResolver() {
21915
+ return componentFactoryResolver;
21916
+ }
21917
+ /**
21918
+ * Represents an instance of a Component created via a {@link ComponentFactory}.
21919
+ *
21920
+ * `ComponentRef` provides access to the Component Instance as well other objects related to this
21921
+ * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
21922
+ * method.
21923
+ *
21924
+ */
21925
+ class ComponentRef extends ComponentRef$1 {
21926
+ constructor(componentType, instance, location, _rootLView, _tNode) {
21927
+ super();
21928
+ this.location = location;
21929
+ this._rootLView = _rootLView;
21930
+ this._tNode = _tNode;
21931
+ this.instance = instance;
21932
+ this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
21933
+ this.componentType = componentType;
21934
+ }
21935
+ get injector() {
21936
+ return new NodeInjector(this._tNode, this._rootLView);
21937
+ }
21938
+ destroy() {
21939
+ this.hostView.destroy();
21940
+ }
21941
+ onDestroy(callback) {
21942
+ this.hostView.onDestroy(callback);
21943
+ }
21944
+ }
21945
+
21946
+ /**
21947
+ * @license
21948
+ * Copyright Google LLC All Rights Reserved.
21949
+ *
21950
+ * Use of this source code is governed by an MIT-style license that can be
21951
+ * found in the LICENSE file at https://angular.io/license
21952
+ */
21953
+ /**
21954
+ * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
21955
+ * @param ngModule NgModule class.
21956
+ * @param parentInjector Optional injector instance to use as a parent for the module injector. If
21957
+ * not provided, `NullInjector` will be used instead.
21958
+ * @publicApi
21959
+ */
21960
+ function createNgModuleRef(ngModule, parentInjector) {
21961
+ return new NgModuleRef(ngModule, parentInjector !== null && parentInjector !== void 0 ? parentInjector : null);
21962
+ }
21963
+ class NgModuleRef extends NgModuleRef$1 {
21964
+ constructor(ngModuleType, _parent) {
21965
+ super();
21966
+ this._parent = _parent;
21967
+ // tslint:disable-next-line:require-internal-with-underscore
21968
+ this._bootstrapComponents = [];
21969
+ this.injector = this;
21970
+ this.destroyCbs = [];
21971
+ // When bootstrapping a module we have a dependency graph that looks like this:
21972
+ // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
21973
+ // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
21974
+ // circular dependency which will result in a runtime error, because the injector doesn't
21975
+ // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
21976
+ // and providing it, rather than letting the injector resolve it.
21977
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
21978
+ const ngModuleDef = getNgModuleDef(ngModuleType);
21979
+ ngDevMode &&
21980
+ assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
21981
+ this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
21982
+ this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
21983
+ { provide: NgModuleRef$1, useValue: this }, {
21984
+ provide: ComponentFactoryResolver$1,
21985
+ useValue: this.componentFactoryResolver
21986
+ }
21987
+ ], stringify(ngModuleType), new Set(['environment']));
21988
+ // We need to resolve the injector types separately from the injector creation, because
21989
+ // the module might be trying to use this ref in its constructor for DI which will cause a
21990
+ // circular error that will eventually error out, because the injector isn't created yet.
21991
+ this._r3Injector.resolveInjectorInitializers();
21992
+ this.instance = this.get(ngModuleType);
21993
+ }
21994
+ get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
21995
+ if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
21996
+ return this;
21997
+ }
21998
+ return this._r3Injector.get(token, notFoundValue, injectFlags);
21999
+ }
22000
+ destroy() {
22001
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22002
+ const injector = this._r3Injector;
22003
+ !injector.destroyed && injector.destroy();
22004
+ this.destroyCbs.forEach(fn => fn());
22005
+ this.destroyCbs = null;
22006
+ }
22007
+ onDestroy(callback) {
22008
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22009
+ this.destroyCbs.push(callback);
22010
+ }
22011
+ }
22012
+ class NgModuleFactory extends NgModuleFactory$1 {
22013
+ constructor(moduleType) {
22014
+ super();
22015
+ this.moduleType = moduleType;
22016
+ }
22017
+ create(parentInjector) {
22018
+ return new NgModuleRef(this.moduleType, parentInjector);
22434
22019
  }
22435
22020
  }
22436
- /** @internal */
22437
- class RootViewRef extends ViewRef {
22438
- constructor(_view) {
22439
- super(_view);
22440
- this._view = _view;
22021
+ class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22022
+ constructor(providers, parent, source) {
22023
+ super();
22024
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
22025
+ this.instance = null;
22026
+ const injector = new R3Injector([
22027
+ ...providers,
22028
+ { provide: NgModuleRef$1, useValue: this },
22029
+ { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22030
+ ], parent || getNullInjector(), source, new Set(['environment']));
22031
+ this.injector = injector;
22032
+ injector.resolveInjectorInitializers();
22441
22033
  }
22442
- detectChanges() {
22443
- detectChangesInRootView(this._view);
22034
+ destroy() {
22035
+ this.injector.destroy();
22444
22036
  }
22445
- checkNoChanges() {
22446
- if (ngDevMode) {
22447
- checkNoChangesInRootView(this._view);
22037
+ onDestroy(callback) {
22038
+ this.injector.onDestroy(callback);
22039
+ }
22040
+ }
22041
+ /**
22042
+ * Create a new environment injector.
22043
+ *
22044
+ * @publicApi
22045
+ * @developerPreview
22046
+ */
22047
+ function createEnvironmentInjector(providers, parent = null, debugName = null) {
22048
+ const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22049
+ return adapter.injector;
22050
+ }
22051
+
22052
+ /**
22053
+ * @license
22054
+ * Copyright Google LLC All Rights Reserved.
22055
+ *
22056
+ * Use of this source code is governed by an MIT-style license that can be
22057
+ * found in the LICENSE file at https://angular.io/license
22058
+ */
22059
+ /**
22060
+ * A service used by the framework to create instances of standalone injectors. Those injectors are
22061
+ * created on demand in case of dynamic component instantiation and contain ambient providers
22062
+ * collected from the imports graph rooted at a given standalone component.
22063
+ */
22064
+ class StandaloneService {
22065
+ constructor(_injector) {
22066
+ this._injector = _injector;
22067
+ this.cachedInjectors = new Map();
22068
+ }
22069
+ getOrCreateStandaloneInjector(componentDef) {
22070
+ if (!componentDef.standalone) {
22071
+ return null;
22072
+ }
22073
+ if (!this.cachedInjectors.has(componentDef.id)) {
22074
+ const providers = internalImportProvidersFrom(false, componentDef.type);
22075
+ const standaloneInjector = providers.length > 0 ?
22076
+ createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22077
+ null;
22078
+ this.cachedInjectors.set(componentDef.id, standaloneInjector);
22448
22079
  }
22080
+ return this.cachedInjectors.get(componentDef.id);
22449
22081
  }
22450
- get context() {
22451
- return null;
22082
+ ngOnDestroy() {
22083
+ try {
22084
+ for (const injector of this.cachedInjectors.values()) {
22085
+ if (injector !== null) {
22086
+ injector.destroy();
22087
+ }
22088
+ }
22089
+ }
22090
+ finally {
22091
+ this.cachedInjectors.clear();
22092
+ }
22452
22093
  }
22453
22094
  }
22095
+ /** @nocollapse */
22096
+ StandaloneService.ɵprov = ɵɵdefineInjectable({
22097
+ token: StandaloneService,
22098
+ providedIn: 'environment',
22099
+ factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22100
+ });
22101
+ /**
22102
+ * A feature that acts as a setup code for the {@link StandaloneService}.
22103
+ *
22104
+ * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
22105
+ * function (an entry points to a standalone injector creation) on a component definition object. We
22106
+ * go through the features infrastructure to make sure that the standalone injector creation logic
22107
+ * is tree-shakable and not included in applications that don't use standalone components.
22108
+ *
22109
+ * @codeGenApi
22110
+ */
22111
+ function ɵɵStandaloneFeature(definition) {
22112
+ definition.getStandaloneInjector = (parentInjector) => {
22113
+ return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22114
+ };
22115
+ }
22454
22116
 
22455
22117
  /**
22456
22118
  * @license
@@ -22459,367 +22121,407 @@ class RootViewRef extends ViewRef {
22459
22121
  * Use of this source code is governed by an MIT-style license that can be
22460
22122
  * found in the LICENSE file at https://angular.io/license
22461
22123
  */
22462
- class ComponentFactoryResolver extends ComponentFactoryResolver$1 {
22463
- /**
22464
- * @param ngModule The NgModuleRef to which all resolved factories are bound.
22465
- */
22466
- constructor(ngModule) {
22467
- super();
22468
- this.ngModule = ngModule;
22124
+ /**
22125
+ * Retrieves the component instance associated with a given DOM element.
22126
+ *
22127
+ * @usageNotes
22128
+ * Given the following DOM structure:
22129
+ *
22130
+ * ```html
22131
+ * <app-root>
22132
+ * <div>
22133
+ * <child-comp></child-comp>
22134
+ * </div>
22135
+ * </app-root>
22136
+ * ```
22137
+ *
22138
+ * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
22139
+ * associated with this DOM element.
22140
+ *
22141
+ * Calling the function on `<app-root>` will return the `MyApp` instance.
22142
+ *
22143
+ *
22144
+ * @param element DOM element from which the component should be retrieved.
22145
+ * @returns Component instance associated with the element or `null` if there
22146
+ * is no component associated with it.
22147
+ *
22148
+ * @publicApi
22149
+ * @globalApi ng
22150
+ */
22151
+ function getComponent(element) {
22152
+ ngDevMode && assertDomElement(element);
22153
+ const context = getLContext(element);
22154
+ if (context === null)
22155
+ return null;
22156
+ if (context.component === undefined) {
22157
+ const lView = context.lView;
22158
+ if (lView === null) {
22159
+ return null;
22160
+ }
22161
+ context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
22469
22162
  }
22470
- resolveComponentFactory(component) {
22471
- ngDevMode && assertComponentType(component);
22472
- const componentDef = getComponentDef$1(component);
22473
- return new ComponentFactory(componentDef, this.ngModule);
22163
+ return context.component;
22164
+ }
22165
+ /**
22166
+ * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
22167
+ * view that the element is part of. Otherwise retrieves the instance of the component whose view
22168
+ * owns the element (in this case, the result is the same as calling `getOwningComponent`).
22169
+ *
22170
+ * @param element Element for which to get the surrounding component instance.
22171
+ * @returns Instance of the component that is around the element or null if the element isn't
22172
+ * inside any component.
22173
+ *
22174
+ * @publicApi
22175
+ * @globalApi ng
22176
+ */
22177
+ function getContext(element) {
22178
+ assertDomElement(element);
22179
+ const context = getLContext(element);
22180
+ const lView = context ? context.lView : null;
22181
+ return lView === null ? null : lView[CONTEXT];
22182
+ }
22183
+ /**
22184
+ * Retrieves the component instance whose view contains the DOM element.
22185
+ *
22186
+ * For example, if `<child-comp>` is used in the template of `<app-comp>`
22187
+ * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
22188
+ * would return `<app-comp>`.
22189
+ *
22190
+ * @param elementOrDir DOM element, component or directive instance
22191
+ * for which to retrieve the root components.
22192
+ * @returns Component instance whose view owns the DOM element or null if the element is not
22193
+ * part of a component view.
22194
+ *
22195
+ * @publicApi
22196
+ * @globalApi ng
22197
+ */
22198
+ function getOwningComponent(elementOrDir) {
22199
+ const context = getLContext(elementOrDir);
22200
+ let lView = context ? context.lView : null;
22201
+ if (lView === null)
22202
+ return null;
22203
+ let parent;
22204
+ while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
22205
+ lView = parent;
22474
22206
  }
22207
+ return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
22475
22208
  }
22476
- function toRefArray(map) {
22477
- const array = [];
22478
- for (let nonMinified in map) {
22479
- if (map.hasOwnProperty(nonMinified)) {
22480
- const minified = map[nonMinified];
22481
- array.push({ propName: minified, templateName: nonMinified });
22209
+ /**
22210
+ * Retrieves all root components associated with a DOM element, directive or component instance.
22211
+ * Root components are those which have been bootstrapped by Angular.
22212
+ *
22213
+ * @param elementOrDir DOM element, component or directive instance
22214
+ * for which to retrieve the root components.
22215
+ * @returns Root components associated with the target object.
22216
+ *
22217
+ * @publicApi
22218
+ * @globalApi ng
22219
+ */
22220
+ function getRootComponents(elementOrDir) {
22221
+ const lView = readPatchedLView(elementOrDir);
22222
+ return lView !== null ? [...getRootContext(lView).components] : [];
22223
+ }
22224
+ /**
22225
+ * Retrieves an `Injector` associated with an element, component or directive instance.
22226
+ *
22227
+ * @param elementOrDir DOM element, component or directive instance for which to
22228
+ * retrieve the injector.
22229
+ * @returns Injector associated with the element, component or directive instance.
22230
+ *
22231
+ * @publicApi
22232
+ * @globalApi ng
22233
+ */
22234
+ function getInjector(elementOrDir) {
22235
+ const context = getLContext(elementOrDir);
22236
+ const lView = context ? context.lView : null;
22237
+ if (lView === null)
22238
+ return Injector.NULL;
22239
+ const tNode = lView[TVIEW].data[context.nodeIndex];
22240
+ return new NodeInjector(tNode, lView);
22241
+ }
22242
+ /**
22243
+ * Retrieve a set of injection tokens at a given DOM node.
22244
+ *
22245
+ * @param element Element for which the injection tokens should be retrieved.
22246
+ */
22247
+ function getInjectionTokens(element) {
22248
+ const context = getLContext(element);
22249
+ const lView = context ? context.lView : null;
22250
+ if (lView === null)
22251
+ return [];
22252
+ const tView = lView[TVIEW];
22253
+ const tNode = tView.data[context.nodeIndex];
22254
+ const providerTokens = [];
22255
+ const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
22256
+ const endIndex = tNode.directiveEnd;
22257
+ for (let i = startIndex; i < endIndex; i++) {
22258
+ let value = tView.data[i];
22259
+ if (isDirectiveDefHack(value)) {
22260
+ // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
22261
+ // design flaw. We should always store same type so that we can be monomorphic. The issue
22262
+ // is that for Components/Directives we store the def instead the type. The correct behavior
22263
+ // is that we should always be storing injectable type in this location.
22264
+ value = value.type;
22482
22265
  }
22266
+ providerTokens.push(value);
22483
22267
  }
22484
- return array;
22485
- }
22486
- function getNamespace(elementName) {
22487
- const name = elementName.toLowerCase();
22488
- return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
22268
+ return providerTokens;
22489
22269
  }
22490
22270
  /**
22491
- * Injector that looks up a value using a specific injector, before falling back to the module
22492
- * injector. Used primarily when creating components or embedded views dynamically.
22271
+ * Retrieves directive instances associated with a given DOM node. Does not include
22272
+ * component instances.
22273
+ *
22274
+ * @usageNotes
22275
+ * Given the following DOM structure:
22276
+ *
22277
+ * ```html
22278
+ * <app-root>
22279
+ * <button my-button></button>
22280
+ * <my-comp></my-comp>
22281
+ * </app-root>
22282
+ * ```
22283
+ *
22284
+ * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
22285
+ * directive that is associated with the DOM node.
22286
+ *
22287
+ * Calling `getDirectives` on `<my-comp>` will return an empty array.
22288
+ *
22289
+ * @param node DOM node for which to get the directives.
22290
+ * @returns Array of directives associated with the node.
22291
+ *
22292
+ * @publicApi
22293
+ * @globalApi ng
22493
22294
  */
22494
- class ChainedInjector {
22495
- constructor(injector, parentInjector) {
22496
- this.injector = injector;
22497
- this.parentInjector = parentInjector;
22295
+ function getDirectives(node) {
22296
+ // Skip text nodes because we can't have directives associated with them.
22297
+ if (node instanceof Text) {
22298
+ return [];
22498
22299
  }
22499
- get(token, notFoundValue, flags) {
22500
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
22501
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
22502
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
22503
- // Return the value from the root element injector when
22504
- // - it provides it
22505
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
22506
- // - the module injector should not be checked
22507
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
22508
- return value;
22509
- }
22510
- return this.parentInjector.get(token, notFoundValue, flags);
22300
+ const context = getLContext(node);
22301
+ const lView = context ? context.lView : null;
22302
+ if (lView === null) {
22303
+ return [];
22304
+ }
22305
+ const tView = lView[TVIEW];
22306
+ const nodeIndex = context.nodeIndex;
22307
+ if (!(tView === null || tView === void 0 ? void 0 : tView.data[nodeIndex])) {
22308
+ return [];
22309
+ }
22310
+ if (context.directives === undefined) {
22311
+ context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
22511
22312
  }
22313
+ // The `directives` in this case are a named array called `LComponentView`. Clone the
22314
+ // result so we don't expose an internal data structure in the user's console.
22315
+ return context.directives === null ? [] : [...context.directives];
22512
22316
  }
22513
22317
  /**
22514
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
22318
+ * Returns the debug (partial) metadata for a particular directive or component instance.
22319
+ * The function accepts an instance of a directive or component and returns the corresponding
22320
+ * metadata.
22321
+ *
22322
+ * @param directiveOrComponentInstance Instance of a directive or component
22323
+ * @returns metadata of the passed directive or component
22324
+ *
22325
+ * @publicApi
22326
+ * @globalApi ng
22515
22327
  */
22516
- class ComponentFactory extends ComponentFactory$1 {
22517
- /**
22518
- * @param componentDef The component definition.
22519
- * @param ngModule The NgModuleRef to which the factory is bound.
22520
- */
22521
- constructor(componentDef, ngModule) {
22522
- super();
22523
- this.componentDef = componentDef;
22524
- this.ngModule = ngModule;
22525
- this.componentType = componentDef.type;
22526
- this.selector = stringifyCSSSelectorList(componentDef.selectors);
22527
- this.ngContentSelectors =
22528
- componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
22529
- this.isBoundToModule = !!ngModule;
22530
- }
22531
- get inputs() {
22532
- return toRefArray(this.componentDef.inputs);
22328
+ function getDirectiveMetadata(directiveOrComponentInstance) {
22329
+ const { constructor } = directiveOrComponentInstance;
22330
+ if (!constructor) {
22331
+ throw new Error('Unable to find the instance constructor');
22533
22332
  }
22534
- get outputs() {
22535
- return toRefArray(this.componentDef.outputs);
22333
+ // In case a component inherits from a directive, we may have component and directive metadata
22334
+ // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
22335
+ const componentDef = getComponentDef$1(constructor);
22336
+ if (componentDef) {
22337
+ return {
22338
+ inputs: componentDef.inputs,
22339
+ outputs: componentDef.outputs,
22340
+ encapsulation: componentDef.encapsulation,
22341
+ changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
22342
+ ChangeDetectionStrategy.Default
22343
+ };
22536
22344
  }
22537
- create(injector, projectableNodes, rootSelectorOrNode, environmentInjector) {
22538
- environmentInjector = environmentInjector || this.ngModule;
22539
- let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ?
22540
- environmentInjector :
22541
- environmentInjector === null || environmentInjector === void 0 ? void 0 : environmentInjector.injector;
22542
- if (realEnvironmentInjector && this.componentDef.getStandaloneInjector !== null) {
22543
- realEnvironmentInjector = this.componentDef.getStandaloneInjector(realEnvironmentInjector) ||
22544
- realEnvironmentInjector;
22545
- }
22546
- const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
22547
- const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
22548
- const sanitizer = rootViewInjector.get(Sanitizer, null);
22549
- const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
22550
- // Determine a tag name used for creating host elements when this component is created
22551
- // dynamically. Default to 'div' if this component did not specify any tag name in its selector.
22552
- const elementName = this.componentDef.selectors[0][0] || 'div';
22553
- const hostRNode = rootSelectorOrNode ?
22554
- locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) :
22555
- createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
22556
- const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
22557
- 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
22558
- const rootContext = createRootContext();
22559
- // Create the root view. Uses empty TView and ContentTemplate.
22560
- const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
22561
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
22562
- // rootView is the parent when bootstrapping
22563
- // TODO(misko): it looks like we are entering view here but we don't really need to as
22564
- // `renderView` does that. However as the code is written it is needed because
22565
- // `createRootComponentView` and `createRootComponent` both read global state. Fixing those
22566
- // issues would allow us to drop this.
22567
- enterView(rootLView);
22568
- let component;
22569
- let tElementNode;
22570
- try {
22571
- const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
22572
- if (hostRNode) {
22573
- if (rootSelectorOrNode) {
22574
- setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
22575
- }
22576
- else {
22577
- // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
22578
- // is not defined), also apply attributes and classes extracted from component selector.
22579
- // Extract attributes and classes from the first selector only to match VE behavior.
22580
- const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
22581
- if (attrs) {
22582
- setUpAttributes(hostRenderer, hostRNode, attrs);
22583
- }
22584
- if (classes && classes.length > 0) {
22585
- writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
22586
- }
22587
- }
22588
- }
22589
- tElementNode = getTNode(rootTView, HEADER_OFFSET);
22590
- if (projectableNodes !== undefined) {
22591
- const projection = tElementNode.projection = [];
22592
- for (let i = 0; i < this.ngContentSelectors.length; i++) {
22593
- const nodesforSlot = projectableNodes[i];
22594
- // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
22595
- // case). Here we do normalize passed data structure to be an array of arrays to avoid
22596
- // complex checks down the line.
22597
- // We also normalize the length of the passed in projectable nodes (to match the number of
22598
- // <ng-container> slots defined by a component).
22599
- projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
22600
- }
22601
- }
22602
- // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
22603
- // executed here?
22604
- // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
22605
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
22606
- renderView(rootTView, rootLView, null);
22607
- }
22608
- finally {
22609
- leaveView();
22610
- }
22611
- return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
22345
+ const directiveDef = getDirectiveDef(constructor);
22346
+ if (directiveDef) {
22347
+ return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
22612
22348
  }
22349
+ return null;
22613
22350
  }
22614
- const componentFactoryResolver = new ComponentFactoryResolver();
22615
22351
  /**
22616
- * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
22617
- * ComponentFactoryResolver
22618
- * already exists, retrieves the existing ComponentFactoryResolver.
22352
+ * Retrieve map of local references.
22619
22353
  *
22620
- * @returns The ComponentFactoryResolver instance to use
22354
+ * The references are retrieved as a map of local reference name to element or directive instance.
22355
+ *
22356
+ * @param target DOM element, component or directive instance for which to retrieve
22357
+ * the local references.
22621
22358
  */
22622
- function injectComponentFactoryResolver() {
22623
- return componentFactoryResolver;
22359
+ function getLocalRefs(target) {
22360
+ const context = getLContext(target);
22361
+ if (context === null)
22362
+ return {};
22363
+ if (context.localRefs === undefined) {
22364
+ const lView = context.lView;
22365
+ if (lView === null) {
22366
+ return {};
22367
+ }
22368
+ context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
22369
+ }
22370
+ return context.localRefs || {};
22624
22371
  }
22625
22372
  /**
22626
- * Represents an instance of a Component created via a {@link ComponentFactory}.
22373
+ * Retrieves the host element of a component or directive instance.
22374
+ * The host element is the DOM element that matched the selector of the directive.
22627
22375
  *
22628
- * `ComponentRef` provides access to the Component Instance as well other objects related to this
22629
- * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
22630
- * method.
22376
+ * @param componentOrDirective Component or directive instance for which the host
22377
+ * element should be retrieved.
22378
+ * @returns Host element of the target.
22631
22379
  *
22380
+ * @publicApi
22381
+ * @globalApi ng
22632
22382
  */
22633
- class ComponentRef extends ComponentRef$1 {
22634
- constructor(componentType, instance, location, _rootLView, _tNode) {
22635
- super();
22636
- this.location = location;
22637
- this._rootLView = _rootLView;
22638
- this._tNode = _tNode;
22639
- this.instance = instance;
22640
- this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
22641
- this.componentType = componentType;
22642
- }
22643
- get injector() {
22644
- return new NodeInjector(this._tNode, this._rootLView);
22645
- }
22646
- destroy() {
22647
- this.hostView.destroy();
22648
- }
22649
- onDestroy(callback) {
22650
- this.hostView.onDestroy(callback);
22651
- }
22383
+ function getHostElement(componentOrDirective) {
22384
+ return getLContext(componentOrDirective).native;
22652
22385
  }
22653
-
22654
22386
  /**
22655
- * @license
22656
- * Copyright Google LLC All Rights Reserved.
22387
+ * Retrieves the rendered text for a given component.
22657
22388
  *
22658
- * Use of this source code is governed by an MIT-style license that can be
22659
- * found in the LICENSE file at https://angular.io/license
22389
+ * This function retrieves the host element of a component and
22390
+ * and then returns the `textContent` for that element. This implies
22391
+ * that the text returned will include re-projected content of
22392
+ * the component as well.
22393
+ *
22394
+ * @param component The component to return the content text for.
22660
22395
  */
22396
+ function getRenderedText(component) {
22397
+ const hostElement = getHostElement(component);
22398
+ return hostElement.textContent || '';
22399
+ }
22661
22400
  /**
22662
- * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
22663
- * @param ngModule NgModule class.
22664
- * @param parentInjector Optional injector instance to use as a parent for the module injector. If
22665
- * not provided, `NullInjector` will be used instead.
22401
+ * Retrieves a list of event listeners associated with a DOM element. The list does include host
22402
+ * listeners, but it does not include event listeners defined outside of the Angular context
22403
+ * (e.g. through `addEventListener`).
22404
+ *
22405
+ * @usageNotes
22406
+ * Given the following DOM structure:
22407
+ *
22408
+ * ```html
22409
+ * <app-root>
22410
+ * <div (click)="doSomething()"></div>
22411
+ * </app-root>
22412
+ * ```
22413
+ *
22414
+ * Calling `getListeners` on `<div>` will return an object that looks as follows:
22415
+ *
22416
+ * ```ts
22417
+ * {
22418
+ * name: 'click',
22419
+ * element: <div>,
22420
+ * callback: () => doSomething(),
22421
+ * useCapture: false
22422
+ * }
22423
+ * ```
22424
+ *
22425
+ * @param element Element for which the DOM listeners should be retrieved.
22426
+ * @returns Array of event listeners on the DOM element.
22427
+ *
22666
22428
  * @publicApi
22429
+ * @globalApi ng
22667
22430
  */
22668
- function createNgModuleRef(ngModule, parentInjector) {
22669
- return new NgModuleRef(ngModule, parentInjector !== null && parentInjector !== void 0 ? parentInjector : null);
22670
- }
22671
- class NgModuleRef extends NgModuleRef$1 {
22672
- constructor(ngModuleType, _parent) {
22673
- super();
22674
- this._parent = _parent;
22675
- // tslint:disable-next-line:require-internal-with-underscore
22676
- this._bootstrapComponents = [];
22677
- this.injector = this;
22678
- this.destroyCbs = [];
22679
- // When bootstrapping a module we have a dependency graph that looks like this:
22680
- // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
22681
- // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
22682
- // circular dependency which will result in a runtime error, because the injector doesn't
22683
- // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
22684
- // and providing it, rather than letting the injector resolve it.
22685
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22686
- const ngModuleDef = getNgModuleDef(ngModuleType);
22687
- ngDevMode &&
22688
- assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
22689
- this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
22690
- this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
22691
- { provide: NgModuleRef$1, useValue: this }, {
22692
- provide: ComponentFactoryResolver$1,
22693
- useValue: this.componentFactoryResolver
22431
+ function getListeners(element) {
22432
+ ngDevMode && assertDomElement(element);
22433
+ const lContext = getLContext(element);
22434
+ const lView = lContext === null ? null : lContext.lView;
22435
+ if (lView === null)
22436
+ return [];
22437
+ const tView = lView[TVIEW];
22438
+ const lCleanup = lView[CLEANUP];
22439
+ const tCleanup = tView.cleanup;
22440
+ const listeners = [];
22441
+ if (tCleanup && lCleanup) {
22442
+ for (let i = 0; i < tCleanup.length;) {
22443
+ const firstParam = tCleanup[i++];
22444
+ const secondParam = tCleanup[i++];
22445
+ if (typeof firstParam === 'string') {
22446
+ const name = firstParam;
22447
+ const listenerElement = unwrapRNode(lView[secondParam]);
22448
+ const callback = lCleanup[tCleanup[i++]];
22449
+ const useCaptureOrIndx = tCleanup[i++];
22450
+ // if useCaptureOrIndx is boolean then report it as is.
22451
+ // if useCaptureOrIndx is positive number then it in unsubscribe method
22452
+ // if useCaptureOrIndx is negative number then it is a Subscription
22453
+ const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
22454
+ const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
22455
+ if (element == listenerElement) {
22456
+ listeners.push({ element, name, callback, useCapture, type });
22457
+ }
22694
22458
  }
22695
- ], stringify(ngModuleType), new Set(['environment']));
22696
- // We need to resolve the injector types separately from the injector creation, because
22697
- // the module might be trying to use this ref in its constructor for DI which will cause a
22698
- // circular error that will eventually error out, because the injector isn't created yet.
22699
- this._r3Injector.resolveInjectorInitializers();
22700
- this.instance = this.get(ngModuleType);
22701
- }
22702
- get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
22703
- if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
22704
- return this;
22705
22459
  }
22706
- return this._r3Injector.get(token, notFoundValue, injectFlags);
22707
- }
22708
- destroy() {
22709
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22710
- const injector = this._r3Injector;
22711
- !injector.destroyed && injector.destroy();
22712
- this.destroyCbs.forEach(fn => fn());
22713
- this.destroyCbs = null;
22714
- }
22715
- onDestroy(callback) {
22716
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22717
- this.destroyCbs.push(callback);
22718
- }
22719
- }
22720
- class NgModuleFactory extends NgModuleFactory$1 {
22721
- constructor(moduleType) {
22722
- super();
22723
- this.moduleType = moduleType;
22724
- }
22725
- create(parentInjector) {
22726
- return new NgModuleRef(this.moduleType, parentInjector);
22727
22460
  }
22461
+ listeners.sort(sortListeners);
22462
+ return listeners;
22728
22463
  }
22729
- class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22730
- constructor(providers, parent, source) {
22731
- super();
22732
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22733
- this.instance = null;
22734
- const injector = new R3Injector([
22735
- ...providers,
22736
- { provide: NgModuleRef$1, useValue: this },
22737
- { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22738
- ], parent || getNullInjector(), source, new Set(['environment']));
22739
- this.injector = injector;
22740
- injector.resolveInjectorInitializers();
22741
- }
22742
- destroy() {
22743
- this.injector.destroy();
22744
- }
22745
- onDestroy(callback) {
22746
- this.injector.onDestroy(callback);
22747
- }
22464
+ function sortListeners(a, b) {
22465
+ if (a.name == b.name)
22466
+ return 0;
22467
+ return a.name < b.name ? -1 : 1;
22748
22468
  }
22749
22469
  /**
22750
- * Create a new environment injector.
22470
+ * This function should not exist because it is megamorphic and only mostly correct.
22751
22471
  *
22752
- * @publicApi
22753
- * @developerPreview
22472
+ * See call site for more info.
22754
22473
  */
22755
- function createEnvironmentInjector(providers, parent = null, debugName = null) {
22756
- const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22757
- return adapter.injector;
22474
+ function isDirectiveDefHack(obj) {
22475
+ return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
22758
22476
  }
22759
-
22760
22477
  /**
22761
- * @license
22762
- * Copyright Google LLC All Rights Reserved.
22478
+ * Returns the attached `DebugNode` instance for an element in the DOM.
22763
22479
  *
22764
- * Use of this source code is governed by an MIT-style license that can be
22765
- * found in the LICENSE file at https://angular.io/license
22766
- */
22767
- /**
22768
- * A service used by the framework to create instances of standalone injectors. Those injectors are
22769
- * created on demand in case of dynamic component instantiation and contain ambient providers
22770
- * collected from the imports graph rooted at a given standalone component.
22480
+ * @param element DOM element which is owned by an existing component's view.
22771
22481
  */
22772
- class StandaloneService {
22773
- constructor(_injector) {
22774
- this._injector = _injector;
22775
- this.cachedInjectors = new Map();
22482
+ function getDebugNode(element) {
22483
+ if (ngDevMode && !(element instanceof Node)) {
22484
+ throw new Error('Expecting instance of DOM Element');
22776
22485
  }
22777
- getOrCreateStandaloneInjector(componentDef) {
22778
- if (!componentDef.standalone) {
22779
- return null;
22780
- }
22781
- if (!this.cachedInjectors.has(componentDef.id)) {
22782
- const providers = internalImportProvidersFrom(false, componentDef.type);
22783
- const standaloneInjector = providers.length > 0 ?
22784
- createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22785
- null;
22786
- this.cachedInjectors.set(componentDef.id, standaloneInjector);
22787
- }
22788
- return this.cachedInjectors.get(componentDef.id);
22486
+ const lContext = getLContext(element);
22487
+ const lView = lContext ? lContext.lView : null;
22488
+ if (lView === null) {
22489
+ return null;
22789
22490
  }
22790
- ngOnDestroy() {
22791
- try {
22792
- for (const injector of this.cachedInjectors.values()) {
22793
- if (injector !== null) {
22794
- injector.destroy();
22795
- }
22796
- }
22797
- }
22798
- finally {
22799
- this.cachedInjectors.clear();
22800
- }
22491
+ const nodeIndex = lContext.nodeIndex;
22492
+ if (nodeIndex !== -1) {
22493
+ const valueInLView = lView[nodeIndex];
22494
+ // this means that value in the lView is a component with its own
22495
+ // data. In this situation the TNode is not accessed at the same spot.
22496
+ const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
22497
+ ngDevMode &&
22498
+ assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
22499
+ return buildDebugNode(tNode, lView);
22801
22500
  }
22501
+ return null;
22802
22502
  }
22803
- /** @nocollapse */
22804
- StandaloneService.ɵprov = ɵɵdefineInjectable({
22805
- token: StandaloneService,
22806
- providedIn: 'environment',
22807
- factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22808
- });
22809
22503
  /**
22810
- * A feature that acts as a setup code for the {@link StandaloneService}.
22504
+ * Retrieve the component `LView` from component/element.
22811
22505
  *
22812
- * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
22813
- * function (an entry points to a standalone injector creation) on a component definition object. We
22814
- * go through the features infrastructure to make sure that the standalone injector creation logic
22815
- * is tree-shakable and not included in applications that don't use standalone components.
22506
+ * NOTE: `LView` is a private and should not be leaked outside.
22507
+ * Don't export this method to `ng.*` on window.
22816
22508
  *
22817
- * @codeGenApi
22509
+ * @param target DOM element or component instance for which to retrieve the LView.
22818
22510
  */
22819
- function ɵɵStandaloneFeature(definition) {
22820
- definition.getStandaloneInjector = (parentInjector) => {
22821
- return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22822
- };
22511
+ function getComponentLView(target) {
22512
+ const lContext = getLContext(target);
22513
+ const nodeIndx = lContext.nodeIndex;
22514
+ const lView = lContext.lView;
22515
+ ngDevMode && assertLView(lView);
22516
+ const componentLView = lView[nodeIndx];
22517
+ ngDevMode && assertLView(componentLView);
22518
+ return componentLView;
22519
+ }
22520
+ /** Asserts that a value is a DOM Element. */
22521
+ function assertDomElement(value) {
22522
+ if (typeof Element !== 'undefined' && !(value instanceof Element)) {
22523
+ throw new Error('Expecting instance of DOM Element');
22524
+ }
22823
22525
  }
22824
22526
 
22825
22527
  /**
@@ -24040,7 +23742,7 @@ const unusedValueExportToPlacateAjd = 1;
24040
23742
  * Use of this source code is governed by an MIT-style license that can be
24041
23743
  * found in the LICENSE file at https://angular.io/license
24042
23744
  */
24043
- const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd;
23745
+ const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
24044
23746
  class LQuery_ {
24045
23747
  constructor(queryList) {
24046
23748
  this.queryList = queryList;
@@ -26893,5 +26595,5 @@ const __core_private_testing_placeholder__ = '';
26893
26595
  * Generated bundle index. Do not edit.
26894
26596
  */
26895
26597
 
26896
- export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick$1 as tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
26598
+ export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
26897
26599
  //# sourceMappingURL=testing.mjs.map