Skip to content

Commit d4fc12f

Browse files
atscottdylhunn
authored andcommitted
fix(router): Remove deprecated initialNavigation option (#45729)
BREAKING CHANGE: `initialNavigation: 'enabled'` was deprecated in v11 and is replaced by `initialNavigation: 'enabledBlocking'`. PR Close #45729
1 parent aba8fb5 commit d4fc12f

File tree

4 files changed

+4
-45
lines changed

4 files changed

+4
-45
lines changed

goldens/public-api/router/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class GuardsCheckStart extends RouterEvent {
249249
}
250250

251251
// @public
252-
export type InitialNavigation = 'disabled' | 'enabled' | 'enabledBlocking' | 'enabledNonBlocking';
252+
export type InitialNavigation = 'disabled' | 'enabledBlocking' | 'enabledNonBlocking';
253253

254254
// @public
255255
export interface IsActiveMatchOptions {

packages/compiler-cli/integrationtest/bazel/injectable_def/app/src/root.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function children(): any {
3434
[
3535
{path: '', pathMatch: 'prefix', loadChildren: children},
3636
],
37-
{initialNavigation: 'enabled'}),
37+
{initialNavigation: 'enabledBlocking'}),
3838
],
3939
declarations: [AppComponent],
4040
bootstrap: [AppComponent],

packages/router/src/router_module.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,11 @@ export function provideRoutes(routes: Routes): any {
237237
* The following values have been [deprecated](guide/releases#deprecation-practices) since v11,
238238
* and should not be used for new applications.
239239
*
240-
* * 'enabled' - This option is 1:1 replaceable with `enabledBlocking`.
241-
*
242240
* @see `forRoot()`
243241
*
244242
* @publicApi
245243
*/
246-
export type InitialNavigation = 'disabled'|'enabled'|'enabledBlocking'|'enabledNonBlocking';
244+
export type InitialNavigation = 'disabled'|'enabledBlocking'|'enabledNonBlocking';
247245

248246
/**
249247
* A set of configuration options for a router module, provided in the
@@ -558,9 +556,7 @@ export class RouterInitializer implements OnDestroy {
558556
if (opts.initialNavigation === 'disabled') {
559557
router.setUpLocationChangeListener();
560558
resolve(true);
561-
} else if (
562-
// TODO: enabled is deprecated as of v11, can be removed in v13
563-
opts.initialNavigation === 'enabled' || opts.initialNavigation === 'enabledBlocking') {
559+
} else if (opts.initialNavigation === 'enabledBlocking') {
564560
router.hooks.afterPreactivation = () => {
565561
// only the initial navigation should be delayed
566562
if (!this.initNavigation) {

packages/router/test/bootstrap.spec.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -76,43 +76,6 @@ describe('bootstrap', () => {
7676
}
7777
}));
7878

79-
it('should wait for resolvers to complete when initialNavigation = enabled', (done) => {
80-
@Component({selector: 'test', template: 'test'})
81-
class TestCmpEnabled {
82-
}
83-
84-
@NgModule({
85-
imports: [
86-
BrowserModule,
87-
RouterModule.forRoot(
88-
[{path: '**', component: TestCmpEnabled, resolve: {test: TestResolver}}],
89-
{useHash: true, initialNavigation: 'enabled'})
90-
],
91-
declarations: [RootCmp, TestCmpEnabled],
92-
bootstrap: [RootCmp],
93-
providers: [...testProviders, TestResolver],
94-
schemas: [CUSTOM_ELEMENTS_SCHEMA]
95-
})
96-
class TestModule {
97-
constructor(router: Router) {
98-
log.push('TestModule');
99-
router.events.subscribe(e => log.push(e.constructor.name));
100-
}
101-
}
102-
103-
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
104-
const router = res.injector.get(Router);
105-
const data = router.routerState.snapshot.root.firstChild!.data;
106-
expect(data['test']).toEqual('test-data');
107-
expect(log).toEqual([
108-
'TestModule', 'NavigationStart', 'RoutesRecognized', 'GuardsCheckStart',
109-
'ChildActivationStart', 'ActivationStart', 'GuardsCheckEnd', 'ResolveStart', 'ResolveEnd',
110-
'RootCmp', 'ActivationEnd', 'ChildActivationEnd', 'NavigationEnd', 'Scroll'
111-
]);
112-
done();
113-
});
114-
});
115-
11679
it('should wait for resolvers to complete when initialNavigation = enabledBlocking', (done) => {
11780
@Component({selector: 'test', template: 'test'})
11881
class TestCmpEnabled {

0 commit comments

Comments
 (0)