@@ -88,8 +88,7 @@ function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, rep
8888 }
8989}
9090
91- function getCurrentScrollPosition ( )
92- {
91+ function getCurrentScrollPosition ( ) {
9392 const scrollPositionX = window . scrollX ;
9493 const scrollPositionY = window . scrollY ;
9594 return { X : scrollPositionX , Y : scrollPositionY } ;
@@ -98,9 +97,9 @@ function getCurrentScrollPosition()
9897function saveScrollPosition ( ) {
9998 const currentState = history . state || { } ;
10099 const scrollPosition = getCurrentScrollPosition ( ) ;
101- // save the current scroll position
102- const updatedState = { ...currentState , scrollPosition : scrollPosition } ;
103- history . replaceState ( updatedState , /* ignored title */ '' , location . href ) ;
100+ // save the current scroll position
101+ const updatedState = { ...currentState , scrollPosition : scrollPosition } ;
102+ history . replaceState ( updatedState , /* ignored title */ '' , location . href ) ;
104103}
105104
106105function onDocumentClick ( event : MouseEvent ) {
@@ -139,9 +138,9 @@ function onPopState(state: PopStateEvent) {
139138 }
140139
141140 // load the new page
141+ const scrollPosition = history . state ?. scrollPosition ;
142142 saveScrollPosition ( ) ;
143143 performEnhancedPageLoad ( location . href , /* interceptedLink */ false ) . then ( ( ) => {
144- const scrollPosition = history . state ?. scrollPosition ;
145144 if ( scrollPosition !== undefined &&
146145 ( scrollPosition . X !== window . scrollX || scrollPosition . Y !== window . scrollY ) ) {
147146 window . scrollTo ( scrollPosition . X , scrollPosition . Y ) ;
0 commit comments