66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { Inject , Injectable , InjectionToken , ɵɵinject } from '@angular/core' ;
9+ import { inject , Injectable , InjectionToken } from '@angular/core' ;
1010
1111import { getDOM } from '../dom_adapter' ;
1212import { DOCUMENT } from '../dom_tokens' ;
@@ -33,11 +33,7 @@ import {DOCUMENT} from '../dom_tokens';
3333 *
3434 * @publicApi
3535 */
36- @Injectable ( {
37- providedIn : 'platform' ,
38- // See #23917
39- useFactory : useBrowserPlatformLocation
40- } )
36+ @Injectable ( { providedIn : 'platform' , useFactory : ( ) => inject ( BrowserPlatformLocation ) } )
4137export abstract class PlatformLocation {
4238 abstract getBaseHrefFromDOM ( ) : string ;
4339 abstract getState ( ) : unknown ;
@@ -71,10 +67,6 @@ export abstract class PlatformLocation {
7167 }
7268}
7369
74- export function useBrowserPlatformLocation ( ) {
75- return ɵɵinject ( BrowserPlatformLocation ) ;
76- }
77-
7870/**
7971 * @description
8072 * Indicates when a location is initialized.
@@ -112,14 +104,14 @@ export interface LocationChangeListener {
112104 */
113105@Injectable ( {
114106 providedIn : 'platform' ,
115- // See #23917
116- useFactory : createBrowserPlatformLocation ,
107+ useFactory : ( ) => new BrowserPlatformLocation ( ) ,
117108} )
118109export class BrowserPlatformLocation extends PlatformLocation {
119110 private _location : Location ;
120111 private _history : History ;
112+ private _doc = inject ( DOCUMENT ) ;
121113
122- constructor ( @ Inject ( DOCUMENT ) private _doc : any ) {
114+ constructor ( ) {
123115 super ( ) ;
124116 this . _location = window . location ;
125117 this . _history = window . history ;
@@ -167,19 +159,11 @@ export class BrowserPlatformLocation extends PlatformLocation {
167159 }
168160
169161 override pushState ( state : any , title : string , url : string ) : void {
170- if ( supportsState ( ) ) {
171- this . _history . pushState ( state , title , url ) ;
172- } else {
173- this . _location . hash = url ;
174- }
162+ this . _history . pushState ( state , title , url ) ;
175163 }
176164
177165 override replaceState ( state : any , title : string , url : string ) : void {
178- if ( supportsState ( ) ) {
179- this . _history . replaceState ( state , title , url ) ;
180- } else {
181- this . _location . hash = url ;
182- }
166+ this . _history . replaceState ( state , title , url ) ;
183167 }
184168
185169 override forward ( ) : void {
@@ -198,10 +182,3 @@ export class BrowserPlatformLocation extends PlatformLocation {
198182 return this . _history . state ;
199183 }
200184}
201-
202- export function supportsState ( ) : boolean {
203- return ! ! window . history . pushState ;
204- }
205- export function createBrowserPlatformLocation ( ) {
206- return new BrowserPlatformLocation ( ɵɵinject ( DOCUMENT ) ) ;
207- }
0 commit comments