@angular/core 17.0.7 → 17.0.9
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/application_ref.mjs +24 -12
- package/esm2022/src/application/create_application.mjs +2 -2
- package/esm2022/src/change_detection/flags.mjs +16 -0
- package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +164 -0
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +13 -0
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +56 -0
- package/esm2022/src/core.mjs +2 -2
- package/esm2022/src/core_private_export.mjs +5 -2
- package/esm2022/src/core_render3_private_export.mjs +1 -2
- package/esm2022/src/defer/dom_triggers.mjs +1 -5
- package/esm2022/src/di/inject_switch.mjs +2 -3
- package/esm2022/src/di/r3_injector.mjs +8 -6
- package/esm2022/src/errors.mjs +1 -1
- package/esm2022/src/event_emitter.mjs +1 -2
- package/esm2022/src/hydration/utils.mjs +2 -2
- package/esm2022/src/hydration/views.mjs +2 -2
- package/esm2022/src/linker/view_container_ref.mjs +2 -2
- package/esm2022/src/pending_tasks.mjs +57 -0
- package/esm2022/src/platform/platform_ref.mjs +2 -2
- package/esm2022/src/render3/after_render_hooks.mjs +16 -34
- package/esm2022/src/render3/collect_native_nodes.mjs +2 -3
- package/esm2022/src/render3/component_ref.mjs +13 -9
- package/esm2022/src/render3/debug/injector_profiler.mjs +1 -1
- package/esm2022/src/render3/errors_di.mjs +4 -3
- package/esm2022/src/render3/instructions/advance.mjs +2 -2
- package/esm2022/src/render3/instructions/change_detection.mjs +1 -6
- package/esm2022/src/render3/instructions/mark_view_dirty.mjs +4 -3
- package/esm2022/src/render3/instructions/shared.mjs +4 -3
- package/esm2022/src/render3/interfaces/container.mjs +1 -6
- package/esm2022/src/render3/interfaces/view.mjs +1 -1
- package/esm2022/src/render3/node_manipulation.mjs +8 -8
- package/esm2022/src/render3/reactivity/effect.mjs +8 -6
- package/esm2022/src/render3/styling/style_binding_list.mjs +4 -4
- package/esm2022/src/render3/util/discovery_utils.mjs +3 -3
- package/esm2022/src/render3/util/global_utils.mjs +28 -28
- package/esm2022/src/render3/util/injector_discovery_utils.mjs +1 -1
- package/esm2022/src/render3/util/injector_utils.mjs +6 -5
- package/esm2022/src/render3/util/view_traversal_utils.mjs +3 -12
- package/esm2022/src/render3/util/view_utils.mjs +36 -19
- package/esm2022/src/render3/view_ref.mjs +2 -1
- package/esm2022/src/version.mjs +6 -5
- package/esm2022/src/zone/ng_zone.mjs +1 -61
- package/esm2022/testing/src/component_fixture.mjs +62 -58
- package/esm2022/testing/src/logger.mjs +3 -3
- package/fesm2022/core.mjs +374 -309
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +62 -58
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +405 -46
- package/package.json +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/block-template-entities/bundle.js +332 -330
- package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
- package/schematics/ng-generate/control-flow-migration/bundle.js +498 -397
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
- package/schematics/ng-generate/standalone-migration/bundle.js +349 -323
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +6 -2
- package/esm2022/src/change_detection/scheduling.mjs +0 -103
- package/esm2022/src/initial_render_pending_tasks.mjs +0 -49
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.0.
|
|
2
|
+
* @license Angular v17.0.9
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ɵDeferBlockState, ɵtriggerResourceLoading, ɵrenderDeferBlockState, ɵCONTAINER_HEADER_OFFSET, ɵgetDeferBlocks, InjectionToken, inject as inject$1, NgZone, ɵZoneAwareQueueingScheduler, getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadataFn, ɵgenerateStandaloneInDeclarationsError, ɵDeferBlockBehavior, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, provideZoneChangeDetection, Compiler, ɵDEFER_BLOCK_CONFIG, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, runInInjectionContext, EnvironmentInjector, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
7
|
+
import { ɵDeferBlockState, ɵtriggerResourceLoading, ɵrenderDeferBlockState, ɵCONTAINER_HEADER_OFFSET, ɵgetDeferBlocks, InjectionToken, inject as inject$1, ɵNoopNgZone, NgZone, ɵZoneAwareQueueingScheduler, ApplicationRef, getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadataFn, ɵgenerateStandaloneInDeclarationsError, ɵDeferBlockBehavior, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, provideZoneChangeDetection, Compiler, ɵDEFER_BLOCK_CONFIG, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, runInInjectionContext, EnvironmentInjector, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
8
8
|
export { ɵDeferBlockBehavior as DeferBlockBehavior, ɵDeferBlockState as DeferBlockState } from '@angular/core';
|
|
9
9
|
import { Subscription } from 'rxjs';
|
|
10
10
|
import { ResourceLoader } from '@angular/compiler';
|
|
@@ -168,62 +168,72 @@ class ComponentFixture {
|
|
|
168
168
|
this._isDestroyed = false;
|
|
169
169
|
this._resolve = null;
|
|
170
170
|
this._promise = null;
|
|
171
|
-
this.
|
|
171
|
+
this.noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
|
|
172
|
+
this._ngZone = this.noZoneOptionIsSet ? new ɵNoopNgZone() : inject$1(NgZone);
|
|
172
173
|
this._autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? false;
|
|
173
174
|
this.effectRunner = inject$1(ɵZoneAwareQueueingScheduler, { optional: true });
|
|
174
175
|
this._subscriptions = new Subscription();
|
|
176
|
+
// Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
|
|
177
|
+
// This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
|
|
178
|
+
// This is a crazy way of doing things but hey, it's the world we live in.
|
|
179
|
+
// The zoneless scheduler should instead do this more imperatively by attaching
|
|
180
|
+
// the `ComponentRef` to `ApplicationRef` and calling `appRef.tick` as the `detectChanges`
|
|
181
|
+
// behavior.
|
|
182
|
+
this.appRef = inject$1(ApplicationRef);
|
|
183
|
+
// TODO(atscott): Remove this from public API
|
|
184
|
+
this.ngZone = this.noZoneOptionIsSet ? null : this._ngZone;
|
|
175
185
|
this.changeDetectorRef = componentRef.changeDetectorRef;
|
|
176
186
|
this.elementRef = componentRef.location;
|
|
177
187
|
this.debugElement = getDebugNode(this.elementRef.nativeElement);
|
|
178
188
|
this.componentInstance = componentRef.instance;
|
|
179
189
|
this.nativeElement = this.elementRef.nativeElement;
|
|
180
190
|
this.componentRef = componentRef;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
this.setupNgZone();
|
|
192
|
+
}
|
|
193
|
+
setupNgZone() {
|
|
194
|
+
// Create subscriptions outside the NgZone so that the callbacks run outside
|
|
195
|
+
// of NgZone.
|
|
196
|
+
this._ngZone.runOutsideAngular(() => {
|
|
197
|
+
this._subscriptions.add(this._ngZone.onUnstable.subscribe({
|
|
198
|
+
next: () => {
|
|
199
|
+
this._isStable = false;
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
this._subscriptions.add(this._ngZone.onMicrotaskEmpty.subscribe({
|
|
203
|
+
next: () => {
|
|
204
|
+
if (this._autoDetect) {
|
|
205
|
+
// Do a change detection run with checkNoChanges set to true to check
|
|
206
|
+
// there are no changes on the second run.
|
|
207
|
+
this.detectChanges(true);
|
|
198
208
|
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
this._subscriptions.add(this._ngZone.onStable.subscribe({
|
|
212
|
+
next: () => {
|
|
213
|
+
this._isStable = true;
|
|
214
|
+
// Check whether there is a pending whenStable() completer to resolve.
|
|
215
|
+
if (this._promise !== null) {
|
|
216
|
+
// If so check whether there are no pending macrotasks before resolving.
|
|
217
|
+
// Do this check in the next tick so that ngZone gets a chance to update the state of
|
|
218
|
+
// pending macrotasks.
|
|
219
|
+
queueMicrotask(() => {
|
|
220
|
+
if (!this._ngZone.hasPendingMacrotasks) {
|
|
221
|
+
if (this._promise !== null) {
|
|
222
|
+
this._resolve(true);
|
|
223
|
+
this._resolve = null;
|
|
224
|
+
this._promise = null;
|
|
215
225
|
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}));
|
|
220
|
-
this._subscriptions.add(ngZone.onError.subscribe({
|
|
221
|
-
next: (error) => {
|
|
222
|
-
throw error;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
223
228
|
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
231
|
+
this._subscriptions.add(this._ngZone.onError.subscribe({
|
|
232
|
+
next: (error) => {
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
});
|
|
227
237
|
}
|
|
228
238
|
_tick(checkNoChanges) {
|
|
229
239
|
this.changeDetectorRef.detectChanges();
|
|
@@ -236,17 +246,11 @@ class ComponentFixture {
|
|
|
236
246
|
*/
|
|
237
247
|
detectChanges(checkNoChanges = true) {
|
|
238
248
|
this.effectRunner?.flush();
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.ngZone.run(() => {
|
|
243
|
-
this._tick(checkNoChanges);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
// Running without zone. Just do the change detection.
|
|
249
|
+
// Run the change detection inside the NgZone so that any async tasks as part of the change
|
|
250
|
+
// detection are captured by the zone and can be waited for in isStable.
|
|
251
|
+
this._ngZone.run(() => {
|
|
248
252
|
this._tick(checkNoChanges);
|
|
249
|
-
}
|
|
253
|
+
});
|
|
250
254
|
// Run any effects that were created/dirtied during change detection. Such effects might become
|
|
251
255
|
// dirty in response to input signals changing.
|
|
252
256
|
this.effectRunner?.flush();
|
|
@@ -263,7 +267,7 @@ class ComponentFixture {
|
|
|
263
267
|
* Also runs detectChanges once so that any existing change is detected.
|
|
264
268
|
*/
|
|
265
269
|
autoDetectChanges(autoDetect = true) {
|
|
266
|
-
if (this.
|
|
270
|
+
if (this.noZoneOptionIsSet) {
|
|
267
271
|
throw new Error('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');
|
|
268
272
|
}
|
|
269
273
|
this._autoDetect = autoDetect;
|
|
@@ -274,7 +278,7 @@ class ComponentFixture {
|
|
|
274
278
|
* yet.
|
|
275
279
|
*/
|
|
276
280
|
isStable() {
|
|
277
|
-
return this._isStable && !this.
|
|
281
|
+
return this._isStable && !this._ngZone.hasPendingMacrotasks;
|
|
278
282
|
}
|
|
279
283
|
/**
|
|
280
284
|
* Get a promise that resolves when the fixture is stable.
|