@angular/core 16.0.0-rc.4 → 16.0.1
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/esm2022/src/application_ref.mjs +60 -55
- package/esm2022/src/errors.mjs +1 -1
- package/esm2022/src/hydration/annotate.mjs +1 -1
- package/esm2022/src/hydration/api.mjs +2 -2
- package/esm2022/src/hydration/skip_hydration.mjs +12 -1
- package/esm2022/src/hydration/utils.mjs +9 -3
- package/esm2022/src/linker/element_ref.mjs +1 -1
- package/esm2022/src/linker/view_container_ref.mjs +16 -6
- package/esm2022/src/render/api.mjs +1 -1
- package/esm2022/src/render3/definition.mjs +6 -3
- package/esm2022/src/render3/instructions/element_validation.mjs +2 -2
- package/esm2022/src/render3/instructions/shared.mjs +7 -3
- package/esm2022/src/render3/interfaces/document.mjs +6 -4
- package/esm2022/src/render3/interfaces/node.mjs +1 -1
- package/esm2022/src/render3/node_manipulation.mjs +7 -1
- package/esm2022/src/transfer_state.mjs +8 -7
- package/esm2022/src/util/assert.mjs +2 -5
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed.mjs +4 -4
- package/fesm2022/core.mjs +163 -120
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +105 -67
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +9 -17
- package/package.json +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/guard-and-resolve-interfaces/bundle.js +13 -13
- package/schematics/migrations/remove-module-id/bundle.js +14 -14
- package/schematics/ng-generate/standalone-migration/bundle.js +415 -361
- package/schematics/ng-generate/standalone-migration/bundle.js.map +3 -3
- package/testing/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v16.0.
|
|
2
|
+
* @license Angular v16.0.1
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -941,10 +941,7 @@ function throwError(msg, actual, expected, comparison) {
|
|
|
941
941
|
(comparison == null ? '' : ` [Expected=> ${expected} ${comparison} ${actual} <=Actual]`));
|
|
942
942
|
}
|
|
943
943
|
function assertDomNode(node) {
|
|
944
|
-
|
|
945
|
-
if (!(typeof Node !== 'undefined' && node instanceof Node) &&
|
|
946
|
-
!(typeof node === 'object' && node != null &&
|
|
947
|
-
node.constructor.name === 'WebWorkerRenderNode')) {
|
|
944
|
+
if (!(node instanceof Node)) {
|
|
948
945
|
throwError(`The provided value must be an instance of a DOM Node but got ${stringify(node)}`);
|
|
949
946
|
}
|
|
950
947
|
}
|
|
@@ -3157,7 +3154,7 @@ function getComponentId(componentDef) {
|
|
|
3157
3154
|
// Example:
|
|
3158
3155
|
// https://github.com/angular/components/blob/d9f82c8f95309e77a6d82fd574c65871e91354c2/src/material/core/option/option.ts#L248
|
|
3159
3156
|
// https://github.com/angular/components/blob/285f46dc2b4c5b127d356cb7c4714b221f03ce50/src/material/legacy-core/option/option.ts#L32
|
|
3160
|
-
const hashSelectors = [
|
|
3157
|
+
const hashSelectors = JSON.stringify([
|
|
3161
3158
|
componentDef.selectors,
|
|
3162
3159
|
componentDef.ngContentSelectors,
|
|
3163
3160
|
componentDef.hostVars,
|
|
@@ -3167,12 +3164,15 @@ function getComponentId(componentDef) {
|
|
|
3167
3164
|
componentDef.decls,
|
|
3168
3165
|
componentDef.encapsulation,
|
|
3169
3166
|
componentDef.standalone,
|
|
3167
|
+
componentDef.exportAs,
|
|
3168
|
+
componentDef.inputs,
|
|
3169
|
+
componentDef.outputs,
|
|
3170
3170
|
// We cannot use 'componentDef.type.name' as the name of the symbol will change and will not
|
|
3171
3171
|
// match in the server and browser bundles.
|
|
3172
3172
|
Object.getOwnPropertyNames(componentDef.type.prototype),
|
|
3173
3173
|
!!componentDef.contentQueries,
|
|
3174
3174
|
!!componentDef.viewQuery,
|
|
3175
|
-
]
|
|
3175
|
+
]);
|
|
3176
3176
|
for (const char of hashSelectors) {
|
|
3177
3177
|
hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
|
|
3178
3178
|
}
|
|
@@ -6385,7 +6385,7 @@ function isPropertyValid(element, propName, tagName, schemas) {
|
|
|
6385
6385
|
if (schemas === null)
|
|
6386
6386
|
return true;
|
|
6387
6387
|
// The property is considered valid if the element matches the schema, it exists on the element,
|
|
6388
|
-
// or it is synthetic
|
|
6388
|
+
// or it is synthetic.
|
|
6389
6389
|
if (matchingSchemas(schemas, tagName) || propName in element || isAnimationProp(propName)) {
|
|
6390
6390
|
return true;
|
|
6391
6391
|
}
|
|
@@ -6527,6 +6527,59 @@ function matchingSchemas(schemas, tagName) {
|
|
|
6527
6527
|
return false;
|
|
6528
6528
|
}
|
|
6529
6529
|
|
|
6530
|
+
/**
|
|
6531
|
+
* The name of an attribute that can be added to the hydration boundary node
|
|
6532
|
+
* (component host node) to disable hydration for the content within that boundary.
|
|
6533
|
+
*/
|
|
6534
|
+
const SKIP_HYDRATION_ATTR_NAME = 'ngSkipHydration';
|
|
6535
|
+
/**
|
|
6536
|
+
* Helper function to check if a given node has the 'ngSkipHydration' attribute
|
|
6537
|
+
*/
|
|
6538
|
+
function hasNgSkipHydrationAttr(tNode) {
|
|
6539
|
+
const SKIP_HYDRATION_ATTR_NAME_LOWER_CASE = SKIP_HYDRATION_ATTR_NAME.toLowerCase();
|
|
6540
|
+
const attrs = tNode.mergedAttrs;
|
|
6541
|
+
if (attrs === null)
|
|
6542
|
+
return false;
|
|
6543
|
+
// only ever look at the attribute name and skip the values
|
|
6544
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
6545
|
+
const value = attrs[i];
|
|
6546
|
+
// This is a marker, which means that the static attributes section is over,
|
|
6547
|
+
// so we can exit early.
|
|
6548
|
+
if (typeof value === 'number')
|
|
6549
|
+
return false;
|
|
6550
|
+
if (typeof value === 'string' && value.toLowerCase() === SKIP_HYDRATION_ATTR_NAME_LOWER_CASE) {
|
|
6551
|
+
return true;
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
return false;
|
|
6555
|
+
}
|
|
6556
|
+
/**
|
|
6557
|
+
* Checks whether a TNode has a flag to indicate that it's a part of
|
|
6558
|
+
* a skip hydration block.
|
|
6559
|
+
*/
|
|
6560
|
+
function hasInSkipHydrationBlockFlag(tNode) {
|
|
6561
|
+
return (tNode.flags & 128 /* TNodeFlags.inSkipHydrationBlock */) === 128 /* TNodeFlags.inSkipHydrationBlock */;
|
|
6562
|
+
}
|
|
6563
|
+
/**
|
|
6564
|
+
* Helper function that determines if a given node is within a skip hydration block
|
|
6565
|
+
* by navigating up the TNode tree to see if any parent nodes have skip hydration
|
|
6566
|
+
* attribute.
|
|
6567
|
+
*
|
|
6568
|
+
* TODO(akushnir): this function should contain the logic of `hasInSkipHydrationBlockFlag`,
|
|
6569
|
+
* there is no need to traverse parent nodes when we have a TNode flag (which would also
|
|
6570
|
+
* make this lookup O(1)).
|
|
6571
|
+
*/
|
|
6572
|
+
function isInSkipHydrationBlock(tNode) {
|
|
6573
|
+
let currentTNode = tNode.parent;
|
|
6574
|
+
while (currentTNode) {
|
|
6575
|
+
if (hasNgSkipHydrationAttr(currentTNode)) {
|
|
6576
|
+
return true;
|
|
6577
|
+
}
|
|
6578
|
+
currentTNode = currentTNode.parent;
|
|
6579
|
+
}
|
|
6580
|
+
return false;
|
|
6581
|
+
}
|
|
6582
|
+
|
|
6530
6583
|
/**
|
|
6531
6584
|
* Flags for renderer-specific style modifiers.
|
|
6532
6585
|
* @publicApi
|
|
@@ -7826,6 +7879,11 @@ function applyProjectionRecursive(renderer, action, lView, tProjectionNode, pare
|
|
|
7826
7879
|
else {
|
|
7827
7880
|
let nodeToProject = nodeToProjectOrRNodes;
|
|
7828
7881
|
const projectedComponentLView = componentLView[PARENT];
|
|
7882
|
+
// If a parent <ng-content> is located within a skip hydration block,
|
|
7883
|
+
// annotate an actual node that is being projected with the same flag too.
|
|
7884
|
+
if (hasInSkipHydrationBlockFlag(tProjectionNode)) {
|
|
7885
|
+
nodeToProject.flags |= 128 /* TNodeFlags.inSkipHydrationBlock */;
|
|
7886
|
+
}
|
|
7829
7887
|
applyNodes(renderer, action, nodeToProject, projectedComponentLView, parentRElement, beforeNode, true);
|
|
7830
7888
|
}
|
|
7831
7889
|
}
|
|
@@ -8126,7 +8184,7 @@ function ɵɵvalidateIframeAttribute(attrValue, tagName, attrName) {
|
|
|
8126
8184
|
* When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
|
|
8127
8185
|
* tell ivy what the global `document` is.
|
|
8128
8186
|
*
|
|
8129
|
-
* Angular does this for us in each of the standard platforms (`Browser
|
|
8187
|
+
* Angular does this for us in each of the standard platforms (`Browser` and `Server`)
|
|
8130
8188
|
* by calling `setDocument()` when providing the `DOCUMENT` token.
|
|
8131
8189
|
*/
|
|
8132
8190
|
let DOCUMENT = undefined;
|
|
@@ -8153,12 +8211,13 @@ function getDocument() {
|
|
|
8153
8211
|
else if (typeof document !== 'undefined') {
|
|
8154
8212
|
return document;
|
|
8155
8213
|
}
|
|
8214
|
+
throw new RuntimeError(210 /* RuntimeErrorCode.MISSING_DOCUMENT */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
|
|
8215
|
+
`The document object is not available in this context. Make sure the DOCUMENT injection token is provided.`);
|
|
8156
8216
|
// No "document" can be found. This should only happen if we are running ivy outside Angular and
|
|
8157
8217
|
// the current platform is not a browser. Since this is not a supported scenario at the moment
|
|
8158
8218
|
// this should not happen in Angular apps.
|
|
8159
8219
|
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
|
8160
|
-
// public API.
|
|
8161
|
-
return undefined;
|
|
8220
|
+
// public API.
|
|
8162
8221
|
}
|
|
8163
8222
|
|
|
8164
8223
|
/**
|
|
@@ -9864,7 +9923,9 @@ function makeStateKey(key) {
|
|
|
9864
9923
|
}
|
|
9865
9924
|
function initTransferState() {
|
|
9866
9925
|
const transferState = new TransferState();
|
|
9867
|
-
|
|
9926
|
+
if (inject$1(PLATFORM_ID) === 'browser') {
|
|
9927
|
+
transferState.store = retrieveTransferredState(getDocument(), inject$1(APP_ID));
|
|
9928
|
+
}
|
|
9868
9929
|
return transferState;
|
|
9869
9930
|
}
|
|
9870
9931
|
/**
|
|
@@ -9953,17 +10014,16 @@ function retrieveTransferredState(doc, appId) {
|
|
|
9953
10014
|
// Locate the script tag with the JSON data transferred from the server.
|
|
9954
10015
|
// The id of the script tag is set to the Angular appId + 'state'.
|
|
9955
10016
|
const script = doc.getElementById(appId + '-state');
|
|
9956
|
-
|
|
9957
|
-
if (script && script.textContent) {
|
|
10017
|
+
if (script?.textContent) {
|
|
9958
10018
|
try {
|
|
9959
10019
|
// Avoid using any here as it triggers lint errors in google3 (any is not allowed).
|
|
9960
|
-
|
|
10020
|
+
return JSON.parse(unescapeTransferStateContent(script.textContent));
|
|
9961
10021
|
}
|
|
9962
10022
|
catch (e) {
|
|
9963
10023
|
console.warn('Exception while restoring TransferState for app ' + appId, e);
|
|
9964
10024
|
}
|
|
9965
10025
|
}
|
|
9966
|
-
return
|
|
10026
|
+
return {};
|
|
9967
10027
|
}
|
|
9968
10028
|
|
|
9969
10029
|
/** Encodes that the node lookup should start from the host node of this component. */
|
|
@@ -10082,6 +10142,12 @@ function getComponentLViewForHydration(viewRef) {
|
|
|
10082
10142
|
if (isRootView(lView)) {
|
|
10083
10143
|
lView = lView[HEADER_OFFSET];
|
|
10084
10144
|
}
|
|
10145
|
+
// If a `ViewContainerRef` was injected in a component class, this resulted
|
|
10146
|
+
// in an LContainer creation at that location. In this case, the component
|
|
10147
|
+
// LView is in the LContainer's `HOST` slot.
|
|
10148
|
+
if (isLContainer(lView)) {
|
|
10149
|
+
lView = lView[HOST];
|
|
10150
|
+
}
|
|
10085
10151
|
return lView;
|
|
10086
10152
|
}
|
|
10087
10153
|
function getTextNodeContent(node) {
|
|
@@ -10377,7 +10443,7 @@ class Version {
|
|
|
10377
10443
|
/**
|
|
10378
10444
|
* @publicApi
|
|
10379
10445
|
*/
|
|
10380
|
-
const VERSION = new Version('16.0.
|
|
10446
|
+
const VERSION = new Version('16.0.1');
|
|
10381
10447
|
|
|
10382
10448
|
// This default value is when checking the hierarchy for a token.
|
|
10383
10449
|
//
|
|
@@ -10483,48 +10549,6 @@ class ErrorHandler {
|
|
|
10483
10549
|
}
|
|
10484
10550
|
}
|
|
10485
10551
|
|
|
10486
|
-
/**
|
|
10487
|
-
* The name of an attribute that can be added to the hydration boundary node
|
|
10488
|
-
* (component host node) to disable hydration for the content within that boundary.
|
|
10489
|
-
*/
|
|
10490
|
-
const SKIP_HYDRATION_ATTR_NAME = 'ngSkipHydration';
|
|
10491
|
-
/**
|
|
10492
|
-
* Helper function to check if a given node has the 'ngSkipHydration' attribute
|
|
10493
|
-
*/
|
|
10494
|
-
function hasNgSkipHydrationAttr(tNode) {
|
|
10495
|
-
const SKIP_HYDRATION_ATTR_NAME_LOWER_CASE = SKIP_HYDRATION_ATTR_NAME.toLowerCase();
|
|
10496
|
-
const attrs = tNode.mergedAttrs;
|
|
10497
|
-
if (attrs === null)
|
|
10498
|
-
return false;
|
|
10499
|
-
// only ever look at the attribute name and skip the values
|
|
10500
|
-
for (let i = 0; i < attrs.length; i += 2) {
|
|
10501
|
-
const value = attrs[i];
|
|
10502
|
-
// This is a marker, which means that the static attributes section is over,
|
|
10503
|
-
// so we can exit early.
|
|
10504
|
-
if (typeof value === 'number')
|
|
10505
|
-
return false;
|
|
10506
|
-
if (typeof value === 'string' && value.toLowerCase() === SKIP_HYDRATION_ATTR_NAME_LOWER_CASE) {
|
|
10507
|
-
return true;
|
|
10508
|
-
}
|
|
10509
|
-
}
|
|
10510
|
-
return false;
|
|
10511
|
-
}
|
|
10512
|
-
/**
|
|
10513
|
-
* Helper function that determines if a given node is within a skip hydration block
|
|
10514
|
-
* by navigating up the TNode tree to see if any parent nodes have skip hydration
|
|
10515
|
-
* attribute.
|
|
10516
|
-
*/
|
|
10517
|
-
function isInSkipHydrationBlock(tNode) {
|
|
10518
|
-
let currentTNode = tNode.parent;
|
|
10519
|
-
while (currentTNode) {
|
|
10520
|
-
if (hasNgSkipHydrationAttr(currentTNode)) {
|
|
10521
|
-
return true;
|
|
10522
|
-
}
|
|
10523
|
-
currentTNode = currentTNode.parent;
|
|
10524
|
-
}
|
|
10525
|
-
return false;
|
|
10526
|
-
}
|
|
10527
|
-
|
|
10528
10552
|
/**
|
|
10529
10553
|
* Internal token that specifies whether DOM reuse logic
|
|
10530
10554
|
* during hydration is enabled.
|
|
@@ -11471,6 +11495,10 @@ function createTNode(tView, tParent, type, index, value, attrs) {
|
|
|
11471
11495
|
ngDevMode && ngDevMode.tNode++;
|
|
11472
11496
|
ngDevMode && tParent && assertTNodeForTView(tParent, tView);
|
|
11473
11497
|
let injectorIndex = tParent ? tParent.injectorIndex : -1;
|
|
11498
|
+
let flags = 0;
|
|
11499
|
+
if (isInSkipHydrationBlock$1()) {
|
|
11500
|
+
flags |= 128 /* TNodeFlags.inSkipHydrationBlock */;
|
|
11501
|
+
}
|
|
11474
11502
|
const tNode = {
|
|
11475
11503
|
type,
|
|
11476
11504
|
index,
|
|
@@ -11481,7 +11509,7 @@ function createTNode(tView, tParent, type, index, value, attrs) {
|
|
|
11481
11509
|
directiveStylingLast: -1,
|
|
11482
11510
|
componentOffset: -1,
|
|
11483
11511
|
propertyBindings: null,
|
|
11484
|
-
flags
|
|
11512
|
+
flags,
|
|
11485
11513
|
providerIndexes: 0,
|
|
11486
11514
|
value: value,
|
|
11487
11515
|
attrs: attrs,
|
|
@@ -23469,7 +23497,11 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
|
|
|
23469
23497
|
}
|
|
23470
23498
|
const hydrationInfo = findMatchingDehydratedView(this._lContainer, templateRef.ssrId);
|
|
23471
23499
|
const viewRef = templateRef.createEmbeddedViewImpl(context || {}, injector, hydrationInfo);
|
|
23472
|
-
|
|
23500
|
+
// If there is a matching dehydrated view, but the host TNode is located in the skip
|
|
23501
|
+
// hydration block, this means that the content was detached (as a part of the skip
|
|
23502
|
+
// hydration logic) and it needs to be appended into the DOM.
|
|
23503
|
+
const skipDomInsertion = !!hydrationInfo && !hasInSkipHydrationBlockFlag(this._hostTNode);
|
|
23504
|
+
this.insertImpl(viewRef, index, skipDomInsertion);
|
|
23473
23505
|
return viewRef;
|
|
23474
23506
|
}
|
|
23475
23507
|
createComponent(componentFactoryOrType, indexOrOptions, injector, projectableNodes, environmentInjector) {
|
|
@@ -23543,7 +23575,11 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
|
|
|
23543
23575
|
const dehydratedView = findMatchingDehydratedView(this._lContainer, componentDef?.id ?? null);
|
|
23544
23576
|
const rNode = dehydratedView?.firstChild ?? null;
|
|
23545
23577
|
const componentRef = componentFactory.create(contextInjector, projectableNodes, rNode, environmentInjector);
|
|
23546
|
-
|
|
23578
|
+
// If there is a matching dehydrated view, but the host TNode is located in the skip
|
|
23579
|
+
// hydration block, this means that the content was detached (as a part of the skip
|
|
23580
|
+
// hydration logic) and it needs to be appended into the DOM.
|
|
23581
|
+
const skipDomInsertion = !!dehydratedView && !hasInSkipHydrationBlockFlag(this._hostTNode);
|
|
23582
|
+
this.insertImpl(componentRef.hostView, index, skipDomInsertion);
|
|
23547
23583
|
return componentRef;
|
|
23548
23584
|
}
|
|
23549
23585
|
insert(viewRef, index) {
|
|
@@ -23717,8 +23753,10 @@ function locateOrCreateAnchorNode(lContainer, hostLView, hostTNode, slotValue) {
|
|
|
23717
23753
|
return;
|
|
23718
23754
|
const hydrationInfo = hostLView[HYDRATION];
|
|
23719
23755
|
const noOffsetIndex = hostTNode.index - HEADER_OFFSET;
|
|
23720
|
-
|
|
23721
|
-
|
|
23756
|
+
// TODO(akushnir): this should really be a single condition, refactor the code
|
|
23757
|
+
// to use `hasInSkipHydrationBlockFlag` logic inside `isInSkipHydrationBlock`.
|
|
23758
|
+
const skipHydration = isInSkipHydrationBlock(hostTNode) || hasInSkipHydrationBlockFlag(hostTNode);
|
|
23759
|
+
const isNodeCreationMode = !hydrationInfo || skipHydration || isDisconnectedNode(hydrationInfo, noOffsetIndex);
|
|
23722
23760
|
// Regular creation mode.
|
|
23723
23761
|
if (isNodeCreationMode) {
|
|
23724
23762
|
return createAnchorNode(lContainer, hostLView, hostTNode, slotValue);
|
|
@@ -26130,7 +26168,7 @@ class TestBedImpl {
|
|
|
26130
26168
|
}
|
|
26131
26169
|
configureCompiler(config) {
|
|
26132
26170
|
if (config.useJit != null) {
|
|
26133
|
-
throw new Error('
|
|
26171
|
+
throw new Error('JIT compiler is not configurable via TestBed APIs.');
|
|
26134
26172
|
}
|
|
26135
26173
|
if (config.providers !== undefined) {
|
|
26136
26174
|
this.compiler.setCompilerProviders(config.providers);
|
|
@@ -26138,7 +26176,7 @@ class TestBedImpl {
|
|
|
26138
26176
|
return this;
|
|
26139
26177
|
}
|
|
26140
26178
|
configureTestingModule(moduleDef) {
|
|
26141
|
-
this.assertNotInstantiated('
|
|
26179
|
+
this.assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
|
|
26142
26180
|
// Trigger module scoping queue flush before executing other TestBed operations in a test.
|
|
26143
26181
|
// This is needed for the first test invocation to ensure that globally declared modules have
|
|
26144
26182
|
// their components scoped properly. See the `checkGlobalCompilationFinished` function
|
|
@@ -26192,7 +26230,7 @@ class TestBedImpl {
|
|
|
26192
26230
|
return this;
|
|
26193
26231
|
}
|
|
26194
26232
|
overrideTemplateUsingTestingModule(component, template) {
|
|
26195
|
-
this.assertNotInstantiated('
|
|
26233
|
+
this.assertNotInstantiated('TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
|
|
26196
26234
|
this.compiler.overrideTemplateUsingTestingModule(component, template);
|
|
26197
26235
|
return this;
|
|
26198
26236
|
}
|