mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(router): Remove deprecated initialNavigation option (#45729)
BREAKING CHANGE: `initialNavigation: 'enabled'` was deprecated in v11 and is replaced by `initialNavigation: 'enabledBlocking'`. PR Close #45729
This commit is contained in:
parent
aba8fb5bbe
commit
d4fc12fa19
4 changed files with 4 additions and 45 deletions
|
|
@ -249,7 +249,7 @@ export class GuardsCheckStart extends RouterEvent {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type InitialNavigation = 'disabled' | 'enabled' | 'enabledBlocking' | 'enabledNonBlocking';
|
||||
export type InitialNavigation = 'disabled' | 'enabledBlocking' | 'enabledNonBlocking';
|
||||
|
||||
// @public
|
||||
export interface IsActiveMatchOptions {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export function children(): any {
|
|||
[
|
||||
{path: '', pathMatch: 'prefix', loadChildren: children},
|
||||
],
|
||||
{initialNavigation: 'enabled'}),
|
||||
{initialNavigation: 'enabledBlocking'}),
|
||||
],
|
||||
declarations: [AppComponent],
|
||||
bootstrap: [AppComponent],
|
||||
|
|
|
|||
|
|
@ -237,13 +237,11 @@ export function provideRoutes(routes: Routes): any {
|
|||
* The following values have been [deprecated](guide/releases#deprecation-practices) since v11,
|
||||
* and should not be used for new applications.
|
||||
*
|
||||
* * 'enabled' - This option is 1:1 replaceable with `enabledBlocking`.
|
||||
*
|
||||
* @see `forRoot()`
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type InitialNavigation = 'disabled'|'enabled'|'enabledBlocking'|'enabledNonBlocking';
|
||||
export type InitialNavigation = 'disabled'|'enabledBlocking'|'enabledNonBlocking';
|
||||
|
||||
/**
|
||||
* A set of configuration options for a router module, provided in the
|
||||
|
|
@ -558,9 +556,7 @@ export class RouterInitializer implements OnDestroy {
|
|||
if (opts.initialNavigation === 'disabled') {
|
||||
router.setUpLocationChangeListener();
|
||||
resolve(true);
|
||||
} else if (
|
||||
// TODO: enabled is deprecated as of v11, can be removed in v13
|
||||
opts.initialNavigation === 'enabled' || opts.initialNavigation === 'enabledBlocking') {
|
||||
} else if (opts.initialNavigation === 'enabledBlocking') {
|
||||
router.hooks.afterPreactivation = () => {
|
||||
// only the initial navigation should be delayed
|
||||
if (!this.initNavigation) {
|
||||
|
|
|
|||
|
|
@ -76,43 +76,6 @@ describe('bootstrap', () => {
|
|||
}
|
||||
}));
|
||||
|
||||
it('should wait for resolvers to complete when initialNavigation = enabled', (done) => {
|
||||
@Component({selector: 'test', template: 'test'})
|
||||
class TestCmpEnabled {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule.forRoot(
|
||||
[{path: '**', component: TestCmpEnabled, resolve: {test: TestResolver}}],
|
||||
{useHash: true, initialNavigation: 'enabled'})
|
||||
],
|
||||
declarations: [RootCmp, TestCmpEnabled],
|
||||
bootstrap: [RootCmp],
|
||||
providers: [...testProviders, TestResolver],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
})
|
||||
class TestModule {
|
||||
constructor(router: Router) {
|
||||
log.push('TestModule');
|
||||
router.events.subscribe(e => log.push(e.constructor.name));
|
||||
}
|
||||
}
|
||||
|
||||
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
|
||||
const router = res.injector.get(Router);
|
||||
const data = router.routerState.snapshot.root.firstChild!.data;
|
||||
expect(data['test']).toEqual('test-data');
|
||||
expect(log).toEqual([
|
||||
'TestModule', 'NavigationStart', 'RoutesRecognized', 'GuardsCheckStart',
|
||||
'ChildActivationStart', 'ActivationStart', 'GuardsCheckEnd', 'ResolveStart', 'ResolveEnd',
|
||||
'RootCmp', 'ActivationEnd', 'ChildActivationEnd', 'NavigationEnd', 'Scroll'
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should wait for resolvers to complete when initialNavigation = enabledBlocking', (done) => {
|
||||
@Component({selector: 'test', template: 'test'})
|
||||
class TestCmpEnabled {
|
||||
|
|
|
|||
Loading…
Reference in a new issue