Breaking Changes
common
- The behavior of the
SpyLocation
used by theRouterTestingModule
has changed
to match the behavior of browsers. It no longer emits a ‘popstate’ event
whenLocation.go
is called. In addition,simulateHashChange
now
triggers both ahashchange
and apopstate
event.
Tests which uselocation.go
and expect the changes to be picked up by
theRouter
should likely change tosimulateHashChange
instead.
Each test is different in what it attempts to assert so there is no
single change that works for all tests. Each test using theSpyLocation
to
simulate browser URL changes should be evaluated on a case-by-case basis.
core
- TypeScript versions older than 4.4.2 are no longer supported.
- NodeJS versions older than
v12.20.0
are no longer
supported due to the Angular packages using the NodeJS package exports
feature with subpath patterns. - The
WrappedValue
class can no longer be imported from@angular/core
,
which may result in compile errors or failures at runtime if outdated
libraries are used that are still usingWrappedValue
. The usage of
WrappedValue
should be removed as no replacement is available.
forms
- A new type called
FormControlStatus
has been introduced, which is a union of all possible status strings for form controls.AbstractControl.status
has been narrowed fromstring
toFormControlStatus
, andstatusChanges
has been narrowed fromObservable<any>
toObservable<FormControlStatus>
. Most applications should consume the new types seamlessly. Any breakage caused by this change is likely due to one of the following two problems: (1) the app is comparingAbstractControl.status
against a string which is not a valid status; or, (2) the app is usingstatusChanges
events as if they were something other than strings.
router
- The default url serializer would previously drop
everything after and including a question mark in query parameters. That
is, for a navigation to/path?q=hello?&other=123
, the query
params would be parsed to just{q: 'hello'}
. This is
incorrect because the URI spec allows for question mark characers in
query data. This change will now correctly parse the params for the
above example to be{v: 'hello?', other: '123'}
. - Previously
null
andundefined
inputs forrouterLink
were
equaivalent to empty string and there was no way to disable the link’s
navigation.
In addition, thehref
is changed from a propertyHostBinding()
to an
attribute binding (HostBinding('attr.href')
). The effect of this
change is thatDebugElement.properties['href']
will now return the
href
value returned by the native element which will be the full URL
rather than the internal value of theRouterLink
href
property. - The router will no longer replace the browser URL when a new navigation
cancels an ongoing navigation. This often causes URL flicker and was
only in place to support some AngularJS hybrid applications. Hybrid
applications which rely on thenavigationId
being present on initial
navigations that were handled by the Angular router should instead
subscribe toNavigationCancel
events and perform the
location.replaceState
themselves to addnavigationId
to the Router
state.
In addition, tests which asserturlChanges
on theSpyLocation
may
need to be adjusted to account for thereplaceState
which is no longer
triggered. - It is no longer possible to use
Route.loadChildren
using a string
value. The following supporting classes were removed from
@angular/core
: NgModuleFactoryLoader
SystemJsNgModuleFactoryLoader
The @angular/router
package no longer exports these symbols:
SpyNgModuleFactoryLoader
DeprecatedLoadChildren
The signature of the setupTestingRouter
function from
@angular/core/testing
has been changed to drop its NgModuleFactoryLoader
parameter, as an argument for that parameter can no longer be created.
service-worker
- The return type of
SwUpdate#activateUpdate
andSwUpdate#checkForUpdate
changed toPromise<boolean>
.
Although unlikely, it is possible that this change will cause TypeScript type-checking to fail in
some cases. If necessary, update your types to account for the new
return type.
Deprecations
- The
renderModuleFactory
symbol in@angular/platform-server
is no longer necessary as of Angular v13.
The renderModuleFactory
calls can be replaced with renderModule
.
service-worker
- The
SwUpdate#activated
observable is deprecated.
The SwUpdate#activated
observable only emits values as a direct response to calling
SwUpdate#activateUpdate()
and was only useful for determining whether the call resulted in an
update or not. Now, the return value of SwUpdate#activateUpdate()
can be used to determine the
outcome of the operation and therefore using SwUpdate#activated
does not offer any benefit.
- The
SwUpdate#availalbe
observable is deprecated.
The new SwUpdate#versionUpdates
observable provides the same information and more. Therefore, it
is possible to rebuild the same behavior as SwUpdate#availalbe
using the events emitted by
SwUpdate#versionUpdates
and filtering for VersionReadyEvent
events.
As a result, the SwUpdate#availalbe
observable is now redundant.
转自 https://github.com/angular/angular/releases