18.0.0-next.0
版本发布时间: 2024-03-14 23:44:33
angular/angular最新发布版本:19.0.0-next.7(2024-09-26 01:14:39)
18.0.0-next.0 (2024-03-14)
compiler-cli
Commit | Description |
---|---|
preserve original reference to non-deferrable dependency (#54759) |
core
router
Commit | Description |
---|---|
Add ability to return UrlTree with NavigationBehaviorOptions from guards (#45023) |
Breaking Changes
core
-
OnPush
views at the root of the application need to be marked dirty for their host bindings to refresh. Previously, the host bindings were refreshed for all root views without respecting theOnPush
change detection strategy. -
OnPush
views at the root of the application need to be marked dirty for their host bindings to refresh. Previously, the host bindings were refreshed for all root views without respecting theOnPush
change detection strategy. - The
ComponentFixture
autoDetect
feature will no longer refresh the component's host view when the component isOnPush
and not marked dirty. This exposes existing issues in components which claim to beOnPush
but do not correctly callmarkForCheck
when they need to be refreshed. If this change causes test failures, the easiest fix is to change the component toChangeDetectionStrategy.Default
. - When Angular runs change detection, it will continue to
refresh any views attached to
ApplicationRef
that are still marked for check after one round completes. In rare cases, this can result in infinite loops when certain patterns continue to mark views for check usingChangeDetectorRef.detectChanges
. This will be surfaced as a runtime error with theNG0103
code. - The
ComponentFixture.autoDetect
feature now executes change detection for the fixture withinApplicationRef.tick
. This more closely matches the behavior of how a component would refresh in production. The order of component refresh in tests may be slightly affected as a result, especially when dealing with additional components attached to the application, such as dialogs. Tests sensitive to this type of change (such as screenshot tests) may need to be updated. Concretely, this change means that the component will refresh before additional views attached toApplicationRef
(i.e. dialog components). Prior to this change, the fixture component would refresh after other views attached to the application. - The exact timing of change detection execution when
using event or run coalescing with
NgZone
is now the first of eithersetTimeout
orrequestAnimationFrame
. Code which relies on this timing (usually by accident) will need to be adjusted. If a callback needs to execute after change detection, we recommendafterNextRender
instead of something likesetTimeout
. - Newly created and views marked for check and reattached
during change detection are now guaranteed to be refreshed in that same
change detection cycle. Previously, if they were attached at a location
in the view tree that was already checked, they would either throw
ExpressionChangedAfterItHasBeenCheckedError
or not be refreshed until some future round of change detection. In rare circumstances, this correction can cause issues. We identified one instance that relied on the previous behavior by reading a value on initialization which was queued to be updated in a microtask instead of being available in the current change detection round. The component only read this value during initialization and did not read it again after the microtask updated it.
router
- Guards can now return
RedirectCommand
for redirects in addition toUrlTree
. Code which expects onlyboolean
orUrlTree
values inRoute
types will need to be adjusted.