@angular/core 14.0.4 → 14.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/application_ref.mjs +1 -1
- package/esm2020/src/core.mjs +1 -1
- package/esm2020/src/core_render3_private_export.mjs +2 -2
- package/esm2020/src/debug/debug_node.mjs +2 -3
- package/esm2020/src/errors.mjs +1 -1
- package/esm2020/src/render/api.mjs +2 -11
- package/esm2020/src/render3/component.mjs +3 -58
- package/esm2020/src/render3/component_ref.mjs +9 -3
- package/esm2020/src/render3/index.mjs +3 -3
- package/esm2020/src/render3/instructions/listener.mjs +34 -44
- package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
- package/esm2020/src/render3/instructions/shared.mjs +19 -57
- package/esm2020/src/render3/instructions/styling.mjs +2 -2
- package/esm2020/src/render3/interfaces/renderer.mjs +1 -26
- package/esm2020/src/render3/interfaces/view.mjs +1 -1
- package/esm2020/src/render3/node_manipulation.mjs +24 -87
- package/esm2020/src/render3/node_manipulation_i18n.mjs +1 -1
- package/esm2020/src/render3/util/attrs_utils.mjs +4 -12
- package/esm2020/src/render3/util/view_utils.mjs +3 -6
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/fesm2015/core.mjs +1751 -1946
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +1625 -1912
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +1751 -1946
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +1625 -1912
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +55 -128
- package/package.json +1 -1
- package/testing/index.d.ts +1 -1
package/fesm2015/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.
|
|
2
|
+
* @license Angular v14.0.5
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -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$
|
|
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$
|
|
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
|
-
|
|
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
|
-
|
|
4475
|
-
renderer.setProperty(native, attrName, attrVal);
|
|
4476
|
-
}
|
|
4379
|
+
renderer.setProperty(native, attrName, attrVal);
|
|
4477
4380
|
}
|
|
4478
4381
|
else {
|
|
4479
|
-
|
|
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$
|
|
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
|
|
7425
|
-
renderer.createTextNode(value);
|
|
7390
|
+
return renderer.createText(value);
|
|
7426
7391
|
}
|
|
7427
7392
|
function updateTextNode(renderer, rNode, value) {
|
|
7428
7393
|
ngDevMode && ngDevMode.rendererSetText++;
|
|
7429
|
-
|
|
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
|
-
|
|
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 (
|
|
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 */
|
|
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
|
|
7890
|
-
* This is a utility function that can be used when native nodes were determined
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
8341
|
-
|
|
8342
|
-
|
|
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
|
|
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$
|
|
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)
|
|
@@ -11814,6 +11719,13 @@ class LContainerDebug {
|
|
|
11814
11719
|
}
|
|
11815
11720
|
}
|
|
11816
11721
|
|
|
11722
|
+
/**
|
|
11723
|
+
* @license
|
|
11724
|
+
* Copyright Google LLC All Rights Reserved.
|
|
11725
|
+
*
|
|
11726
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
11727
|
+
* found in the LICENSE file at https://angular.io/license
|
|
11728
|
+
*/
|
|
11817
11729
|
/**
|
|
11818
11730
|
* A permanent marker promise which signifies that the current CD tree is
|
|
11819
11731
|
* clean.
|
|
@@ -11881,7 +11793,7 @@ function refreshChildComponents(hostLView, components) {
|
|
|
11881
11793
|
/** Renders child components in the current view (creation mode). */
|
|
11882
11794
|
function renderChildComponents(hostLView, components) {
|
|
11883
11795
|
for (let i = 0; i < components.length; i++) {
|
|
11884
|
-
renderComponent
|
|
11796
|
+
renderComponent(hostLView, components[i]);
|
|
11885
11797
|
}
|
|
11886
11798
|
}
|
|
11887
11799
|
function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
|
|
@@ -12399,16 +12311,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
|
|
|
12399
12311
|
function createError(text, token) {
|
|
12400
12312
|
return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
|
|
12401
12313
|
}
|
|
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
12314
|
/**
|
|
12413
12315
|
* Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
|
|
12414
12316
|
*
|
|
@@ -12417,21 +12319,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
|
|
|
12417
12319
|
* @param encapsulation View Encapsulation defined for component that requests host element.
|
|
12418
12320
|
*/
|
|
12419
12321
|
function locateHostElement(renderer, elementOrSelector, encapsulation) {
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
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;
|
|
12322
|
+
// When using native Shadow DOM, do not clear host element to allow native slot projection
|
|
12323
|
+
const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
|
|
12324
|
+
return renderer.selectRootElement(elementOrSelector, preserveContent);
|
|
12435
12325
|
}
|
|
12436
12326
|
/**
|
|
12437
12327
|
* Saves context for this cleanup function in LView.cleanupInstances.
|
|
@@ -12646,13 +12536,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
|
|
|
12646
12536
|
// It is assumed that the sanitizer is only added when the compiler determines that the
|
|
12647
12537
|
// property is risky, so sanitization can be done without further checks.
|
|
12648
12538
|
value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
|
|
12649
|
-
|
|
12650
|
-
renderer.setProperty(element, propName, value);
|
|
12651
|
-
}
|
|
12652
|
-
else if (!isAnimationProp(propName)) {
|
|
12653
|
-
element.setProperty ? element.setProperty(propName, value) :
|
|
12654
|
-
element[propName] = value;
|
|
12655
|
-
}
|
|
12539
|
+
renderer.setProperty(element, propName, value);
|
|
12656
12540
|
}
|
|
12657
12541
|
else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
|
|
12658
12542
|
// If the node is a container and the property didn't
|
|
@@ -12676,23 +12560,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
|
|
|
12676
12560
|
const debugValue = normalizeDebugBindingValue(value);
|
|
12677
12561
|
if (type & 3 /* TNodeType.AnyRNode */) {
|
|
12678
12562
|
if (value == null) {
|
|
12679
|
-
|
|
12680
|
-
element.removeAttribute(attrName);
|
|
12563
|
+
renderer.removeAttribute(element, attrName);
|
|
12681
12564
|
}
|
|
12682
12565
|
else {
|
|
12683
|
-
|
|
12684
|
-
renderer.setAttribute(element, attrName, debugValue) :
|
|
12685
|
-
element.setAttribute(attrName, debugValue);
|
|
12566
|
+
renderer.setAttribute(element, attrName, debugValue);
|
|
12686
12567
|
}
|
|
12687
12568
|
}
|
|
12688
12569
|
else {
|
|
12689
12570
|
const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
|
|
12690
|
-
|
|
12691
|
-
renderer.setValue(element, textContent);
|
|
12692
|
-
}
|
|
12693
|
-
else {
|
|
12694
|
-
element.textContent = textContent;
|
|
12695
|
-
}
|
|
12571
|
+
renderer.setValue(element, textContent);
|
|
12696
12572
|
}
|
|
12697
12573
|
}
|
|
12698
12574
|
function setNgReflectProperties(lView, element, type, dataValue, value) {
|
|
@@ -13046,19 +12922,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
|
|
|
13046
12922
|
function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
|
|
13047
12923
|
if (value == null) {
|
|
13048
12924
|
ngDevMode && ngDevMode.rendererRemoveAttribute++;
|
|
13049
|
-
|
|
13050
|
-
element.removeAttribute(name);
|
|
12925
|
+
renderer.removeAttribute(element, name, namespace);
|
|
13051
12926
|
}
|
|
13052
12927
|
else {
|
|
13053
12928
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
13054
12929
|
const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
|
|
13055
|
-
|
|
13056
|
-
renderer.setAttribute(element, name, strValue, namespace);
|
|
13057
|
-
}
|
|
13058
|
-
else {
|
|
13059
|
-
namespace ? element.setAttributeNS(namespace, name, strValue) :
|
|
13060
|
-
element.setAttribute(name, strValue);
|
|
13061
|
-
}
|
|
12930
|
+
renderer.setAttribute(element, name, strValue, namespace);
|
|
13062
12931
|
}
|
|
13063
12932
|
}
|
|
13064
12933
|
/**
|
|
@@ -13150,7 +13019,6 @@ const LContainerArray = class LContainer extends Array {
|
|
|
13150
13019
|
*/
|
|
13151
13020
|
function createLContainer(hostNative, currentView, native, tNode) {
|
|
13152
13021
|
ngDevMode && assertLView(currentView);
|
|
13153
|
-
ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
|
|
13154
13022
|
// https://jsperf.com/array-literal-vs-new-array-really
|
|
13155
13023
|
const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
|
|
13156
13024
|
true, // Boolean `true` in this position signifies that this is an `LContainer`
|
|
@@ -13266,7 +13134,7 @@ function refreshContainsDirtyView(lView) {
|
|
|
13266
13134
|
}
|
|
13267
13135
|
}
|
|
13268
13136
|
}
|
|
13269
|
-
function renderComponent
|
|
13137
|
+
function renderComponent(hostLView, componentHostIdx) {
|
|
13270
13138
|
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
|
|
13271
13139
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
|
13272
13140
|
const componentTView = componentView[TVIEW];
|
|
@@ -13618,48 +13486,135 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
|
|
|
13618
13486
|
* Use of this source code is governed by an MIT-style license that can be
|
|
13619
13487
|
* found in the LICENSE file at https://angular.io/license
|
|
13620
13488
|
*/
|
|
13489
|
+
// TODO: A hack to not pull in the NullInjector from @angular/core.
|
|
13490
|
+
const NULL_INJECTOR = {
|
|
13491
|
+
get: (token, notFoundValue) => {
|
|
13492
|
+
throwProviderNotFoundError(token, 'NullInjector');
|
|
13493
|
+
}
|
|
13494
|
+
};
|
|
13621
13495
|
/**
|
|
13622
|
-
*
|
|
13496
|
+
* Creates the root component view and the root component node.
|
|
13623
13497
|
*
|
|
13624
|
-
*
|
|
13498
|
+
* @param rNode Render host element.
|
|
13499
|
+
* @param def ComponentDef
|
|
13500
|
+
* @param rootView The parent view where the host node is stored
|
|
13501
|
+
* @param rendererFactory Factory to be used for creating child renderers.
|
|
13502
|
+
* @param hostRenderer The current renderer
|
|
13503
|
+
* @param sanitizer The sanitizer, if provided
|
|
13625
13504
|
*
|
|
13626
|
-
* @
|
|
13505
|
+
* @returns Component view created
|
|
13627
13506
|
*/
|
|
13628
|
-
function
|
|
13629
|
-
const
|
|
13630
|
-
|
|
13507
|
+
function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
|
|
13508
|
+
const tView = rootView[TVIEW];
|
|
13509
|
+
const index = HEADER_OFFSET;
|
|
13510
|
+
ngDevMode && assertIndexInRange(rootView, index);
|
|
13511
|
+
rootView[index] = rNode;
|
|
13512
|
+
// '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
|
|
13513
|
+
// the same time we want to communicate the debug `TNode` that this is a special `TNode`
|
|
13514
|
+
// representing a host element.
|
|
13515
|
+
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
|
|
13516
|
+
const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
|
|
13517
|
+
if (mergedAttrs !== null) {
|
|
13518
|
+
computeStaticStyling(tNode, mergedAttrs, true);
|
|
13519
|
+
if (rNode !== null) {
|
|
13520
|
+
setUpAttributes(hostRenderer, rNode, mergedAttrs);
|
|
13521
|
+
if (tNode.classes !== null) {
|
|
13522
|
+
writeDirectClass(hostRenderer, rNode, tNode.classes);
|
|
13523
|
+
}
|
|
13524
|
+
if (tNode.styles !== null) {
|
|
13525
|
+
writeDirectStyle(hostRenderer, rNode, tNode.styles);
|
|
13526
|
+
}
|
|
13527
|
+
}
|
|
13528
|
+
}
|
|
13529
|
+
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
13530
|
+
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
13531
|
+
if (tView.firstCreatePass) {
|
|
13532
|
+
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
13533
|
+
markAsComponentHost(tView, tNode);
|
|
13534
|
+
initTNodeFlags(tNode, rootView.length, 1);
|
|
13535
|
+
}
|
|
13536
|
+
addToViewTree(rootView, componentView);
|
|
13537
|
+
// Store component view at node index, with node as the HOST
|
|
13538
|
+
return rootView[index] = componentView;
|
|
13631
13539
|
}
|
|
13632
13540
|
/**
|
|
13633
|
-
*
|
|
13634
|
-
*
|
|
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.
|
|
13541
|
+
* Creates a root component and sets it up with features and host bindings. Shared by
|
|
13542
|
+
* renderComponent() and ViewContainerRef.createComponent().
|
|
13640
13543
|
*/
|
|
13641
|
-
function
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13544
|
+
function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
|
|
13545
|
+
const tView = rootLView[TVIEW];
|
|
13546
|
+
// Create directive instance with factory() and store at next index in viewData
|
|
13547
|
+
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
|
13548
|
+
rootContext.components.push(component);
|
|
13549
|
+
componentView[CONTEXT] = component;
|
|
13550
|
+
if (hostFeatures !== null) {
|
|
13551
|
+
for (const feature of hostFeatures) {
|
|
13552
|
+
feature(component, componentDef);
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
// We want to generate an empty QueryList for root content queries for backwards
|
|
13556
|
+
// compatibility with ViewEngine.
|
|
13557
|
+
if (componentDef.contentQueries) {
|
|
13558
|
+
const tNode = getCurrentTNode();
|
|
13559
|
+
ngDevMode && assertDefined(tNode, 'TNode expected');
|
|
13560
|
+
componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
|
|
13561
|
+
}
|
|
13562
|
+
const rootTNode = getCurrentTNode();
|
|
13563
|
+
ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
|
|
13564
|
+
if (tView.firstCreatePass &&
|
|
13565
|
+
(componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
|
|
13566
|
+
setSelectedIndex(rootTNode.index);
|
|
13567
|
+
const rootTView = rootLView[TVIEW];
|
|
13568
|
+
registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
|
|
13569
|
+
invokeHostBindingsInCreationMode(componentDef, component);
|
|
13570
|
+
}
|
|
13571
|
+
return component;
|
|
13572
|
+
}
|
|
13573
|
+
function createRootContext(scheduler, playerHandler) {
|
|
13574
|
+
return {
|
|
13575
|
+
components: [],
|
|
13576
|
+
scheduler: scheduler || defaultScheduler,
|
|
13577
|
+
clean: CLEAN_PROMISE,
|
|
13578
|
+
playerHandler: playerHandler || null,
|
|
13579
|
+
flags: 0 /* RootContextFlags.Empty */
|
|
13580
|
+
};
|
|
13581
|
+
}
|
|
13647
13582
|
/**
|
|
13648
|
-
* Used to
|
|
13583
|
+
* Used to enable lifecycle hooks on the root component.
|
|
13649
13584
|
*
|
|
13650
|
-
*
|
|
13651
|
-
*
|
|
13652
|
-
*
|
|
13585
|
+
* Include this feature when calling `renderComponent` if the root component
|
|
13586
|
+
* you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
|
|
13587
|
+
* be called properly.
|
|
13653
13588
|
*
|
|
13654
|
-
*
|
|
13655
|
-
*
|
|
13656
|
-
*
|
|
13657
|
-
*
|
|
13589
|
+
* Example:
|
|
13590
|
+
*
|
|
13591
|
+
* ```
|
|
13592
|
+
* renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
|
|
13593
|
+
* ```
|
|
13658
13594
|
*/
|
|
13659
|
-
function
|
|
13660
|
-
const
|
|
13661
|
-
|
|
13662
|
-
|
|
13595
|
+
function LifecycleHooksFeature() {
|
|
13596
|
+
const tNode = getCurrentTNode();
|
|
13597
|
+
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
13598
|
+
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
13599
|
+
}
|
|
13600
|
+
/**
|
|
13601
|
+
* Wait on component until it is rendered.
|
|
13602
|
+
*
|
|
13603
|
+
* This function returns a `Promise` which is resolved when the component's
|
|
13604
|
+
* change detection is executed. This is determined by finding the scheduler
|
|
13605
|
+
* associated with the `component`'s render tree and waiting until the scheduler
|
|
13606
|
+
* flushes. If nothing is scheduled, the function returns a resolved promise.
|
|
13607
|
+
*
|
|
13608
|
+
* Example:
|
|
13609
|
+
* ```
|
|
13610
|
+
* await whenRendered(myComponent);
|
|
13611
|
+
* ```
|
|
13612
|
+
*
|
|
13613
|
+
* @param component Component to wait upon
|
|
13614
|
+
* @returns Promise which resolves when the component is rendered.
|
|
13615
|
+
*/
|
|
13616
|
+
function whenRendered(component) {
|
|
13617
|
+
return getRootContext(component).clean;
|
|
13663
13618
|
}
|
|
13664
13619
|
|
|
13665
13620
|
/**
|
|
@@ -13669,407 +13624,312 @@ function tick(component) {
|
|
|
13669
13624
|
* Use of this source code is governed by an MIT-style license that can be
|
|
13670
13625
|
* found in the LICENSE file at https://angular.io/license
|
|
13671
13626
|
*/
|
|
13627
|
+
function getSuperType(type) {
|
|
13628
|
+
return Object.getPrototypeOf(type.prototype).constructor;
|
|
13629
|
+
}
|
|
13672
13630
|
/**
|
|
13673
|
-
*
|
|
13674
|
-
*
|
|
13675
|
-
* @usageNotes
|
|
13676
|
-
* Given the following DOM structure:
|
|
13677
|
-
*
|
|
13678
|
-
* ```html
|
|
13679
|
-
* <app-root>
|
|
13680
|
-
* <div>
|
|
13681
|
-
* <child-comp></child-comp>
|
|
13682
|
-
* </div>
|
|
13683
|
-
* </app-root>
|
|
13684
|
-
* ```
|
|
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.
|
|
13631
|
+
* Merges the definition from a super class to a sub class.
|
|
13632
|
+
* @param definition The definition that is a SubClass of another directive of component
|
|
13695
13633
|
*
|
|
13696
|
-
* @
|
|
13697
|
-
* @globalApi ng
|
|
13634
|
+
* @codeGenApi
|
|
13698
13635
|
*/
|
|
13699
|
-
function
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13636
|
+
function ɵɵInheritDefinitionFeature(definition) {
|
|
13637
|
+
let superType = getSuperType(definition.type);
|
|
13638
|
+
let shouldInheritFields = true;
|
|
13639
|
+
const inheritanceChain = [definition];
|
|
13640
|
+
while (superType) {
|
|
13641
|
+
let superDef = undefined;
|
|
13642
|
+
if (isComponentDef(definition)) {
|
|
13643
|
+
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
13644
|
+
superDef = superType.ɵcmp || superType.ɵdir;
|
|
13708
13645
|
}
|
|
13709
|
-
|
|
13646
|
+
else {
|
|
13647
|
+
if (superType.ɵcmp) {
|
|
13648
|
+
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
|
|
13649
|
+
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
|
|
13650
|
+
}
|
|
13651
|
+
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
13652
|
+
superDef = superType.ɵdir;
|
|
13653
|
+
}
|
|
13654
|
+
if (superDef) {
|
|
13655
|
+
if (shouldInheritFields) {
|
|
13656
|
+
inheritanceChain.push(superDef);
|
|
13657
|
+
// Some fields in the definition may be empty, if there were no values to put in them that
|
|
13658
|
+
// would've justified object creation. Unwrap them if necessary.
|
|
13659
|
+
const writeableDef = definition;
|
|
13660
|
+
writeableDef.inputs = maybeUnwrapEmpty(definition.inputs);
|
|
13661
|
+
writeableDef.declaredInputs = maybeUnwrapEmpty(definition.declaredInputs);
|
|
13662
|
+
writeableDef.outputs = maybeUnwrapEmpty(definition.outputs);
|
|
13663
|
+
// Merge hostBindings
|
|
13664
|
+
const superHostBindings = superDef.hostBindings;
|
|
13665
|
+
superHostBindings && inheritHostBindings(definition, superHostBindings);
|
|
13666
|
+
// Merge queries
|
|
13667
|
+
const superViewQuery = superDef.viewQuery;
|
|
13668
|
+
const superContentQueries = superDef.contentQueries;
|
|
13669
|
+
superViewQuery && inheritViewQuery(definition, superViewQuery);
|
|
13670
|
+
superContentQueries && inheritContentQueries(definition, superContentQueries);
|
|
13671
|
+
// Merge inputs and outputs
|
|
13672
|
+
fillProperties(definition.inputs, superDef.inputs);
|
|
13673
|
+
fillProperties(definition.declaredInputs, superDef.declaredInputs);
|
|
13674
|
+
fillProperties(definition.outputs, superDef.outputs);
|
|
13675
|
+
// Merge animations metadata.
|
|
13676
|
+
// If `superDef` is a Component, the `data` field is present (defaults to an empty object).
|
|
13677
|
+
if (isComponentDef(superDef) && superDef.data.animation) {
|
|
13678
|
+
// If super def is a Component, the `definition` is also a Component, since Directives can
|
|
13679
|
+
// not inherit Components (we throw an error above and cannot reach this code).
|
|
13680
|
+
const defData = definition.data;
|
|
13681
|
+
defData.animation = (defData.animation || []).concat(superDef.data.animation);
|
|
13682
|
+
}
|
|
13683
|
+
}
|
|
13684
|
+
// Run parent features
|
|
13685
|
+
const features = superDef.features;
|
|
13686
|
+
if (features) {
|
|
13687
|
+
for (let i = 0; i < features.length; i++) {
|
|
13688
|
+
const feature = features[i];
|
|
13689
|
+
if (feature && feature.ngInherit) {
|
|
13690
|
+
feature(definition);
|
|
13691
|
+
}
|
|
13692
|
+
// If `InheritDefinitionFeature` is a part of the current `superDef`, it means that this
|
|
13693
|
+
// def already has all the necessary information inherited from its super class(es), so we
|
|
13694
|
+
// can stop merging fields from super classes. However we need to iterate through the
|
|
13695
|
+
// prototype chain to look for classes that might contain other "features" (like
|
|
13696
|
+
// NgOnChanges), which we should invoke for the original `definition`. We set the
|
|
13697
|
+
// `shouldInheritFields` flag to indicate that, essentially skipping fields inheritance
|
|
13698
|
+
// logic and only invoking functions from the "features" list.
|
|
13699
|
+
if (feature === ɵɵInheritDefinitionFeature) {
|
|
13700
|
+
shouldInheritFields = false;
|
|
13701
|
+
}
|
|
13702
|
+
}
|
|
13703
|
+
}
|
|
13704
|
+
}
|
|
13705
|
+
superType = Object.getPrototypeOf(superType);
|
|
13710
13706
|
}
|
|
13711
|
-
|
|
13707
|
+
mergeHostAttrsAcrossInheritance(inheritanceChain);
|
|
13712
13708
|
}
|
|
13713
13709
|
/**
|
|
13714
|
-
*
|
|
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.
|
|
13710
|
+
* Merge the `hostAttrs` and `hostVars` from the inherited parent to the base class.
|
|
13721
13711
|
*
|
|
13722
|
-
* @
|
|
13723
|
-
*
|
|
13712
|
+
* @param inheritanceChain A list of `WritableDefs` starting at the top most type and listing
|
|
13713
|
+
* sub-types in order. For each type take the `hostAttrs` and `hostVars` and merge it with the child
|
|
13714
|
+
* type.
|
|
13724
13715
|
*/
|
|
13725
|
-
function
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13716
|
+
function mergeHostAttrsAcrossInheritance(inheritanceChain) {
|
|
13717
|
+
let hostVars = 0;
|
|
13718
|
+
let hostAttrs = null;
|
|
13719
|
+
// We process the inheritance order from the base to the leaves here.
|
|
13720
|
+
for (let i = inheritanceChain.length - 1; i >= 0; i--) {
|
|
13721
|
+
const def = inheritanceChain[i];
|
|
13722
|
+
// For each `hostVars`, we need to add the superclass amount.
|
|
13723
|
+
def.hostVars = (hostVars += def.hostVars);
|
|
13724
|
+
// for each `hostAttrs` we need to merge it with superclass.
|
|
13725
|
+
def.hostAttrs =
|
|
13726
|
+
mergeHostAttrs(def.hostAttrs, hostAttrs = mergeHostAttrs(hostAttrs, def.hostAttrs));
|
|
13727
|
+
}
|
|
13730
13728
|
}
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
13741
|
-
* part of a component view.
|
|
13742
|
-
*
|
|
13743
|
-
* @publicApi
|
|
13744
|
-
* @globalApi ng
|
|
13745
|
-
*/
|
|
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;
|
|
13729
|
+
function maybeUnwrapEmpty(value) {
|
|
13730
|
+
if (value === EMPTY_OBJ) {
|
|
13731
|
+
return {};
|
|
13732
|
+
}
|
|
13733
|
+
else if (value === EMPTY_ARRAY) {
|
|
13734
|
+
return [];
|
|
13735
|
+
}
|
|
13736
|
+
else {
|
|
13737
|
+
return value;
|
|
13754
13738
|
}
|
|
13755
|
-
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
13756
13739
|
}
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13740
|
+
function inheritViewQuery(definition, superViewQuery) {
|
|
13741
|
+
const prevViewQuery = definition.viewQuery;
|
|
13742
|
+
if (prevViewQuery) {
|
|
13743
|
+
definition.viewQuery = (rf, ctx) => {
|
|
13744
|
+
superViewQuery(rf, ctx);
|
|
13745
|
+
prevViewQuery(rf, ctx);
|
|
13746
|
+
};
|
|
13747
|
+
}
|
|
13748
|
+
else {
|
|
13749
|
+
definition.viewQuery = superViewQuery;
|
|
13750
|
+
}
|
|
13751
|
+
}
|
|
13752
|
+
function inheritContentQueries(definition, superContentQueries) {
|
|
13753
|
+
const prevContentQueries = definition.contentQueries;
|
|
13754
|
+
if (prevContentQueries) {
|
|
13755
|
+
definition.contentQueries = (rf, ctx, directiveIndex) => {
|
|
13756
|
+
superContentQueries(rf, ctx, directiveIndex);
|
|
13757
|
+
prevContentQueries(rf, ctx, directiveIndex);
|
|
13758
|
+
};
|
|
13759
|
+
}
|
|
13760
|
+
else {
|
|
13761
|
+
definition.contentQueries = superContentQueries;
|
|
13762
|
+
}
|
|
13763
|
+
}
|
|
13764
|
+
function inheritHostBindings(definition, superHostBindings) {
|
|
13765
|
+
const prevHostBindings = definition.hostBindings;
|
|
13766
|
+
if (prevHostBindings) {
|
|
13767
|
+
definition.hostBindings = (rf, ctx) => {
|
|
13768
|
+
superHostBindings(rf, ctx);
|
|
13769
|
+
prevHostBindings(rf, ctx);
|
|
13770
|
+
};
|
|
13771
|
+
}
|
|
13772
|
+
else {
|
|
13773
|
+
definition.hostBindings = superHostBindings;
|
|
13774
|
+
}
|
|
13771
13775
|
}
|
|
13776
|
+
|
|
13772
13777
|
/**
|
|
13773
|
-
*
|
|
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.
|
|
13778
|
+
* @license
|
|
13779
|
+
* Copyright Google LLC All Rights Reserved.
|
|
13778
13780
|
*
|
|
13779
|
-
*
|
|
13780
|
-
*
|
|
13781
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
13782
|
+
* found in the LICENSE file at https://angular.io/license
|
|
13781
13783
|
*/
|
|
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);
|
|
13789
|
-
}
|
|
13790
13784
|
/**
|
|
13791
|
-
*
|
|
13792
|
-
*
|
|
13793
|
-
* @param element Element for which the injection tokens should be retrieved.
|
|
13785
|
+
* Fields which exist on either directive or component definitions, and need to be copied from
|
|
13786
|
+
* parent to child classes by the `ɵɵCopyDefinitionFeature`.
|
|
13794
13787
|
*/
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
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);
|
|
13815
|
-
}
|
|
13816
|
-
return providerTokens;
|
|
13817
|
-
}
|
|
13788
|
+
const COPY_DIRECTIVE_FIELDS = [
|
|
13789
|
+
// The child class should use the providers of its parent.
|
|
13790
|
+
'providersResolver',
|
|
13791
|
+
// Not listed here are any fields which are handled by the `ɵɵInheritDefinitionFeature`, such
|
|
13792
|
+
// as inputs, outputs, and host binding functions.
|
|
13793
|
+
];
|
|
13818
13794
|
/**
|
|
13819
|
-
*
|
|
13820
|
-
*
|
|
13821
|
-
*
|
|
13822
|
-
* @usageNotes
|
|
13823
|
-
* Given the following DOM structure:
|
|
13795
|
+
* Fields which exist only on component definitions, and need to be copied from parent to child
|
|
13796
|
+
* classes by the `ɵɵCopyDefinitionFeature`.
|
|
13824
13797
|
*
|
|
13825
|
-
*
|
|
13826
|
-
*
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13798
|
+
* The type here allows any field of `ComponentDef` which is not also a property of `DirectiveDef`,
|
|
13799
|
+
* since those should go in `COPY_DIRECTIVE_FIELDS` above.
|
|
13800
|
+
*/
|
|
13801
|
+
const COPY_COMPONENT_FIELDS = [
|
|
13802
|
+
// The child class should use the template function of its parent, including all template
|
|
13803
|
+
// semantics.
|
|
13804
|
+
'template',
|
|
13805
|
+
'decls',
|
|
13806
|
+
'consts',
|
|
13807
|
+
'vars',
|
|
13808
|
+
'onPush',
|
|
13809
|
+
'ngContentSelectors',
|
|
13810
|
+
// The child class should use the CSS styles of its parent, including all styling semantics.
|
|
13811
|
+
'styles',
|
|
13812
|
+
'encapsulation',
|
|
13813
|
+
// The child class should be checked by the runtime in the same way as its parent.
|
|
13814
|
+
'schemas',
|
|
13815
|
+
];
|
|
13816
|
+
/**
|
|
13817
|
+
* Copies the fields not handled by the `ɵɵInheritDefinitionFeature` from the supertype of a
|
|
13818
|
+
* definition.
|
|
13831
13819
|
*
|
|
13832
|
-
*
|
|
13833
|
-
*
|
|
13820
|
+
* This exists primarily to support ngcc migration of an existing View Engine pattern, where an
|
|
13821
|
+
* entire decorator is inherited from a parent to a child class. When ngcc detects this case, it
|
|
13822
|
+
* generates a skeleton definition on the child class, and applies this feature.
|
|
13834
13823
|
*
|
|
13835
|
-
*
|
|
13824
|
+
* The `ɵɵCopyDefinitionFeature` then copies any needed fields from the parent class' definition,
|
|
13825
|
+
* including things like the component template function.
|
|
13836
13826
|
*
|
|
13837
|
-
* @param
|
|
13838
|
-
*
|
|
13827
|
+
* @param definition The definition of a child class which inherits from a parent class with its
|
|
13828
|
+
* own definition.
|
|
13839
13829
|
*
|
|
13840
|
-
* @
|
|
13841
|
-
* @globalApi ng
|
|
13830
|
+
* @codeGenApi
|
|
13842
13831
|
*/
|
|
13843
|
-
function
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13832
|
+
function ɵɵCopyDefinitionFeature(definition) {
|
|
13833
|
+
let superType = getSuperType(definition.type);
|
|
13834
|
+
let superDef = undefined;
|
|
13835
|
+
if (isComponentDef(definition)) {
|
|
13836
|
+
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
13837
|
+
superDef = superType.ɵcmp;
|
|
13847
13838
|
}
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
return [];
|
|
13839
|
+
else {
|
|
13840
|
+
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
13841
|
+
superDef = superType.ɵdir;
|
|
13852
13842
|
}
|
|
13853
|
-
|
|
13854
|
-
const
|
|
13855
|
-
|
|
13856
|
-
|
|
13843
|
+
// Needed because `definition` fields are readonly.
|
|
13844
|
+
const defAny = definition;
|
|
13845
|
+
// Copy over any fields that apply to either directives or components.
|
|
13846
|
+
for (const field of COPY_DIRECTIVE_FIELDS) {
|
|
13847
|
+
defAny[field] = superDef[field];
|
|
13857
13848
|
}
|
|
13858
|
-
if (
|
|
13859
|
-
|
|
13849
|
+
if (isComponentDef(superDef)) {
|
|
13850
|
+
// Copy over any component-specific fields.
|
|
13851
|
+
for (const field of COPY_COMPONENT_FIELDS) {
|
|
13852
|
+
defAny[field] = superDef[field];
|
|
13853
|
+
}
|
|
13860
13854
|
}
|
|
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
13855
|
}
|
|
13856
|
+
|
|
13865
13857
|
/**
|
|
13866
|
-
*
|
|
13867
|
-
*
|
|
13868
|
-
* metadata.
|
|
13869
|
-
*
|
|
13870
|
-
* @param directiveOrComponentInstance Instance of a directive or component
|
|
13871
|
-
* @returns metadata of the passed directive or component
|
|
13858
|
+
* @license
|
|
13859
|
+
* Copyright Google LLC All Rights Reserved.
|
|
13872
13860
|
*
|
|
13873
|
-
*
|
|
13874
|
-
*
|
|
13861
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
13862
|
+
* found in the LICENSE file at https://angular.io/license
|
|
13875
13863
|
*/
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
if (!
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
if (directiveDef) {
|
|
13895
|
-
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
13864
|
+
let _symbolIterator = null;
|
|
13865
|
+
function getSymbolIterator() {
|
|
13866
|
+
if (!_symbolIterator) {
|
|
13867
|
+
const Symbol = _global$1['Symbol'];
|
|
13868
|
+
if (Symbol && Symbol.iterator) {
|
|
13869
|
+
_symbolIterator = Symbol.iterator;
|
|
13870
|
+
}
|
|
13871
|
+
else {
|
|
13872
|
+
// es6-shim specific logic
|
|
13873
|
+
const keys = Object.getOwnPropertyNames(Map.prototype);
|
|
13874
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
13875
|
+
const key = keys[i];
|
|
13876
|
+
if (key !== 'entries' && key !== 'size' &&
|
|
13877
|
+
Map.prototype[key] === Map.prototype['entries']) {
|
|
13878
|
+
_symbolIterator = key;
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
}
|
|
13896
13882
|
}
|
|
13897
|
-
return
|
|
13883
|
+
return _symbolIterator;
|
|
13898
13884
|
}
|
|
13885
|
+
|
|
13899
13886
|
/**
|
|
13900
|
-
*
|
|
13901
|
-
*
|
|
13902
|
-
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
13887
|
+
* @license
|
|
13888
|
+
* Copyright Google LLC All Rights Reserved.
|
|
13903
13889
|
*
|
|
13904
|
-
*
|
|
13905
|
-
*
|
|
13890
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
13891
|
+
* found in the LICENSE file at https://angular.io/license
|
|
13906
13892
|
*/
|
|
13907
|
-
function
|
|
13908
|
-
|
|
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
|
-
/**
|
|
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
|
|
13930
|
-
*/
|
|
13931
|
-
function getHostElement(componentOrDirective) {
|
|
13932
|
-
return getLContext(componentOrDirective).native;
|
|
13893
|
+
function isIterable(obj) {
|
|
13894
|
+
return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
|
|
13933
13895
|
}
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
* the component as well.
|
|
13941
|
-
*
|
|
13942
|
-
* @param component The component to return the content text for.
|
|
13943
|
-
*/
|
|
13944
|
-
function getRenderedText(component) {
|
|
13945
|
-
const hostElement = getHostElement(component);
|
|
13946
|
-
return hostElement.textContent || '';
|
|
13896
|
+
function isListLikeIterable(obj) {
|
|
13897
|
+
if (!isJsObject(obj))
|
|
13898
|
+
return false;
|
|
13899
|
+
return Array.isArray(obj) ||
|
|
13900
|
+
(!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
|
|
13901
|
+
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
|
|
13947
13902
|
}
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
* ```
|
|
13961
|
-
*
|
|
13962
|
-
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
13963
|
-
*
|
|
13964
|
-
* ```ts
|
|
13965
|
-
* {
|
|
13966
|
-
* name: 'click',
|
|
13967
|
-
* element: <div>,
|
|
13968
|
-
* callback: () => doSomething(),
|
|
13969
|
-
* useCapture: false
|
|
13970
|
-
* }
|
|
13971
|
-
* ```
|
|
13972
|
-
*
|
|
13973
|
-
* @param element Element for which the DOM listeners should be retrieved.
|
|
13974
|
-
* @returns Array of event listeners on the DOM element.
|
|
13975
|
-
*
|
|
13976
|
-
* @publicApi
|
|
13977
|
-
* @globalApi ng
|
|
13978
|
-
*/
|
|
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
|
-
}
|
|
14007
|
-
}
|
|
13903
|
+
function areIterablesEqual(a, b, comparator) {
|
|
13904
|
+
const iterator1 = a[getSymbolIterator()]();
|
|
13905
|
+
const iterator2 = b[getSymbolIterator()]();
|
|
13906
|
+
while (true) {
|
|
13907
|
+
const item1 = iterator1.next();
|
|
13908
|
+
const item2 = iterator2.next();
|
|
13909
|
+
if (item1.done && item2.done)
|
|
13910
|
+
return true;
|
|
13911
|
+
if (item1.done || item2.done)
|
|
13912
|
+
return false;
|
|
13913
|
+
if (!comparator(item1.value, item2.value))
|
|
13914
|
+
return false;
|
|
14008
13915
|
}
|
|
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
|
-
}
|
|
14017
|
-
/**
|
|
14018
|
-
* This function should not exist because it is megamorphic and only mostly correct.
|
|
14019
|
-
*
|
|
14020
|
-
* See call site for more info.
|
|
14021
|
-
*/
|
|
14022
|
-
function isDirectiveDefHack(obj) {
|
|
14023
|
-
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
14024
13916
|
}
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
function getDebugNode(element) {
|
|
14031
|
-
if (ngDevMode && !(element instanceof Node)) {
|
|
14032
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14033
|
-
}
|
|
14034
|
-
const lContext = getLContext(element);
|
|
14035
|
-
const lView = lContext ? lContext.lView : null;
|
|
14036
|
-
if (lView === null) {
|
|
14037
|
-
return null;
|
|
13917
|
+
function iterateListLike(obj, fn) {
|
|
13918
|
+
if (Array.isArray(obj)) {
|
|
13919
|
+
for (let i = 0; i < obj.length; i++) {
|
|
13920
|
+
fn(obj[i]);
|
|
13921
|
+
}
|
|
14038
13922
|
}
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
ngDevMode &&
|
|
14046
|
-
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
14047
|
-
return buildDebugNode(tNode, lView);
|
|
13923
|
+
else {
|
|
13924
|
+
const iterator = obj[getSymbolIterator()]();
|
|
13925
|
+
let item;
|
|
13926
|
+
while (!((item = iterator.next()).done)) {
|
|
13927
|
+
fn(item.value);
|
|
13928
|
+
}
|
|
14048
13929
|
}
|
|
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
13930
|
}
|
|
14068
|
-
|
|
14069
|
-
function
|
|
14070
|
-
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
14071
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14072
|
-
}
|
|
13931
|
+
function isJsObject(o) {
|
|
13932
|
+
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
|
14073
13933
|
}
|
|
14074
13934
|
|
|
14075
13935
|
/**
|
|
@@ -14079,18 +13939,22 @@ function assertDomElement(value) {
|
|
|
14079
13939
|
* Use of this source code is governed by an MIT-style license that can be
|
|
14080
13940
|
* found in the LICENSE file at https://angular.io/license
|
|
14081
13941
|
*/
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
13942
|
+
function devModeEqual(a, b) {
|
|
13943
|
+
const isListLikeIterableA = isListLikeIterable(a);
|
|
13944
|
+
const isListLikeIterableB = isListLikeIterable(b);
|
|
13945
|
+
if (isListLikeIterableA && isListLikeIterableB) {
|
|
13946
|
+
return areIterablesEqual(a, b, devModeEqual);
|
|
13947
|
+
}
|
|
13948
|
+
else {
|
|
13949
|
+
const isAObject = a && (typeof a === 'object' || typeof a === 'function');
|
|
13950
|
+
const isBObject = b && (typeof b === 'object' || typeof b === 'function');
|
|
13951
|
+
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
|
|
13952
|
+
return true;
|
|
13953
|
+
}
|
|
13954
|
+
else {
|
|
13955
|
+
return Object.is(a, b);
|
|
13956
|
+
}
|
|
13957
|
+
}
|
|
14094
13958
|
}
|
|
14095
13959
|
|
|
14096
13960
|
/**
|
|
@@ -14100,70 +13964,73 @@ function applyChanges(component) {
|
|
|
14100
13964
|
* Use of this source code is governed by an MIT-style license that can be
|
|
14101
13965
|
* found in the LICENSE file at https://angular.io/license
|
|
14102
13966
|
*/
|
|
13967
|
+
// TODO(misko): consider inlining
|
|
13968
|
+
/** Updates binding and returns the value. */
|
|
13969
|
+
function updateBinding(lView, bindingIndex, value) {
|
|
13970
|
+
return lView[bindingIndex] = value;
|
|
13971
|
+
}
|
|
13972
|
+
/** Gets the current binding value. */
|
|
13973
|
+
function getBinding(lView, bindingIndex) {
|
|
13974
|
+
ngDevMode && assertIndexInRange(lView, bindingIndex);
|
|
13975
|
+
ngDevMode &&
|
|
13976
|
+
assertNotSame(lView[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
|
|
13977
|
+
return lView[bindingIndex];
|
|
13978
|
+
}
|
|
14103
13979
|
/**
|
|
14104
|
-
*
|
|
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
|
|
13980
|
+
* Updates binding if changed, then returns whether it was updated.
|
|
14110
13981
|
*
|
|
14111
|
-
*
|
|
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`.
|
|
13982
|
+
* This function also checks the `CheckNoChangesMode` and throws if changes are made.
|
|
13983
|
+
* Some changes (Objects/iterables) during `CheckNoChangesMode` are exempt to comply with VE
|
|
13984
|
+
* behavior.
|
|
14121
13985
|
*
|
|
14122
|
-
*
|
|
14123
|
-
*
|
|
13986
|
+
* @param lView current `LView`
|
|
13987
|
+
* @param bindingIndex The binding in the `LView` to check
|
|
13988
|
+
* @param value New value to check against `lView[bindingIndex]`
|
|
13989
|
+
* @returns `true` if the bindings has changed. (Throws if binding has changed during
|
|
13990
|
+
* `CheckNoChangesMode`)
|
|
14124
13991
|
*/
|
|
14125
|
-
function
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
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);
|
|
13992
|
+
function bindingUpdated(lView, bindingIndex, value) {
|
|
13993
|
+
ngDevMode && assertNotSame(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
|
|
13994
|
+
ngDevMode &&
|
|
13995
|
+
assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
|
|
13996
|
+
const oldValue = lView[bindingIndex];
|
|
13997
|
+
if (Object.is(oldValue, value)) {
|
|
13998
|
+
return false;
|
|
14144
13999
|
}
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
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] = {};
|
|
14000
|
+
else {
|
|
14001
|
+
if (ngDevMode && isInCheckNoChangesMode()) {
|
|
14002
|
+
// View engine didn't report undefined values as changed on the first checkNoChanges pass
|
|
14003
|
+
// (before the change detection was run).
|
|
14004
|
+
const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined;
|
|
14005
|
+
if (!devModeEqual(oldValueToCompare, value)) {
|
|
14006
|
+
const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
|
|
14007
|
+
throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName);
|
|
14162
14008
|
}
|
|
14163
|
-
|
|
14164
|
-
|
|
14009
|
+
// There was a change, but the `devModeEqual` decided that the change is exempt from an error.
|
|
14010
|
+
// For this reason we exit as if no change. The early exit is needed to prevent the changed
|
|
14011
|
+
// value to be written into `LView` (If we would write the new value that we would not see it
|
|
14012
|
+
// as change on next CD.)
|
|
14013
|
+
return false;
|
|
14014
|
+
}
|
|
14015
|
+
lView[bindingIndex] = value;
|
|
14016
|
+
return true;
|
|
14165
14017
|
}
|
|
14166
14018
|
}
|
|
14019
|
+
/** Updates 2 bindings if changed, then returns whether either was updated. */
|
|
14020
|
+
function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
|
|
14021
|
+
const different = bindingUpdated(lView, bindingIndex, exp1);
|
|
14022
|
+
return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
|
|
14023
|
+
}
|
|
14024
|
+
/** Updates 3 bindings if changed, then returns whether any was updated. */
|
|
14025
|
+
function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
|
|
14026
|
+
const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
|
|
14027
|
+
return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
|
|
14028
|
+
}
|
|
14029
|
+
/** Updates 4 bindings if changed, then returns whether any was updated. */
|
|
14030
|
+
function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
|
|
14031
|
+
const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
|
|
14032
|
+
return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
|
|
14033
|
+
}
|
|
14167
14034
|
|
|
14168
14035
|
/**
|
|
14169
14036
|
* @license
|
|
@@ -14172,885 +14039,281 @@ function publishGlobalUtil(name, fn) {
|
|
|
14172
14039
|
* Use of this source code is governed by an MIT-style license that can be
|
|
14173
14040
|
* found in the LICENSE file at https://angular.io/license
|
|
14174
14041
|
*/
|
|
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
14042
|
/**
|
|
14182
|
-
*
|
|
14183
|
-
*
|
|
14184
|
-
*
|
|
14185
|
-
*
|
|
14186
|
-
*
|
|
14187
|
-
*
|
|
14188
|
-
*
|
|
14189
|
-
*
|
|
14190
|
-
*
|
|
14191
|
-
*
|
|
14192
|
-
* @
|
|
14193
|
-
*/
|
|
14194
|
-
function
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
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();
|
|
14043
|
+
* Updates the value of or removes a bound attribute on an Element.
|
|
14044
|
+
*
|
|
14045
|
+
* Used in the case of `[attr.title]="value"`
|
|
14046
|
+
*
|
|
14047
|
+
* @param name name The name of the attribute.
|
|
14048
|
+
* @param value value The attribute is removed when value is `null` or `undefined`.
|
|
14049
|
+
* Otherwise the attribute value is set to the stringified value.
|
|
14050
|
+
* @param sanitizer An optional function used to sanitize the value.
|
|
14051
|
+
* @param namespace Optional namespace to use when setting the attribute.
|
|
14052
|
+
*
|
|
14053
|
+
* @codeGenApi
|
|
14054
|
+
*/
|
|
14055
|
+
function ɵɵattribute(name, value, sanitizer, namespace) {
|
|
14056
|
+
const lView = getLView();
|
|
14057
|
+
const bindingIndex = nextBindingIndex();
|
|
14058
|
+
if (bindingUpdated(lView, bindingIndex, value)) {
|
|
14059
|
+
const tView = getTView();
|
|
14060
|
+
const tNode = getSelectedTNode();
|
|
14061
|
+
elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace);
|
|
14062
|
+
ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex);
|
|
14229
14063
|
}
|
|
14230
|
-
return
|
|
14064
|
+
return ɵɵattribute;
|
|
14231
14065
|
}
|
|
14066
|
+
|
|
14232
14067
|
/**
|
|
14233
|
-
*
|
|
14068
|
+
* @license
|
|
14069
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14234
14070
|
*
|
|
14235
|
-
*
|
|
14236
|
-
*
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
*
|
|
14240
|
-
* @param sanitizer The sanitizer, if provided
|
|
14071
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14072
|
+
* found in the LICENSE file at https://angular.io/license
|
|
14073
|
+
*/
|
|
14074
|
+
/**
|
|
14075
|
+
* Create interpolation bindings with a variable number of expressions.
|
|
14241
14076
|
*
|
|
14242
|
-
*
|
|
14077
|
+
* If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
|
|
14078
|
+
* Those are faster because there is no need to create an array of expressions and iterate over it.
|
|
14079
|
+
*
|
|
14080
|
+
* `values`:
|
|
14081
|
+
* - has static text at even indexes,
|
|
14082
|
+
* - has evaluated expressions at odd indexes.
|
|
14083
|
+
*
|
|
14084
|
+
* Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
|
|
14243
14085
|
*/
|
|
14244
|
-
function
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
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
|
-
}
|
|
14086
|
+
function interpolationV(lView, values) {
|
|
14087
|
+
ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
|
|
14088
|
+
ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
|
|
14089
|
+
let isBindingUpdated = false;
|
|
14090
|
+
let bindingIndex = getBindingIndex();
|
|
14091
|
+
for (let i = 1; i < values.length; i += 2) {
|
|
14092
|
+
// Check if bindings (odd indexes) have changed
|
|
14093
|
+
isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
|
|
14265
14094
|
}
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
14270
|
-
markAsComponentHost(tView, tNode);
|
|
14271
|
-
initTNodeFlags(tNode, rootView.length, 1);
|
|
14095
|
+
setBindingIndex(bindingIndex);
|
|
14096
|
+
if (!isBindingUpdated) {
|
|
14097
|
+
return NO_CHANGE;
|
|
14272
14098
|
}
|
|
14273
|
-
|
|
14274
|
-
|
|
14275
|
-
|
|
14099
|
+
// Build the updated content
|
|
14100
|
+
let content = values[0];
|
|
14101
|
+
for (let i = 1; i < values.length; i += 2) {
|
|
14102
|
+
content += renderStringify(values[i]) + values[i + 1];
|
|
14103
|
+
}
|
|
14104
|
+
return content;
|
|
14276
14105
|
}
|
|
14277
14106
|
/**
|
|
14278
|
-
* Creates
|
|
14279
|
-
*
|
|
14107
|
+
* Creates an interpolation binding with 1 expression.
|
|
14108
|
+
*
|
|
14109
|
+
* @param prefix static value used for concatenation only.
|
|
14110
|
+
* @param v0 value checked for change.
|
|
14111
|
+
* @param suffix static value used for concatenation only.
|
|
14280
14112
|
*/
|
|
14281
|
-
function
|
|
14282
|
-
const
|
|
14283
|
-
|
|
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;
|
|
14113
|
+
function interpolation1(lView, prefix, v0, suffix) {
|
|
14114
|
+
const different = bindingUpdated(lView, nextBindingIndex(), v0);
|
|
14115
|
+
return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
|
|
14309
14116
|
}
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14117
|
+
/**
|
|
14118
|
+
* Creates an interpolation binding with 2 expressions.
|
|
14119
|
+
*/
|
|
14120
|
+
function interpolation2(lView, prefix, v0, i0, v1, suffix) {
|
|
14121
|
+
const bindingIndex = getBindingIndex();
|
|
14122
|
+
const different = bindingUpdated2(lView, bindingIndex, v0, v1);
|
|
14123
|
+
incrementBindingIndex(2);
|
|
14124
|
+
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
|
|
14318
14125
|
}
|
|
14319
14126
|
/**
|
|
14320
|
-
*
|
|
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
|
-
* ```
|
|
14127
|
+
* Creates an interpolation binding with 3 expressions.
|
|
14331
14128
|
*/
|
|
14332
|
-
function
|
|
14333
|
-
const
|
|
14334
|
-
|
|
14335
|
-
|
|
14129
|
+
function interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix) {
|
|
14130
|
+
const bindingIndex = getBindingIndex();
|
|
14131
|
+
const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
|
|
14132
|
+
incrementBindingIndex(3);
|
|
14133
|
+
return different ?
|
|
14134
|
+
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
|
|
14135
|
+
NO_CHANGE;
|
|
14336
14136
|
}
|
|
14337
14137
|
/**
|
|
14338
|
-
*
|
|
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.
|
|
14138
|
+
* Create an interpolation binding with 4 expressions.
|
|
14352
14139
|
*/
|
|
14353
|
-
function
|
|
14354
|
-
|
|
14140
|
+
function interpolation4(lView, prefix, v0, i0, v1, i1, v2, i2, v3, suffix) {
|
|
14141
|
+
const bindingIndex = getBindingIndex();
|
|
14142
|
+
const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
|
14143
|
+
incrementBindingIndex(4);
|
|
14144
|
+
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
|
14145
|
+
renderStringify(v2) + i2 + renderStringify(v3) + suffix :
|
|
14146
|
+
NO_CHANGE;
|
|
14355
14147
|
}
|
|
14356
|
-
|
|
14357
14148
|
/**
|
|
14358
|
-
*
|
|
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
|
|
14149
|
+
* Creates an interpolation binding with 5 expressions.
|
|
14363
14150
|
*/
|
|
14364
|
-
function
|
|
14365
|
-
|
|
14151
|
+
function interpolation5(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix) {
|
|
14152
|
+
const bindingIndex = getBindingIndex();
|
|
14153
|
+
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
|
14154
|
+
different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
|
|
14155
|
+
incrementBindingIndex(5);
|
|
14156
|
+
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
|
14157
|
+
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + suffix :
|
|
14158
|
+
NO_CHANGE;
|
|
14366
14159
|
}
|
|
14367
14160
|
/**
|
|
14368
|
-
*
|
|
14369
|
-
* @param definition The definition that is a SubClass of another directive of component
|
|
14370
|
-
*
|
|
14371
|
-
* @codeGenApi
|
|
14161
|
+
* Creates an interpolation binding with 6 expressions.
|
|
14372
14162
|
*/
|
|
14373
|
-
function
|
|
14374
|
-
|
|
14375
|
-
let
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
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);
|
|
14163
|
+
function interpolation6(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix) {
|
|
14164
|
+
const bindingIndex = getBindingIndex();
|
|
14165
|
+
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
|
14166
|
+
different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
|
|
14167
|
+
incrementBindingIndex(6);
|
|
14168
|
+
return different ?
|
|
14169
|
+
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
|
14170
|
+
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
|
|
14171
|
+
NO_CHANGE;
|
|
14445
14172
|
}
|
|
14446
14173
|
/**
|
|
14447
|
-
*
|
|
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.
|
|
14174
|
+
* Creates an interpolation binding with 7 expressions.
|
|
14452
14175
|
*/
|
|
14453
|
-
function
|
|
14454
|
-
|
|
14455
|
-
let
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
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
|
-
}
|
|
14176
|
+
function interpolation7(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix) {
|
|
14177
|
+
const bindingIndex = getBindingIndex();
|
|
14178
|
+
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
|
14179
|
+
different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
|
|
14180
|
+
incrementBindingIndex(7);
|
|
14181
|
+
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
|
14182
|
+
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
|
|
14183
|
+
renderStringify(v5) + i5 + renderStringify(v6) + suffix :
|
|
14184
|
+
NO_CHANGE;
|
|
14500
14185
|
}
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
|
|
14510
|
-
|
|
14511
|
-
|
|
14186
|
+
/**
|
|
14187
|
+
* Creates an interpolation binding with 8 expressions.
|
|
14188
|
+
*/
|
|
14189
|
+
function interpolation8(lView, prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix) {
|
|
14190
|
+
const bindingIndex = getBindingIndex();
|
|
14191
|
+
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
|
14192
|
+
different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
|
|
14193
|
+
incrementBindingIndex(8);
|
|
14194
|
+
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 +
|
|
14195
|
+
renderStringify(v2) + i2 + renderStringify(v3) + i3 + renderStringify(v4) + i4 +
|
|
14196
|
+
renderStringify(v5) + i5 + renderStringify(v6) + i6 + renderStringify(v7) + suffix :
|
|
14197
|
+
NO_CHANGE;
|
|
14512
14198
|
}
|
|
14513
14199
|
|
|
14514
14200
|
/**
|
|
14515
|
-
* @license
|
|
14516
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14517
14201
|
*
|
|
14518
|
-
*
|
|
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`.
|
|
14202
|
+
* Update an interpolated attribute on an element with single bound value surrounded by text.
|
|
14534
14203
|
*
|
|
14535
|
-
*
|
|
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.
|
|
14204
|
+
* Used when the value passed to a property has 1 interpolated value in it:
|
|
14556
14205
|
*
|
|
14557
|
-
*
|
|
14558
|
-
*
|
|
14559
|
-
*
|
|
14206
|
+
* ```html
|
|
14207
|
+
* <div attr.title="prefix{{v0}}suffix"></div>
|
|
14208
|
+
* ```
|
|
14560
14209
|
*
|
|
14561
|
-
*
|
|
14562
|
-
* including things like the component template function.
|
|
14210
|
+
* Its compiled representation is::
|
|
14563
14211
|
*
|
|
14564
|
-
*
|
|
14565
|
-
*
|
|
14212
|
+
* ```ts
|
|
14213
|
+
* ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
|
|
14214
|
+
* ```
|
|
14566
14215
|
*
|
|
14216
|
+
* @param attrName The name of the attribute to update
|
|
14217
|
+
* @param prefix Static value used for concatenation only.
|
|
14218
|
+
* @param v0 Value checked for change.
|
|
14219
|
+
* @param suffix Static value used for concatenation only.
|
|
14220
|
+
* @param sanitizer An optional sanitizer function
|
|
14221
|
+
* @returns itself, so that it may be chained.
|
|
14567
14222
|
* @codeGenApi
|
|
14568
14223
|
*/
|
|
14569
|
-
function
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
if (
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
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
|
-
}
|
|
14224
|
+
function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
|
|
14225
|
+
const lView = getLView();
|
|
14226
|
+
const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
|
|
14227
|
+
if (interpolatedValue !== NO_CHANGE) {
|
|
14228
|
+
const tNode = getSelectedTNode();
|
|
14229
|
+
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
14230
|
+
ngDevMode &&
|
|
14231
|
+
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
|
|
14591
14232
|
}
|
|
14233
|
+
return ɵɵattributeInterpolate1;
|
|
14592
14234
|
}
|
|
14593
|
-
|
|
14594
14235
|
/**
|
|
14595
|
-
* @license
|
|
14596
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14597
14236
|
*
|
|
14598
|
-
*
|
|
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.
|
|
14237
|
+
* Update an interpolated attribute on an element with 2 bound values surrounded by text.
|
|
14626
14238
|
*
|
|
14627
|
-
*
|
|
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.
|
|
14239
|
+
* Used when the value passed to a property has 2 interpolated values in it:
|
|
14675
14240
|
*
|
|
14676
|
-
*
|
|
14677
|
-
*
|
|
14678
|
-
|
|
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
|
-
}
|
|
14694
|
-
}
|
|
14695
|
-
}
|
|
14696
|
-
|
|
14697
|
-
/**
|
|
14698
|
-
* @license
|
|
14699
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14241
|
+
* ```html
|
|
14242
|
+
* <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
|
|
14243
|
+
* ```
|
|
14700
14244
|
*
|
|
14701
|
-
*
|
|
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.
|
|
14245
|
+
* Its compiled representation is::
|
|
14718
14246
|
*
|
|
14719
|
-
*
|
|
14720
|
-
*
|
|
14721
|
-
*
|
|
14247
|
+
* ```ts
|
|
14248
|
+
* ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
|
|
14249
|
+
* ```
|
|
14722
14250
|
*
|
|
14723
|
-
* @param
|
|
14724
|
-
* @param
|
|
14725
|
-
* @param
|
|
14726
|
-
* @
|
|
14727
|
-
*
|
|
14251
|
+
* @param attrName The name of the attribute to update
|
|
14252
|
+
* @param prefix Static value used for concatenation only.
|
|
14253
|
+
* @param v0 Value checked for change.
|
|
14254
|
+
* @param i0 Static value used for concatenation only.
|
|
14255
|
+
* @param v1 Value checked for change.
|
|
14256
|
+
* @param suffix Static value used for concatenation only.
|
|
14257
|
+
* @param sanitizer An optional sanitizer function
|
|
14258
|
+
* @returns itself, so that it may be chained.
|
|
14259
|
+
* @codeGenApi
|
|
14728
14260
|
*/
|
|
14729
|
-
function
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
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;
|
|
14261
|
+
function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
|
|
14262
|
+
const lView = getLView();
|
|
14263
|
+
const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
|
|
14264
|
+
if (interpolatedValue !== NO_CHANGE) {
|
|
14265
|
+
const tNode = getSelectedTNode();
|
|
14266
|
+
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
14267
|
+
ngDevMode &&
|
|
14268
|
+
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
|
|
14754
14269
|
}
|
|
14270
|
+
return ɵɵattributeInterpolate2;
|
|
14755
14271
|
}
|
|
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
14272
|
/**
|
|
14773
|
-
* @license
|
|
14774
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14775
14273
|
*
|
|
14776
|
-
*
|
|
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.
|
|
14274
|
+
* Update an interpolated attribute on an element with 3 bound values surrounded by text.
|
|
14781
14275
|
*
|
|
14782
|
-
* Used
|
|
14276
|
+
* Used when the value passed to a property has 3 interpolated values in it:
|
|
14783
14277
|
*
|
|
14784
|
-
*
|
|
14785
|
-
*
|
|
14786
|
-
*
|
|
14787
|
-
*
|
|
14788
|
-
*
|
|
14278
|
+
* ```html
|
|
14279
|
+
* <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
|
|
14280
|
+
* ```
|
|
14281
|
+
*
|
|
14282
|
+
* Its compiled representation is::
|
|
14283
|
+
*
|
|
14284
|
+
* ```ts
|
|
14285
|
+
* ɵɵattributeInterpolate3(
|
|
14286
|
+
* 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
|
|
14287
|
+
* ```
|
|
14789
14288
|
*
|
|
14289
|
+
* @param attrName The name of the attribute to update
|
|
14290
|
+
* @param prefix Static value used for concatenation only.
|
|
14291
|
+
* @param v0 Value checked for change.
|
|
14292
|
+
* @param i0 Static value used for concatenation only.
|
|
14293
|
+
* @param v1 Value checked for change.
|
|
14294
|
+
* @param i1 Static value used for concatenation only.
|
|
14295
|
+
* @param v2 Value checked for change.
|
|
14296
|
+
* @param suffix Static value used for concatenation only.
|
|
14297
|
+
* @param sanitizer An optional sanitizer function
|
|
14298
|
+
* @returns itself, so that it may be chained.
|
|
14790
14299
|
* @codeGenApi
|
|
14791
14300
|
*/
|
|
14792
|
-
function
|
|
14301
|
+
function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
|
|
14793
14302
|
const lView = getLView();
|
|
14794
|
-
const
|
|
14795
|
-
if (
|
|
14796
|
-
const tView = getTView();
|
|
14303
|
+
const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
|
|
14304
|
+
if (interpolatedValue !== NO_CHANGE) {
|
|
14797
14305
|
const tNode = getSelectedTNode();
|
|
14798
|
-
elementAttributeInternal(tNode, lView,
|
|
14799
|
-
ngDevMode &&
|
|
14306
|
+
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
14307
|
+
ngDevMode &&
|
|
14308
|
+
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
|
|
14800
14309
|
}
|
|
14801
|
-
return
|
|
14310
|
+
return ɵɵattributeInterpolate3;
|
|
14802
14311
|
}
|
|
14803
|
-
|
|
14804
14312
|
/**
|
|
14805
|
-
* @license
|
|
14806
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14807
14313
|
*
|
|
14808
|
-
*
|
|
14809
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14810
|
-
*/
|
|
14811
|
-
/**
|
|
14812
|
-
* Create interpolation bindings with a variable number of expressions.
|
|
14314
|
+
* Update an interpolated attribute on an element with 4 bound values surrounded by text.
|
|
14813
14315
|
*
|
|
14814
|
-
*
|
|
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:
|
|
14942
|
-
*
|
|
14943
|
-
* ```html
|
|
14944
|
-
* <div attr.title="prefix{{v0}}suffix"></div>
|
|
14945
|
-
* ```
|
|
14946
|
-
*
|
|
14947
|
-
* Its compiled representation is::
|
|
14948
|
-
*
|
|
14949
|
-
* ```ts
|
|
14950
|
-
* ɵɵattributeInterpolate1('title', 'prefix', v0, 'suffix');
|
|
14951
|
-
* ```
|
|
14952
|
-
*
|
|
14953
|
-
* @param attrName The name of the attribute to update
|
|
14954
|
-
* @param prefix Static value used for concatenation only.
|
|
14955
|
-
* @param v0 Value checked for change.
|
|
14956
|
-
* @param suffix Static value used for concatenation only.
|
|
14957
|
-
* @param sanitizer An optional sanitizer function
|
|
14958
|
-
* @returns itself, so that it may be chained.
|
|
14959
|
-
* @codeGenApi
|
|
14960
|
-
*/
|
|
14961
|
-
function ɵɵattributeInterpolate1(attrName, prefix, v0, suffix, sanitizer, namespace) {
|
|
14962
|
-
const lView = getLView();
|
|
14963
|
-
const interpolatedValue = interpolation1(lView, prefix, v0, suffix);
|
|
14964
|
-
if (interpolatedValue !== NO_CHANGE) {
|
|
14965
|
-
const tNode = getSelectedTNode();
|
|
14966
|
-
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
14967
|
-
ngDevMode &&
|
|
14968
|
-
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 1, prefix, suffix);
|
|
14969
|
-
}
|
|
14970
|
-
return ɵɵattributeInterpolate1;
|
|
14971
|
-
}
|
|
14972
|
-
/**
|
|
14973
|
-
*
|
|
14974
|
-
* Update an interpolated attribute on an element with 2 bound values surrounded by text.
|
|
14975
|
-
*
|
|
14976
|
-
* Used when the value passed to a property has 2 interpolated values in it:
|
|
14977
|
-
*
|
|
14978
|
-
* ```html
|
|
14979
|
-
* <div attr.title="prefix{{v0}}-{{v1}}suffix"></div>
|
|
14980
|
-
* ```
|
|
14981
|
-
*
|
|
14982
|
-
* Its compiled representation is::
|
|
14983
|
-
*
|
|
14984
|
-
* ```ts
|
|
14985
|
-
* ɵɵattributeInterpolate2('title', 'prefix', v0, '-', v1, 'suffix');
|
|
14986
|
-
* ```
|
|
14987
|
-
*
|
|
14988
|
-
* @param attrName The name of the attribute to update
|
|
14989
|
-
* @param prefix Static value used for concatenation only.
|
|
14990
|
-
* @param v0 Value checked for change.
|
|
14991
|
-
* @param i0 Static value used for concatenation only.
|
|
14992
|
-
* @param v1 Value checked for change.
|
|
14993
|
-
* @param suffix Static value used for concatenation only.
|
|
14994
|
-
* @param sanitizer An optional sanitizer function
|
|
14995
|
-
* @returns itself, so that it may be chained.
|
|
14996
|
-
* @codeGenApi
|
|
14997
|
-
*/
|
|
14998
|
-
function ɵɵattributeInterpolate2(attrName, prefix, v0, i0, v1, suffix, sanitizer, namespace) {
|
|
14999
|
-
const lView = getLView();
|
|
15000
|
-
const interpolatedValue = interpolation2(lView, prefix, v0, i0, v1, suffix);
|
|
15001
|
-
if (interpolatedValue !== NO_CHANGE) {
|
|
15002
|
-
const tNode = getSelectedTNode();
|
|
15003
|
-
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
15004
|
-
ngDevMode &&
|
|
15005
|
-
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 2, prefix, i0, suffix);
|
|
15006
|
-
}
|
|
15007
|
-
return ɵɵattributeInterpolate2;
|
|
15008
|
-
}
|
|
15009
|
-
/**
|
|
15010
|
-
*
|
|
15011
|
-
* Update an interpolated attribute on an element with 3 bound values surrounded by text.
|
|
15012
|
-
*
|
|
15013
|
-
* Used when the value passed to a property has 3 interpolated values in it:
|
|
15014
|
-
*
|
|
15015
|
-
* ```html
|
|
15016
|
-
* <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}suffix"></div>
|
|
15017
|
-
* ```
|
|
15018
|
-
*
|
|
15019
|
-
* Its compiled representation is::
|
|
15020
|
-
*
|
|
15021
|
-
* ```ts
|
|
15022
|
-
* ɵɵattributeInterpolate3(
|
|
15023
|
-
* 'title', 'prefix', v0, '-', v1, '-', v2, 'suffix');
|
|
15024
|
-
* ```
|
|
15025
|
-
*
|
|
15026
|
-
* @param attrName The name of the attribute to update
|
|
15027
|
-
* @param prefix Static value used for concatenation only.
|
|
15028
|
-
* @param v0 Value checked for change.
|
|
15029
|
-
* @param i0 Static value used for concatenation only.
|
|
15030
|
-
* @param v1 Value checked for change.
|
|
15031
|
-
* @param i1 Static value used for concatenation only.
|
|
15032
|
-
* @param v2 Value checked for change.
|
|
15033
|
-
* @param suffix Static value used for concatenation only.
|
|
15034
|
-
* @param sanitizer An optional sanitizer function
|
|
15035
|
-
* @returns itself, so that it may be chained.
|
|
15036
|
-
* @codeGenApi
|
|
15037
|
-
*/
|
|
15038
|
-
function ɵɵattributeInterpolate3(attrName, prefix, v0, i0, v1, i1, v2, suffix, sanitizer, namespace) {
|
|
15039
|
-
const lView = getLView();
|
|
15040
|
-
const interpolatedValue = interpolation3(lView, prefix, v0, i0, v1, i1, v2, suffix);
|
|
15041
|
-
if (interpolatedValue !== NO_CHANGE) {
|
|
15042
|
-
const tNode = getSelectedTNode();
|
|
15043
|
-
elementAttributeInternal(tNode, lView, attrName, interpolatedValue, sanitizer, namespace);
|
|
15044
|
-
ngDevMode &&
|
|
15045
|
-
storePropertyBindingMetadata(getTView().data, tNode, 'attr.' + attrName, getBindingIndex() - 3, prefix, i0, i1, suffix);
|
|
15046
|
-
}
|
|
15047
|
-
return ɵɵattributeInterpolate3;
|
|
15048
|
-
}
|
|
15049
|
-
/**
|
|
15050
|
-
*
|
|
15051
|
-
* Update an interpolated attribute on an element with 4 bound values surrounded by text.
|
|
15052
|
-
*
|
|
15053
|
-
* Used when the value passed to a property has 4 interpolated values in it:
|
|
14316
|
+
* Used when the value passed to a property has 4 interpolated values in it:
|
|
15054
14317
|
*
|
|
15055
14318
|
* ```html
|
|
15056
14319
|
* <div attr.title="prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}suffix"></div>
|
|
@@ -15326,26 +14589,77 @@ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
|
|
|
15326
14589
|
* Use of this source code is governed by an MIT-style license that can be
|
|
15327
14590
|
* found in the LICENSE file at https://angular.io/license
|
|
15328
14591
|
*/
|
|
15329
|
-
function templateFirstCreatePass(index, tView, lView, templateFn, decls, vars, tagName, attrsIndex, localRefsIndex) {
|
|
15330
|
-
ngDevMode && assertFirstCreatePass(tView);
|
|
15331
|
-
ngDevMode && ngDevMode.firstCreatePass++;
|
|
15332
|
-
const tViewConsts = tView.consts;
|
|
15333
|
-
// TODO(pk): refactor getOrCreateTNode to have the "create" only version
|
|
15334
|
-
const tNode = getOrCreateTNode(tView, index, 4 /* TNodeType.Container */, tagName || null, getConstant(tViewConsts, attrsIndex));
|
|
15335
|
-
resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
|
|
15336
|
-
registerPostOrderHooks(tView, tNode);
|
|
15337
|
-
const embeddedTView = tNode.tViews = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
|
|
15338
|
-
if (tView.queries !== null) {
|
|
15339
|
-
tView.queries.template(tView, tNode);
|
|
15340
|
-
embeddedTView.queries = tView.queries.embeddedTView(tNode);
|
|
15341
|
-
}
|
|
15342
|
-
return tNode;
|
|
15343
|
-
}
|
|
15344
14592
|
/**
|
|
15345
|
-
*
|
|
14593
|
+
* Synchronously perform change detection on a component (and possibly its sub-components).
|
|
15346
14594
|
*
|
|
15347
|
-
*
|
|
15348
|
-
*
|
|
14595
|
+
* This function triggers change detection in a synchronous way on a component.
|
|
14596
|
+
*
|
|
14597
|
+
* @param component The component which the change detection should be performed on.
|
|
14598
|
+
*/
|
|
14599
|
+
function detectChanges(component) {
|
|
14600
|
+
const view = getComponentViewByInstance(component);
|
|
14601
|
+
detectChangesInternal(view[TVIEW], view, component);
|
|
14602
|
+
}
|
|
14603
|
+
/**
|
|
14604
|
+
* Marks the component as dirty (needing change detection). Marking a component dirty will
|
|
14605
|
+
* schedule a change detection on it at some point in the future.
|
|
14606
|
+
*
|
|
14607
|
+
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
14608
|
+
* detection can be scheduled per component tree.
|
|
14609
|
+
*
|
|
14610
|
+
* @param component Component to mark as dirty.
|
|
14611
|
+
*/
|
|
14612
|
+
function markDirty(component) {
|
|
14613
|
+
ngDevMode && assertDefined(component, 'component');
|
|
14614
|
+
const rootView = markViewDirty(getComponentViewByInstance(component));
|
|
14615
|
+
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
|
|
14616
|
+
scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
|
|
14617
|
+
}
|
|
14618
|
+
/**
|
|
14619
|
+
* Used to perform change detection on the whole application.
|
|
14620
|
+
*
|
|
14621
|
+
* This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
|
|
14622
|
+
* executes lifecycle hooks and conditionally checks components based on their
|
|
14623
|
+
* `ChangeDetectionStrategy` and dirtiness.
|
|
14624
|
+
*
|
|
14625
|
+
* The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
|
|
14626
|
+
* schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
|
|
14627
|
+
* single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
|
|
14628
|
+
* be changed when calling `renderComponent` and providing the `scheduler` option.
|
|
14629
|
+
*/
|
|
14630
|
+
function tick(component) {
|
|
14631
|
+
const rootView = getRootView(component);
|
|
14632
|
+
const rootContext = rootView[CONTEXT];
|
|
14633
|
+
tickRootContext(rootContext);
|
|
14634
|
+
}
|
|
14635
|
+
|
|
14636
|
+
/**
|
|
14637
|
+
* @license
|
|
14638
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14639
|
+
*
|
|
14640
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14641
|
+
* found in the LICENSE file at https://angular.io/license
|
|
14642
|
+
*/
|
|
14643
|
+
function templateFirstCreatePass(index, tView, lView, templateFn, decls, vars, tagName, attrsIndex, localRefsIndex) {
|
|
14644
|
+
ngDevMode && assertFirstCreatePass(tView);
|
|
14645
|
+
ngDevMode && ngDevMode.firstCreatePass++;
|
|
14646
|
+
const tViewConsts = tView.consts;
|
|
14647
|
+
// TODO(pk): refactor getOrCreateTNode to have the "create" only version
|
|
14648
|
+
const tNode = getOrCreateTNode(tView, index, 4 /* TNodeType.Container */, tagName || null, getConstant(tViewConsts, attrsIndex));
|
|
14649
|
+
resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
|
|
14650
|
+
registerPostOrderHooks(tView, tNode);
|
|
14651
|
+
const embeddedTView = tNode.tViews = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
|
|
14652
|
+
if (tView.queries !== null) {
|
|
14653
|
+
tView.queries.template(tView, tNode);
|
|
14654
|
+
embeddedTView.queries = tView.queries.embeddedTView(tNode);
|
|
14655
|
+
}
|
|
14656
|
+
return tNode;
|
|
14657
|
+
}
|
|
14658
|
+
/**
|
|
14659
|
+
* Creates an LContainer for an ng-template (dynamically-inserted view), e.g.
|
|
14660
|
+
*
|
|
14661
|
+
* <ng-template #foo>
|
|
14662
|
+
* <div></div>
|
|
15349
14663
|
* </ng-template>
|
|
15350
14664
|
*
|
|
15351
14665
|
* @param index The index of the container in the data array
|
|
@@ -15863,51 +15177,42 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
|
|
|
15863
15177
|
tNode.index;
|
|
15864
15178
|
// In order to match current behavior, native DOM event listeners must be added for all
|
|
15865
15179
|
// events (including outputs).
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
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
|
-
}
|
|
15180
|
+
// There might be cases where multiple directives on the same element try to register an event
|
|
15181
|
+
// handler function for the same event. In this situation we want to avoid registration of
|
|
15182
|
+
// several native listeners as each registration would be intercepted by NgZone and
|
|
15183
|
+
// trigger change detection. This would mean that a single user action would result in several
|
|
15184
|
+
// change detections being invoked. To avoid this situation we want to have only one call to
|
|
15185
|
+
// native handler registration (for the same element and same type of event).
|
|
15186
|
+
//
|
|
15187
|
+
// In order to have just one native event handler in presence of multiple handler functions,
|
|
15188
|
+
// we just register a first handler function as a native event listener and then chain
|
|
15189
|
+
// (coalesce) other handler functions on top of the first native handler function.
|
|
15190
|
+
let existingListener = null;
|
|
15191
|
+
// Please note that the coalescing described here doesn't happen for events specifying an
|
|
15192
|
+
// alternative target (ex. (document:click)) - this is to keep backward compatibility with the
|
|
15193
|
+
// view engine.
|
|
15194
|
+
// Also, we don't have to search for existing listeners is there are no directives
|
|
15195
|
+
// matching on a given node as we can't register multiple event handlers for the same event in
|
|
15196
|
+
// a template (this would mean having duplicate attributes).
|
|
15197
|
+
if (!eventTargetResolver && isTNodeDirectiveHost) {
|
|
15198
|
+
existingListener = findExistingListener(tView, lView, eventName, tNode.index);
|
|
15199
|
+
}
|
|
15200
|
+
if (existingListener !== null) {
|
|
15201
|
+
// Attach a new listener to coalesced listeners list, maintaining the order in which
|
|
15202
|
+
// listeners are registered. For performance reasons, we keep a reference to the last
|
|
15203
|
+
// listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
|
|
15204
|
+
// the entire set each time we need to add a new listener.
|
|
15205
|
+
const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
|
|
15206
|
+
lastListenerFn.__ngNextListenerFn__ = listenerFn;
|
|
15207
|
+
existingListener.__ngLastListenerFn__ = listenerFn;
|
|
15208
|
+
processOutputs = false;
|
|
15904
15209
|
}
|
|
15905
15210
|
else {
|
|
15906
|
-
listenerFn = wrapListener(tNode, lView, context, listenerFn,
|
|
15907
|
-
|
|
15211
|
+
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
|
|
15212
|
+
const cleanupFn = renderer.listen(target, eventName, listenerFn);
|
|
15908
15213
|
ngDevMode && ngDevMode.rendererAddEventListener++;
|
|
15909
|
-
lCleanup.push(listenerFn);
|
|
15910
|
-
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex,
|
|
15214
|
+
lCleanup.push(listenerFn, cleanupFn);
|
|
15215
|
+
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
|
|
15911
15216
|
}
|
|
15912
15217
|
}
|
|
15913
15218
|
else {
|
|
@@ -17981,7 +17286,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
|
|
|
17981
17286
|
valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
|
|
17982
17287
|
}
|
|
17983
17288
|
let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
|
|
17984
|
-
key === prop ? valueAtLViewIndex : undefined;
|
|
17289
|
+
(key === prop ? valueAtLViewIndex : undefined);
|
|
17985
17290
|
if (containsStatics && !isStylingValuePresent(currentValue)) {
|
|
17986
17291
|
currentValue = keyValueArrayGet(rawKey, prop);
|
|
17987
17292
|
}
|
|
@@ -21834,7 +21139,7 @@ function noComponentFactoryError(component) {
|
|
|
21834
21139
|
return error;
|
|
21835
21140
|
}
|
|
21836
21141
|
const ERROR_COMPONENT = 'ngComponent';
|
|
21837
|
-
function getComponent(error) {
|
|
21142
|
+
function getComponent$1(error) {
|
|
21838
21143
|
return error[ERROR_COMPONENT];
|
|
21839
21144
|
}
|
|
21840
21145
|
class _NullComponentFactoryResolver {
|
|
@@ -22018,14 +21323,6 @@ class Renderer2 {
|
|
|
22018
21323
|
* @nocollapse
|
|
22019
21324
|
*/
|
|
22020
21325
|
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
21326
|
/** Injects a Renderer2 for the current component. */
|
|
22030
21327
|
function injectRenderer2() {
|
|
22031
21328
|
// We need the Renderer to be based on the component that it's being injected into, however since
|
|
@@ -22033,7 +21330,7 @@ function injectRenderer2() {
|
|
|
22033
21330
|
const lView = getLView();
|
|
22034
21331
|
const tNode = getCurrentTNode();
|
|
22035
21332
|
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
|
|
22036
|
-
return
|
|
21333
|
+
return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
|
|
22037
21334
|
}
|
|
22038
21335
|
|
|
22039
21336
|
/**
|
|
@@ -22080,7 +21377,7 @@ class Version {
|
|
|
22080
21377
|
/**
|
|
22081
21378
|
* @publicApi
|
|
22082
21379
|
*/
|
|
22083
|
-
const VERSION = new Version('14.0.
|
|
21380
|
+
const VERSION = new Version('14.0.5');
|
|
22084
21381
|
|
|
22085
21382
|
/**
|
|
22086
21383
|
* @license
|
|
@@ -22426,31 +21723,407 @@ class ViewRef {
|
|
|
22426
21723
|
this._appRef = null;
|
|
22427
21724
|
renderDetachView(this._lView[TVIEW], this._lView);
|
|
22428
21725
|
}
|
|
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;
|
|
21726
|
+
attachToAppRef(appRef) {
|
|
21727
|
+
if (this._attachedToViewContainer) {
|
|
21728
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
|
|
21729
|
+
}
|
|
21730
|
+
this._appRef = appRef;
|
|
21731
|
+
}
|
|
21732
|
+
}
|
|
21733
|
+
/** @internal */
|
|
21734
|
+
class RootViewRef extends ViewRef {
|
|
21735
|
+
constructor(_view) {
|
|
21736
|
+
super(_view);
|
|
21737
|
+
this._view = _view;
|
|
21738
|
+
}
|
|
21739
|
+
detectChanges() {
|
|
21740
|
+
detectChangesInRootView(this._view);
|
|
21741
|
+
}
|
|
21742
|
+
checkNoChanges() {
|
|
21743
|
+
if (ngDevMode) {
|
|
21744
|
+
checkNoChangesInRootView(this._view);
|
|
21745
|
+
}
|
|
21746
|
+
}
|
|
21747
|
+
get context() {
|
|
21748
|
+
return null;
|
|
21749
|
+
}
|
|
21750
|
+
}
|
|
21751
|
+
|
|
21752
|
+
/**
|
|
21753
|
+
* @license
|
|
21754
|
+
* Copyright Google LLC All Rights Reserved.
|
|
21755
|
+
*
|
|
21756
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
21757
|
+
* found in the LICENSE file at https://angular.io/license
|
|
21758
|
+
*/
|
|
21759
|
+
class ComponentFactoryResolver extends ComponentFactoryResolver$1 {
|
|
21760
|
+
/**
|
|
21761
|
+
* @param ngModule The NgModuleRef to which all resolved factories are bound.
|
|
21762
|
+
*/
|
|
21763
|
+
constructor(ngModule) {
|
|
21764
|
+
super();
|
|
21765
|
+
this.ngModule = ngModule;
|
|
21766
|
+
}
|
|
21767
|
+
resolveComponentFactory(component) {
|
|
21768
|
+
ngDevMode && assertComponentType(component);
|
|
21769
|
+
const componentDef = getComponentDef$1(component);
|
|
21770
|
+
return new ComponentFactory(componentDef, this.ngModule);
|
|
21771
|
+
}
|
|
21772
|
+
}
|
|
21773
|
+
function toRefArray(map) {
|
|
21774
|
+
const array = [];
|
|
21775
|
+
for (let nonMinified in map) {
|
|
21776
|
+
if (map.hasOwnProperty(nonMinified)) {
|
|
21777
|
+
const minified = map[nonMinified];
|
|
21778
|
+
array.push({ propName: minified, templateName: nonMinified });
|
|
21779
|
+
}
|
|
21780
|
+
}
|
|
21781
|
+
return array;
|
|
21782
|
+
}
|
|
21783
|
+
function getNamespace(elementName) {
|
|
21784
|
+
const name = elementName.toLowerCase();
|
|
21785
|
+
return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
|
|
21786
|
+
}
|
|
21787
|
+
/**
|
|
21788
|
+
* Injector that looks up a value using a specific injector, before falling back to the module
|
|
21789
|
+
* injector. Used primarily when creating components or embedded views dynamically.
|
|
21790
|
+
*/
|
|
21791
|
+
class ChainedInjector {
|
|
21792
|
+
constructor(injector, parentInjector) {
|
|
21793
|
+
this.injector = injector;
|
|
21794
|
+
this.parentInjector = parentInjector;
|
|
21795
|
+
}
|
|
21796
|
+
get(token, notFoundValue, flags) {
|
|
21797
|
+
const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
|
|
21798
|
+
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
|
|
21799
|
+
notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
|
21800
|
+
// Return the value from the root element injector when
|
|
21801
|
+
// - it provides it
|
|
21802
|
+
// (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
|
21803
|
+
// - the module injector should not be checked
|
|
21804
|
+
// (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
|
21805
|
+
return value;
|
|
21806
|
+
}
|
|
21807
|
+
return this.parentInjector.get(token, notFoundValue, flags);
|
|
21808
|
+
}
|
|
21809
|
+
}
|
|
21810
|
+
/**
|
|
21811
|
+
* Render3 implementation of {@link viewEngine_ComponentFactory}.
|
|
21812
|
+
*/
|
|
21813
|
+
class ComponentFactory extends ComponentFactory$1 {
|
|
21814
|
+
/**
|
|
21815
|
+
* @param componentDef The component definition.
|
|
21816
|
+
* @param ngModule The NgModuleRef to which the factory is bound.
|
|
21817
|
+
*/
|
|
21818
|
+
constructor(componentDef, ngModule) {
|
|
21819
|
+
super();
|
|
21820
|
+
this.componentDef = componentDef;
|
|
21821
|
+
this.ngModule = ngModule;
|
|
21822
|
+
this.componentType = componentDef.type;
|
|
21823
|
+
this.selector = stringifyCSSSelectorList(componentDef.selectors);
|
|
21824
|
+
this.ngContentSelectors =
|
|
21825
|
+
componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
|
|
21826
|
+
this.isBoundToModule = !!ngModule;
|
|
21827
|
+
}
|
|
21828
|
+
get inputs() {
|
|
21829
|
+
return toRefArray(this.componentDef.inputs);
|
|
21830
|
+
}
|
|
21831
|
+
get outputs() {
|
|
21832
|
+
return toRefArray(this.componentDef.outputs);
|
|
21833
|
+
}
|
|
21834
|
+
create(injector, projectableNodes, rootSelectorOrNode, environmentInjector) {
|
|
21835
|
+
environmentInjector = environmentInjector || this.ngModule;
|
|
21836
|
+
let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ?
|
|
21837
|
+
environmentInjector :
|
|
21838
|
+
environmentInjector === null || environmentInjector === void 0 ? void 0 : environmentInjector.injector;
|
|
21839
|
+
if (realEnvironmentInjector && this.componentDef.getStandaloneInjector !== null) {
|
|
21840
|
+
realEnvironmentInjector = this.componentDef.getStandaloneInjector(realEnvironmentInjector) ||
|
|
21841
|
+
realEnvironmentInjector;
|
|
21842
|
+
}
|
|
21843
|
+
const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
|
|
21844
|
+
const rendererFactory = rootViewInjector.get(RendererFactory2, null);
|
|
21845
|
+
if (rendererFactory === null) {
|
|
21846
|
+
throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
|
|
21847
|
+
'Angular was not able to inject a renderer (RendererFactory2). ' +
|
|
21848
|
+
'Likely this is due to a broken DI hierarchy. ' +
|
|
21849
|
+
'Make sure that any injector used to create this component has a correct parent.');
|
|
21850
|
+
}
|
|
21851
|
+
const sanitizer = rootViewInjector.get(Sanitizer, null);
|
|
21852
|
+
const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
|
|
21853
|
+
// Determine a tag name used for creating host elements when this component is created
|
|
21854
|
+
// dynamically. Default to 'div' if this component did not specify any tag name in its selector.
|
|
21855
|
+
const elementName = this.componentDef.selectors[0][0] || 'div';
|
|
21856
|
+
const hostRNode = rootSelectorOrNode ?
|
|
21857
|
+
locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) :
|
|
21858
|
+
createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
|
|
21859
|
+
const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
|
|
21860
|
+
16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
|
|
21861
|
+
const rootContext = createRootContext();
|
|
21862
|
+
// Create the root view. Uses empty TView and ContentTemplate.
|
|
21863
|
+
const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
|
|
21864
|
+
const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
|
|
21865
|
+
// rootView is the parent when bootstrapping
|
|
21866
|
+
// TODO(misko): it looks like we are entering view here but we don't really need to as
|
|
21867
|
+
// `renderView` does that. However as the code is written it is needed because
|
|
21868
|
+
// `createRootComponentView` and `createRootComponent` both read global state. Fixing those
|
|
21869
|
+
// issues would allow us to drop this.
|
|
21870
|
+
enterView(rootLView);
|
|
21871
|
+
let component;
|
|
21872
|
+
let tElementNode;
|
|
21873
|
+
try {
|
|
21874
|
+
const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
|
|
21875
|
+
if (hostRNode) {
|
|
21876
|
+
if (rootSelectorOrNode) {
|
|
21877
|
+
setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
|
|
21878
|
+
}
|
|
21879
|
+
else {
|
|
21880
|
+
// If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
|
|
21881
|
+
// is not defined), also apply attributes and classes extracted from component selector.
|
|
21882
|
+
// Extract attributes and classes from the first selector only to match VE behavior.
|
|
21883
|
+
const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
|
|
21884
|
+
if (attrs) {
|
|
21885
|
+
setUpAttributes(hostRenderer, hostRNode, attrs);
|
|
21886
|
+
}
|
|
21887
|
+
if (classes && classes.length > 0) {
|
|
21888
|
+
writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
|
|
21889
|
+
}
|
|
21890
|
+
}
|
|
21891
|
+
}
|
|
21892
|
+
tElementNode = getTNode(rootTView, HEADER_OFFSET);
|
|
21893
|
+
if (projectableNodes !== undefined) {
|
|
21894
|
+
const projection = tElementNode.projection = [];
|
|
21895
|
+
for (let i = 0; i < this.ngContentSelectors.length; i++) {
|
|
21896
|
+
const nodesforSlot = projectableNodes[i];
|
|
21897
|
+
// Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
|
|
21898
|
+
// case). Here we do normalize passed data structure to be an array of arrays to avoid
|
|
21899
|
+
// complex checks down the line.
|
|
21900
|
+
// We also normalize the length of the passed in projectable nodes (to match the number of
|
|
21901
|
+
// <ng-container> slots defined by a component).
|
|
21902
|
+
projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
|
|
21903
|
+
}
|
|
21904
|
+
}
|
|
21905
|
+
// TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
|
|
21906
|
+
// executed here?
|
|
21907
|
+
// Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
|
|
21908
|
+
component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
|
|
21909
|
+
renderView(rootTView, rootLView, null);
|
|
21910
|
+
}
|
|
21911
|
+
finally {
|
|
21912
|
+
leaveView();
|
|
21913
|
+
}
|
|
21914
|
+
return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
|
|
21915
|
+
}
|
|
21916
|
+
}
|
|
21917
|
+
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
21918
|
+
/**
|
|
21919
|
+
* Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
|
|
21920
|
+
* ComponentFactoryResolver
|
|
21921
|
+
* already exists, retrieves the existing ComponentFactoryResolver.
|
|
21922
|
+
*
|
|
21923
|
+
* @returns The ComponentFactoryResolver instance to use
|
|
21924
|
+
*/
|
|
21925
|
+
function injectComponentFactoryResolver() {
|
|
21926
|
+
return componentFactoryResolver;
|
|
21927
|
+
}
|
|
21928
|
+
/**
|
|
21929
|
+
* Represents an instance of a Component created via a {@link ComponentFactory}.
|
|
21930
|
+
*
|
|
21931
|
+
* `ComponentRef` provides access to the Component Instance as well other objects related to this
|
|
21932
|
+
* Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
|
|
21933
|
+
* method.
|
|
21934
|
+
*
|
|
21935
|
+
*/
|
|
21936
|
+
class ComponentRef extends ComponentRef$1 {
|
|
21937
|
+
constructor(componentType, instance, location, _rootLView, _tNode) {
|
|
21938
|
+
super();
|
|
21939
|
+
this.location = location;
|
|
21940
|
+
this._rootLView = _rootLView;
|
|
21941
|
+
this._tNode = _tNode;
|
|
21942
|
+
this.instance = instance;
|
|
21943
|
+
this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
|
|
21944
|
+
this.componentType = componentType;
|
|
21945
|
+
}
|
|
21946
|
+
get injector() {
|
|
21947
|
+
return new NodeInjector(this._tNode, this._rootLView);
|
|
21948
|
+
}
|
|
21949
|
+
destroy() {
|
|
21950
|
+
this.hostView.destroy();
|
|
21951
|
+
}
|
|
21952
|
+
onDestroy(callback) {
|
|
21953
|
+
this.hostView.onDestroy(callback);
|
|
21954
|
+
}
|
|
21955
|
+
}
|
|
21956
|
+
|
|
21957
|
+
/**
|
|
21958
|
+
* @license
|
|
21959
|
+
* Copyright Google LLC All Rights Reserved.
|
|
21960
|
+
*
|
|
21961
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
21962
|
+
* found in the LICENSE file at https://angular.io/license
|
|
21963
|
+
*/
|
|
21964
|
+
/**
|
|
21965
|
+
* Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
|
|
21966
|
+
* @param ngModule NgModule class.
|
|
21967
|
+
* @param parentInjector Optional injector instance to use as a parent for the module injector. If
|
|
21968
|
+
* not provided, `NullInjector` will be used instead.
|
|
21969
|
+
* @publicApi
|
|
21970
|
+
*/
|
|
21971
|
+
function createNgModuleRef(ngModule, parentInjector) {
|
|
21972
|
+
return new NgModuleRef(ngModule, parentInjector !== null && parentInjector !== void 0 ? parentInjector : null);
|
|
21973
|
+
}
|
|
21974
|
+
class NgModuleRef extends NgModuleRef$1 {
|
|
21975
|
+
constructor(ngModuleType, _parent) {
|
|
21976
|
+
super();
|
|
21977
|
+
this._parent = _parent;
|
|
21978
|
+
// tslint:disable-next-line:require-internal-with-underscore
|
|
21979
|
+
this._bootstrapComponents = [];
|
|
21980
|
+
this.injector = this;
|
|
21981
|
+
this.destroyCbs = [];
|
|
21982
|
+
// When bootstrapping a module we have a dependency graph that looks like this:
|
|
21983
|
+
// ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
|
|
21984
|
+
// module being resolved tries to inject the ComponentFactoryResolver, it'll create a
|
|
21985
|
+
// circular dependency which will result in a runtime error, because the injector doesn't
|
|
21986
|
+
// exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
|
|
21987
|
+
// and providing it, rather than letting the injector resolve it.
|
|
21988
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
21989
|
+
const ngModuleDef = getNgModuleDef(ngModuleType);
|
|
21990
|
+
ngDevMode &&
|
|
21991
|
+
assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
|
|
21992
|
+
this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
|
|
21993
|
+
this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
|
|
21994
|
+
{ provide: NgModuleRef$1, useValue: this }, {
|
|
21995
|
+
provide: ComponentFactoryResolver$1,
|
|
21996
|
+
useValue: this.componentFactoryResolver
|
|
21997
|
+
}
|
|
21998
|
+
], stringify(ngModuleType), new Set(['environment']));
|
|
21999
|
+
// We need to resolve the injector types separately from the injector creation, because
|
|
22000
|
+
// the module might be trying to use this ref in its constructor for DI which will cause a
|
|
22001
|
+
// circular error that will eventually error out, because the injector isn't created yet.
|
|
22002
|
+
this._r3Injector.resolveInjectorInitializers();
|
|
22003
|
+
this.instance = this.get(ngModuleType);
|
|
22004
|
+
}
|
|
22005
|
+
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
|
|
22006
|
+
if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
|
|
22007
|
+
return this;
|
|
22008
|
+
}
|
|
22009
|
+
return this._r3Injector.get(token, notFoundValue, injectFlags);
|
|
22010
|
+
}
|
|
22011
|
+
destroy() {
|
|
22012
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22013
|
+
const injector = this._r3Injector;
|
|
22014
|
+
!injector.destroyed && injector.destroy();
|
|
22015
|
+
this.destroyCbs.forEach(fn => fn());
|
|
22016
|
+
this.destroyCbs = null;
|
|
22017
|
+
}
|
|
22018
|
+
onDestroy(callback) {
|
|
22019
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22020
|
+
this.destroyCbs.push(callback);
|
|
22021
|
+
}
|
|
22022
|
+
}
|
|
22023
|
+
class NgModuleFactory extends NgModuleFactory$1 {
|
|
22024
|
+
constructor(moduleType) {
|
|
22025
|
+
super();
|
|
22026
|
+
this.moduleType = moduleType;
|
|
22027
|
+
}
|
|
22028
|
+
create(parentInjector) {
|
|
22029
|
+
return new NgModuleRef(this.moduleType, parentInjector);
|
|
22434
22030
|
}
|
|
22435
22031
|
}
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
this.
|
|
22032
|
+
class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
|
|
22033
|
+
constructor(providers, parent, source) {
|
|
22034
|
+
super();
|
|
22035
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
22036
|
+
this.instance = null;
|
|
22037
|
+
const injector = new R3Injector([
|
|
22038
|
+
...providers,
|
|
22039
|
+
{ provide: NgModuleRef$1, useValue: this },
|
|
22040
|
+
{ provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
|
|
22041
|
+
], parent || getNullInjector(), source, new Set(['environment']));
|
|
22042
|
+
this.injector = injector;
|
|
22043
|
+
injector.resolveInjectorInitializers();
|
|
22441
22044
|
}
|
|
22442
|
-
|
|
22443
|
-
|
|
22045
|
+
destroy() {
|
|
22046
|
+
this.injector.destroy();
|
|
22444
22047
|
}
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22048
|
+
onDestroy(callback) {
|
|
22049
|
+
this.injector.onDestroy(callback);
|
|
22050
|
+
}
|
|
22051
|
+
}
|
|
22052
|
+
/**
|
|
22053
|
+
* Create a new environment injector.
|
|
22054
|
+
*
|
|
22055
|
+
* @publicApi
|
|
22056
|
+
* @developerPreview
|
|
22057
|
+
*/
|
|
22058
|
+
function createEnvironmentInjector(providers, parent = null, debugName = null) {
|
|
22059
|
+
const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
|
|
22060
|
+
return adapter.injector;
|
|
22061
|
+
}
|
|
22062
|
+
|
|
22063
|
+
/**
|
|
22064
|
+
* @license
|
|
22065
|
+
* Copyright Google LLC All Rights Reserved.
|
|
22066
|
+
*
|
|
22067
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
22068
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22069
|
+
*/
|
|
22070
|
+
/**
|
|
22071
|
+
* A service used by the framework to create instances of standalone injectors. Those injectors are
|
|
22072
|
+
* created on demand in case of dynamic component instantiation and contain ambient providers
|
|
22073
|
+
* collected from the imports graph rooted at a given standalone component.
|
|
22074
|
+
*/
|
|
22075
|
+
class StandaloneService {
|
|
22076
|
+
constructor(_injector) {
|
|
22077
|
+
this._injector = _injector;
|
|
22078
|
+
this.cachedInjectors = new Map();
|
|
22079
|
+
}
|
|
22080
|
+
getOrCreateStandaloneInjector(componentDef) {
|
|
22081
|
+
if (!componentDef.standalone) {
|
|
22082
|
+
return null;
|
|
22083
|
+
}
|
|
22084
|
+
if (!this.cachedInjectors.has(componentDef.id)) {
|
|
22085
|
+
const providers = internalImportProvidersFrom(false, componentDef.type);
|
|
22086
|
+
const standaloneInjector = providers.length > 0 ?
|
|
22087
|
+
createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
|
|
22088
|
+
null;
|
|
22089
|
+
this.cachedInjectors.set(componentDef.id, standaloneInjector);
|
|
22448
22090
|
}
|
|
22091
|
+
return this.cachedInjectors.get(componentDef.id);
|
|
22449
22092
|
}
|
|
22450
|
-
|
|
22451
|
-
|
|
22093
|
+
ngOnDestroy() {
|
|
22094
|
+
try {
|
|
22095
|
+
for (const injector of this.cachedInjectors.values()) {
|
|
22096
|
+
if (injector !== null) {
|
|
22097
|
+
injector.destroy();
|
|
22098
|
+
}
|
|
22099
|
+
}
|
|
22100
|
+
}
|
|
22101
|
+
finally {
|
|
22102
|
+
this.cachedInjectors.clear();
|
|
22103
|
+
}
|
|
22452
22104
|
}
|
|
22453
22105
|
}
|
|
22106
|
+
/** @nocollapse */
|
|
22107
|
+
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22108
|
+
token: StandaloneService,
|
|
22109
|
+
providedIn: 'environment',
|
|
22110
|
+
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22111
|
+
});
|
|
22112
|
+
/**
|
|
22113
|
+
* A feature that acts as a setup code for the {@link StandaloneService}.
|
|
22114
|
+
*
|
|
22115
|
+
* The most important responsaibility of this feature is to expose the "getStandaloneInjector"
|
|
22116
|
+
* function (an entry points to a standalone injector creation) on a component definition object. We
|
|
22117
|
+
* go through the features infrastructure to make sure that the standalone injector creation logic
|
|
22118
|
+
* is tree-shakable and not included in applications that don't use standalone components.
|
|
22119
|
+
*
|
|
22120
|
+
* @codeGenApi
|
|
22121
|
+
*/
|
|
22122
|
+
function ɵɵStandaloneFeature(definition) {
|
|
22123
|
+
definition.getStandaloneInjector = (parentInjector) => {
|
|
22124
|
+
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
|
|
22125
|
+
};
|
|
22126
|
+
}
|
|
22454
22127
|
|
|
22455
22128
|
/**
|
|
22456
22129
|
* @license
|
|
@@ -22459,367 +22132,407 @@ class RootViewRef extends ViewRef {
|
|
|
22459
22132
|
* Use of this source code is governed by an MIT-style license that can be
|
|
22460
22133
|
* found in the LICENSE file at https://angular.io/license
|
|
22461
22134
|
*/
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
22466
|
-
|
|
22467
|
-
|
|
22468
|
-
|
|
22135
|
+
/**
|
|
22136
|
+
* Retrieves the component instance associated with a given DOM element.
|
|
22137
|
+
*
|
|
22138
|
+
* @usageNotes
|
|
22139
|
+
* Given the following DOM structure:
|
|
22140
|
+
*
|
|
22141
|
+
* ```html
|
|
22142
|
+
* <app-root>
|
|
22143
|
+
* <div>
|
|
22144
|
+
* <child-comp></child-comp>
|
|
22145
|
+
* </div>
|
|
22146
|
+
* </app-root>
|
|
22147
|
+
* ```
|
|
22148
|
+
*
|
|
22149
|
+
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
|
|
22150
|
+
* associated with this DOM element.
|
|
22151
|
+
*
|
|
22152
|
+
* Calling the function on `<app-root>` will return the `MyApp` instance.
|
|
22153
|
+
*
|
|
22154
|
+
*
|
|
22155
|
+
* @param element DOM element from which the component should be retrieved.
|
|
22156
|
+
* @returns Component instance associated with the element or `null` if there
|
|
22157
|
+
* is no component associated with it.
|
|
22158
|
+
*
|
|
22159
|
+
* @publicApi
|
|
22160
|
+
* @globalApi ng
|
|
22161
|
+
*/
|
|
22162
|
+
function getComponent(element) {
|
|
22163
|
+
ngDevMode && assertDomElement(element);
|
|
22164
|
+
const context = getLContext(element);
|
|
22165
|
+
if (context === null)
|
|
22166
|
+
return null;
|
|
22167
|
+
if (context.component === undefined) {
|
|
22168
|
+
const lView = context.lView;
|
|
22169
|
+
if (lView === null) {
|
|
22170
|
+
return null;
|
|
22171
|
+
}
|
|
22172
|
+
context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
|
|
22469
22173
|
}
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22174
|
+
return context.component;
|
|
22175
|
+
}
|
|
22176
|
+
/**
|
|
22177
|
+
* If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
|
|
22178
|
+
* view that the element is part of. Otherwise retrieves the instance of the component whose view
|
|
22179
|
+
* owns the element (in this case, the result is the same as calling `getOwningComponent`).
|
|
22180
|
+
*
|
|
22181
|
+
* @param element Element for which to get the surrounding component instance.
|
|
22182
|
+
* @returns Instance of the component that is around the element or null if the element isn't
|
|
22183
|
+
* inside any component.
|
|
22184
|
+
*
|
|
22185
|
+
* @publicApi
|
|
22186
|
+
* @globalApi ng
|
|
22187
|
+
*/
|
|
22188
|
+
function getContext(element) {
|
|
22189
|
+
assertDomElement(element);
|
|
22190
|
+
const context = getLContext(element);
|
|
22191
|
+
const lView = context ? context.lView : null;
|
|
22192
|
+
return lView === null ? null : lView[CONTEXT];
|
|
22193
|
+
}
|
|
22194
|
+
/**
|
|
22195
|
+
* Retrieves the component instance whose view contains the DOM element.
|
|
22196
|
+
*
|
|
22197
|
+
* For example, if `<child-comp>` is used in the template of `<app-comp>`
|
|
22198
|
+
* (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
|
|
22199
|
+
* would return `<app-comp>`.
|
|
22200
|
+
*
|
|
22201
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22202
|
+
* for which to retrieve the root components.
|
|
22203
|
+
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
22204
|
+
* part of a component view.
|
|
22205
|
+
*
|
|
22206
|
+
* @publicApi
|
|
22207
|
+
* @globalApi ng
|
|
22208
|
+
*/
|
|
22209
|
+
function getOwningComponent(elementOrDir) {
|
|
22210
|
+
const context = getLContext(elementOrDir);
|
|
22211
|
+
let lView = context ? context.lView : null;
|
|
22212
|
+
if (lView === null)
|
|
22213
|
+
return null;
|
|
22214
|
+
let parent;
|
|
22215
|
+
while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
|
|
22216
|
+
lView = parent;
|
|
22474
22217
|
}
|
|
22218
|
+
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
22475
22219
|
}
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22220
|
+
/**
|
|
22221
|
+
* Retrieves all root components associated with a DOM element, directive or component instance.
|
|
22222
|
+
* Root components are those which have been bootstrapped by Angular.
|
|
22223
|
+
*
|
|
22224
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22225
|
+
* for which to retrieve the root components.
|
|
22226
|
+
* @returns Root components associated with the target object.
|
|
22227
|
+
*
|
|
22228
|
+
* @publicApi
|
|
22229
|
+
* @globalApi ng
|
|
22230
|
+
*/
|
|
22231
|
+
function getRootComponents(elementOrDir) {
|
|
22232
|
+
const lView = readPatchedLView(elementOrDir);
|
|
22233
|
+
return lView !== null ? [...getRootContext(lView).components] : [];
|
|
22234
|
+
}
|
|
22235
|
+
/**
|
|
22236
|
+
* Retrieves an `Injector` associated with an element, component or directive instance.
|
|
22237
|
+
*
|
|
22238
|
+
* @param elementOrDir DOM element, component or directive instance for which to
|
|
22239
|
+
* retrieve the injector.
|
|
22240
|
+
* @returns Injector associated with the element, component or directive instance.
|
|
22241
|
+
*
|
|
22242
|
+
* @publicApi
|
|
22243
|
+
* @globalApi ng
|
|
22244
|
+
*/
|
|
22245
|
+
function getInjector(elementOrDir) {
|
|
22246
|
+
const context = getLContext(elementOrDir);
|
|
22247
|
+
const lView = context ? context.lView : null;
|
|
22248
|
+
if (lView === null)
|
|
22249
|
+
return Injector.NULL;
|
|
22250
|
+
const tNode = lView[TVIEW].data[context.nodeIndex];
|
|
22251
|
+
return new NodeInjector(tNode, lView);
|
|
22252
|
+
}
|
|
22253
|
+
/**
|
|
22254
|
+
* Retrieve a set of injection tokens at a given DOM node.
|
|
22255
|
+
*
|
|
22256
|
+
* @param element Element for which the injection tokens should be retrieved.
|
|
22257
|
+
*/
|
|
22258
|
+
function getInjectionTokens(element) {
|
|
22259
|
+
const context = getLContext(element);
|
|
22260
|
+
const lView = context ? context.lView : null;
|
|
22261
|
+
if (lView === null)
|
|
22262
|
+
return [];
|
|
22263
|
+
const tView = lView[TVIEW];
|
|
22264
|
+
const tNode = tView.data[context.nodeIndex];
|
|
22265
|
+
const providerTokens = [];
|
|
22266
|
+
const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
|
|
22267
|
+
const endIndex = tNode.directiveEnd;
|
|
22268
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
22269
|
+
let value = tView.data[i];
|
|
22270
|
+
if (isDirectiveDefHack(value)) {
|
|
22271
|
+
// The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
|
|
22272
|
+
// design flaw. We should always store same type so that we can be monomorphic. The issue
|
|
22273
|
+
// is that for Components/Directives we store the def instead the type. The correct behavior
|
|
22274
|
+
// is that we should always be storing injectable type in this location.
|
|
22275
|
+
value = value.type;
|
|
22482
22276
|
}
|
|
22277
|
+
providerTokens.push(value);
|
|
22483
22278
|
}
|
|
22484
|
-
return
|
|
22485
|
-
}
|
|
22486
|
-
function getNamespace(elementName) {
|
|
22487
|
-
const name = elementName.toLowerCase();
|
|
22488
|
-
return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
|
|
22279
|
+
return providerTokens;
|
|
22489
22280
|
}
|
|
22490
22281
|
/**
|
|
22491
|
-
*
|
|
22492
|
-
*
|
|
22282
|
+
* Retrieves directive instances associated with a given DOM node. Does not include
|
|
22283
|
+
* component instances.
|
|
22284
|
+
*
|
|
22285
|
+
* @usageNotes
|
|
22286
|
+
* Given the following DOM structure:
|
|
22287
|
+
*
|
|
22288
|
+
* ```html
|
|
22289
|
+
* <app-root>
|
|
22290
|
+
* <button my-button></button>
|
|
22291
|
+
* <my-comp></my-comp>
|
|
22292
|
+
* </app-root>
|
|
22293
|
+
* ```
|
|
22294
|
+
*
|
|
22295
|
+
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
|
|
22296
|
+
* directive that is associated with the DOM node.
|
|
22297
|
+
*
|
|
22298
|
+
* Calling `getDirectives` on `<my-comp>` will return an empty array.
|
|
22299
|
+
*
|
|
22300
|
+
* @param node DOM node for which to get the directives.
|
|
22301
|
+
* @returns Array of directives associated with the node.
|
|
22302
|
+
*
|
|
22303
|
+
* @publicApi
|
|
22304
|
+
* @globalApi ng
|
|
22493
22305
|
*/
|
|
22494
|
-
|
|
22495
|
-
|
|
22496
|
-
|
|
22497
|
-
|
|
22306
|
+
function getDirectives(node) {
|
|
22307
|
+
// Skip text nodes because we can't have directives associated with them.
|
|
22308
|
+
if (node instanceof Text) {
|
|
22309
|
+
return [];
|
|
22498
22310
|
}
|
|
22499
|
-
|
|
22500
|
-
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22311
|
+
const context = getLContext(node);
|
|
22312
|
+
const lView = context ? context.lView : null;
|
|
22313
|
+
if (lView === null) {
|
|
22314
|
+
return [];
|
|
22315
|
+
}
|
|
22316
|
+
const tView = lView[TVIEW];
|
|
22317
|
+
const nodeIndex = context.nodeIndex;
|
|
22318
|
+
if (!(tView === null || tView === void 0 ? void 0 : tView.data[nodeIndex])) {
|
|
22319
|
+
return [];
|
|
22320
|
+
}
|
|
22321
|
+
if (context.directives === undefined) {
|
|
22322
|
+
context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
|
|
22511
22323
|
}
|
|
22324
|
+
// The `directives` in this case are a named array called `LComponentView`. Clone the
|
|
22325
|
+
// result so we don't expose an internal data structure in the user's console.
|
|
22326
|
+
return context.directives === null ? [] : [...context.directives];
|
|
22512
22327
|
}
|
|
22513
22328
|
/**
|
|
22514
|
-
*
|
|
22329
|
+
* Returns the debug (partial) metadata for a particular directive or component instance.
|
|
22330
|
+
* The function accepts an instance of a directive or component and returns the corresponding
|
|
22331
|
+
* metadata.
|
|
22332
|
+
*
|
|
22333
|
+
* @param directiveOrComponentInstance Instance of a directive or component
|
|
22334
|
+
* @returns metadata of the passed directive or component
|
|
22335
|
+
*
|
|
22336
|
+
* @publicApi
|
|
22337
|
+
* @globalApi ng
|
|
22515
22338
|
*/
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
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);
|
|
22339
|
+
function getDirectiveMetadata(directiveOrComponentInstance) {
|
|
22340
|
+
const { constructor } = directiveOrComponentInstance;
|
|
22341
|
+
if (!constructor) {
|
|
22342
|
+
throw new Error('Unable to find the instance constructor');
|
|
22533
22343
|
}
|
|
22534
|
-
|
|
22535
|
-
|
|
22344
|
+
// In case a component inherits from a directive, we may have component and directive metadata
|
|
22345
|
+
// To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
|
|
22346
|
+
const componentDef = getComponentDef$1(constructor);
|
|
22347
|
+
if (componentDef) {
|
|
22348
|
+
return {
|
|
22349
|
+
inputs: componentDef.inputs,
|
|
22350
|
+
outputs: componentDef.outputs,
|
|
22351
|
+
encapsulation: componentDef.encapsulation,
|
|
22352
|
+
changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
|
|
22353
|
+
ChangeDetectionStrategy.Default
|
|
22354
|
+
};
|
|
22536
22355
|
}
|
|
22537
|
-
|
|
22538
|
-
|
|
22539
|
-
|
|
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);
|
|
22356
|
+
const directiveDef = getDirectiveDef(constructor);
|
|
22357
|
+
if (directiveDef) {
|
|
22358
|
+
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
22612
22359
|
}
|
|
22360
|
+
return null;
|
|
22613
22361
|
}
|
|
22614
|
-
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
22615
22362
|
/**
|
|
22616
|
-
*
|
|
22617
|
-
* ComponentFactoryResolver
|
|
22618
|
-
* already exists, retrieves the existing ComponentFactoryResolver.
|
|
22363
|
+
* Retrieve map of local references.
|
|
22619
22364
|
*
|
|
22620
|
-
*
|
|
22365
|
+
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
22366
|
+
*
|
|
22367
|
+
* @param target DOM element, component or directive instance for which to retrieve
|
|
22368
|
+
* the local references.
|
|
22621
22369
|
*/
|
|
22622
|
-
function
|
|
22623
|
-
|
|
22370
|
+
function getLocalRefs(target) {
|
|
22371
|
+
const context = getLContext(target);
|
|
22372
|
+
if (context === null)
|
|
22373
|
+
return {};
|
|
22374
|
+
if (context.localRefs === undefined) {
|
|
22375
|
+
const lView = context.lView;
|
|
22376
|
+
if (lView === null) {
|
|
22377
|
+
return {};
|
|
22378
|
+
}
|
|
22379
|
+
context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
|
|
22380
|
+
}
|
|
22381
|
+
return context.localRefs || {};
|
|
22624
22382
|
}
|
|
22625
22383
|
/**
|
|
22626
|
-
*
|
|
22384
|
+
* Retrieves the host element of a component or directive instance.
|
|
22385
|
+
* The host element is the DOM element that matched the selector of the directive.
|
|
22627
22386
|
*
|
|
22628
|
-
*
|
|
22629
|
-
*
|
|
22630
|
-
*
|
|
22387
|
+
* @param componentOrDirective Component or directive instance for which the host
|
|
22388
|
+
* element should be retrieved.
|
|
22389
|
+
* @returns Host element of the target.
|
|
22631
22390
|
*
|
|
22391
|
+
* @publicApi
|
|
22392
|
+
* @globalApi ng
|
|
22632
22393
|
*/
|
|
22633
|
-
|
|
22634
|
-
|
|
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
|
-
}
|
|
22394
|
+
function getHostElement(componentOrDirective) {
|
|
22395
|
+
return getLContext(componentOrDirective).native;
|
|
22652
22396
|
}
|
|
22653
|
-
|
|
22654
22397
|
/**
|
|
22655
|
-
*
|
|
22656
|
-
* Copyright Google LLC All Rights Reserved.
|
|
22398
|
+
* Retrieves the rendered text for a given component.
|
|
22657
22399
|
*
|
|
22658
|
-
*
|
|
22659
|
-
*
|
|
22400
|
+
* This function retrieves the host element of a component and
|
|
22401
|
+
* and then returns the `textContent` for that element. This implies
|
|
22402
|
+
* that the text returned will include re-projected content of
|
|
22403
|
+
* the component as well.
|
|
22404
|
+
*
|
|
22405
|
+
* @param component The component to return the content text for.
|
|
22660
22406
|
*/
|
|
22407
|
+
function getRenderedText(component) {
|
|
22408
|
+
const hostElement = getHostElement(component);
|
|
22409
|
+
return hostElement.textContent || '';
|
|
22410
|
+
}
|
|
22661
22411
|
/**
|
|
22662
|
-
*
|
|
22663
|
-
*
|
|
22664
|
-
*
|
|
22665
|
-
*
|
|
22412
|
+
* Retrieves a list of event listeners associated with a DOM element. The list does include host
|
|
22413
|
+
* listeners, but it does not include event listeners defined outside of the Angular context
|
|
22414
|
+
* (e.g. through `addEventListener`).
|
|
22415
|
+
*
|
|
22416
|
+
* @usageNotes
|
|
22417
|
+
* Given the following DOM structure:
|
|
22418
|
+
*
|
|
22419
|
+
* ```html
|
|
22420
|
+
* <app-root>
|
|
22421
|
+
* <div (click)="doSomething()"></div>
|
|
22422
|
+
* </app-root>
|
|
22423
|
+
* ```
|
|
22424
|
+
*
|
|
22425
|
+
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
22426
|
+
*
|
|
22427
|
+
* ```ts
|
|
22428
|
+
* {
|
|
22429
|
+
* name: 'click',
|
|
22430
|
+
* element: <div>,
|
|
22431
|
+
* callback: () => doSomething(),
|
|
22432
|
+
* useCapture: false
|
|
22433
|
+
* }
|
|
22434
|
+
* ```
|
|
22435
|
+
*
|
|
22436
|
+
* @param element Element for which the DOM listeners should be retrieved.
|
|
22437
|
+
* @returns Array of event listeners on the DOM element.
|
|
22438
|
+
*
|
|
22666
22439
|
* @publicApi
|
|
22440
|
+
* @globalApi ng
|
|
22667
22441
|
*/
|
|
22668
|
-
function
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22442
|
+
function getListeners(element) {
|
|
22443
|
+
ngDevMode && assertDomElement(element);
|
|
22444
|
+
const lContext = getLContext(element);
|
|
22445
|
+
const lView = lContext === null ? null : lContext.lView;
|
|
22446
|
+
if (lView === null)
|
|
22447
|
+
return [];
|
|
22448
|
+
const tView = lView[TVIEW];
|
|
22449
|
+
const lCleanup = lView[CLEANUP];
|
|
22450
|
+
const tCleanup = tView.cleanup;
|
|
22451
|
+
const listeners = [];
|
|
22452
|
+
if (tCleanup && lCleanup) {
|
|
22453
|
+
for (let i = 0; i < tCleanup.length;) {
|
|
22454
|
+
const firstParam = tCleanup[i++];
|
|
22455
|
+
const secondParam = tCleanup[i++];
|
|
22456
|
+
if (typeof firstParam === 'string') {
|
|
22457
|
+
const name = firstParam;
|
|
22458
|
+
const listenerElement = unwrapRNode(lView[secondParam]);
|
|
22459
|
+
const callback = lCleanup[tCleanup[i++]];
|
|
22460
|
+
const useCaptureOrIndx = tCleanup[i++];
|
|
22461
|
+
// if useCaptureOrIndx is boolean then report it as is.
|
|
22462
|
+
// if useCaptureOrIndx is positive number then it in unsubscribe method
|
|
22463
|
+
// if useCaptureOrIndx is negative number then it is a Subscription
|
|
22464
|
+
const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
|
|
22465
|
+
const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
|
|
22466
|
+
if (element == listenerElement) {
|
|
22467
|
+
listeners.push({ element, name, callback, useCapture, type });
|
|
22468
|
+
}
|
|
22694
22469
|
}
|
|
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
22470
|
}
|
|
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
22471
|
}
|
|
22472
|
+
listeners.sort(sortListeners);
|
|
22473
|
+
return listeners;
|
|
22728
22474
|
}
|
|
22729
|
-
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
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
|
-
}
|
|
22475
|
+
function sortListeners(a, b) {
|
|
22476
|
+
if (a.name == b.name)
|
|
22477
|
+
return 0;
|
|
22478
|
+
return a.name < b.name ? -1 : 1;
|
|
22748
22479
|
}
|
|
22749
22480
|
/**
|
|
22750
|
-
*
|
|
22481
|
+
* This function should not exist because it is megamorphic and only mostly correct.
|
|
22751
22482
|
*
|
|
22752
|
-
*
|
|
22753
|
-
* @developerPreview
|
|
22483
|
+
* See call site for more info.
|
|
22754
22484
|
*/
|
|
22755
|
-
function
|
|
22756
|
-
|
|
22757
|
-
return adapter.injector;
|
|
22485
|
+
function isDirectiveDefHack(obj) {
|
|
22486
|
+
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
22758
22487
|
}
|
|
22759
|
-
|
|
22760
22488
|
/**
|
|
22761
|
-
*
|
|
22762
|
-
* Copyright Google LLC All Rights Reserved.
|
|
22489
|
+
* Returns the attached `DebugNode` instance for an element in the DOM.
|
|
22763
22490
|
*
|
|
22764
|
-
*
|
|
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.
|
|
22491
|
+
* @param element DOM element which is owned by an existing component's view.
|
|
22771
22492
|
*/
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
this.cachedInjectors = new Map();
|
|
22493
|
+
function getDebugNode(element) {
|
|
22494
|
+
if (ngDevMode && !(element instanceof Node)) {
|
|
22495
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22776
22496
|
}
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
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);
|
|
22497
|
+
const lContext = getLContext(element);
|
|
22498
|
+
const lView = lContext ? lContext.lView : null;
|
|
22499
|
+
if (lView === null) {
|
|
22500
|
+
return null;
|
|
22789
22501
|
}
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
this.cachedInjectors.clear();
|
|
22800
|
-
}
|
|
22502
|
+
const nodeIndex = lContext.nodeIndex;
|
|
22503
|
+
if (nodeIndex !== -1) {
|
|
22504
|
+
const valueInLView = lView[nodeIndex];
|
|
22505
|
+
// this means that value in the lView is a component with its own
|
|
22506
|
+
// data. In this situation the TNode is not accessed at the same spot.
|
|
22507
|
+
const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
|
|
22508
|
+
ngDevMode &&
|
|
22509
|
+
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
22510
|
+
return buildDebugNode(tNode, lView);
|
|
22801
22511
|
}
|
|
22512
|
+
return null;
|
|
22802
22513
|
}
|
|
22803
|
-
/** @nocollapse */
|
|
22804
|
-
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22805
|
-
token: StandaloneService,
|
|
22806
|
-
providedIn: 'environment',
|
|
22807
|
-
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22808
|
-
});
|
|
22809
22514
|
/**
|
|
22810
|
-
*
|
|
22515
|
+
* Retrieve the component `LView` from component/element.
|
|
22811
22516
|
*
|
|
22812
|
-
*
|
|
22813
|
-
*
|
|
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.
|
|
22517
|
+
* NOTE: `LView` is a private and should not be leaked outside.
|
|
22518
|
+
* Don't export this method to `ng.*` on window.
|
|
22816
22519
|
*
|
|
22817
|
-
* @
|
|
22520
|
+
* @param target DOM element or component instance for which to retrieve the LView.
|
|
22818
22521
|
*/
|
|
22819
|
-
function
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
|
|
22522
|
+
function getComponentLView(target) {
|
|
22523
|
+
const lContext = getLContext(target);
|
|
22524
|
+
const nodeIndx = lContext.nodeIndex;
|
|
22525
|
+
const lView = lContext.lView;
|
|
22526
|
+
ngDevMode && assertLView(lView);
|
|
22527
|
+
const componentLView = lView[nodeIndx];
|
|
22528
|
+
ngDevMode && assertLView(componentLView);
|
|
22529
|
+
return componentLView;
|
|
22530
|
+
}
|
|
22531
|
+
/** Asserts that a value is a DOM Element. */
|
|
22532
|
+
function assertDomElement(value) {
|
|
22533
|
+
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
22534
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22535
|
+
}
|
|
22823
22536
|
}
|
|
22824
22537
|
|
|
22825
22538
|
/**
|
|
@@ -24040,7 +23753,7 @@ const unusedValueExportToPlacateAjd = 1;
|
|
|
24040
23753
|
* Use of this source code is governed by an MIT-style license that can be
|
|
24041
23754
|
* found in the LICENSE file at https://angular.io/license
|
|
24042
23755
|
*/
|
|
24043
|
-
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$
|
|
23756
|
+
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
|
|
24044
23757
|
class LQuery_ {
|
|
24045
23758
|
constructor(queryList) {
|
|
24046
23759
|
this.queryList = queryList;
|