@@ -38,8 +38,6 @@ function isInScope(url) {
3838 * @param {NavigateEvent } e
3939 */
4040function handleNav ( state , e ) {
41- // TODO: Double-check this can't fail to parse.
42- // `.destination` is read-only, so I'm hoping it guarantees a valid URL.
4341 const url = new URL ( e . destination . url ) ;
4442
4543 if (
@@ -93,14 +91,12 @@ export const exec = (url, route, matches = {}) => {
9391 * @param {import('preact').ComponentChildren } [props.children]
9492 */
9593export function LocationProvider ( props ) {
96- // @ts -expect-error - props.url is not implemented correctly & will be removed in the future
97- const [ url , route ] = useReducer ( handleNav , props . url || location . pathname + location . search ) ;
94+ const [ url , route ] = useReducer ( handleNav , location . pathname + location . search ) ;
9895 if ( props . scope ) scope = props . scope ;
9996
10097 const value = useMemo ( ( ) => {
10198 const u = new URL ( url , location . origin ) ;
10299 const path = u . pathname . replace ( / \/ + $ / g, '' ) || '/' ;
103- // @ts -ignore-next
104100 return {
105101 url,
106102 path,
@@ -116,7 +112,6 @@ export function LocationProvider(props) {
116112 } ;
117113 } , [ ] ) ;
118114
119- // @ts -ignore
120115 return h ( LocationProvider . ctx . Provider , { value } , props . children ) ;
121116}
122117
@@ -259,9 +254,6 @@ export function Router(props) {
259254
260255 // The route is loaded and rendered.
261256 if ( prevRoute . current !== path ) {
262- // TODO: Definitely need to think about this, for now, just removing `wasPush` as it
263- // doesn't make sense in context of the Navigation API.
264- scrollTo ( 0 , 0 ) ;
265257 if ( props . onRouteChange ) props . onRouteChange ( url ) ;
266258
267259 prevRoute . current = path ;
@@ -286,10 +278,10 @@ const RenderRef = ({ r }) => r.current;
286278Router . Provider = LocationProvider ;
287279
288280LocationProvider . ctx = createContext (
289- /** @type {import('./router.d.ts').LocationHook } */ ( { } )
281+ /** @type {import('./router-navigation-api .d.ts').LocationHook } */ ( { } )
290282) ;
291283const RouteContext = createContext (
292- /** @type {import('./router.d.ts').RouteHook & { rest: string } } */ ( { } )
284+ /** @type {import('./router-navigation-api .d.ts').RouteHook & { rest: string } } */ ( { } )
293285) ;
294286
295287export const Route = props => h ( props . component , props ) ;
0 commit comments