@@ -87,20 +87,6 @@ function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, rep
8787 performEnhancedPageLoad ( absoluteInternalHref , /* interceptedLink */ false ) ;
8888}
8989
90- function getCurrentScrollPosition ( ) {
91- const scrollPositionX = window . scrollX ;
92- const scrollPositionY = window . scrollY ;
93- return { X : scrollPositionX , Y : scrollPositionY } ;
94- }
95-
96- function saveScrollPosition ( ) {
97- const currentState = history . state || { } ;
98- const scrollPosition = getCurrentScrollPosition ( ) ;
99- // save the current scroll position
100- const updatedState = { ...currentState , scrollPosition : scrollPosition } ;
101- history . replaceState ( updatedState , /* ignored title */ '' , location . href ) ;
102- }
103-
10490function onDocumentClick ( event : MouseEvent ) {
10591 if ( hasInteractiveRouter ( ) ) {
10692 return ;
@@ -112,7 +98,6 @@ function onDocumentClick(event: MouseEvent) {
11298
11399 handleClickForNavigationInterception ( event , absoluteInternalHref => {
114100 const originalLocation = location . href ;
115- saveScrollPosition ( ) ;
116101
117102 const shouldScrollToHash = isSamePageWithHash ( absoluteInternalHref ) ;
118103 history . pushState ( null , /* ignored title */ '' , absoluteInternalHref ) ;
@@ -130,27 +115,13 @@ function onDocumentClick(event: MouseEvent) {
130115 } ) ;
131116}
132117
133- function removeScrollPositionFromState ( ) {
134- const currentState = history . state || { } ;
135- const { scrollPosition, ...rest } = currentState ;
136- history . replaceState ( Object . keys ( rest ) . length ? rest : null , /* ignored title */ '' , location . href ) ;
137- }
138-
139- function onPopState ( event : PopStateEvent ) {
118+ function onPopState ( state : PopStateEvent ) {
140119 if ( hasInteractiveRouter ( ) ) {
141120 return ;
142121 }
143122
144123 // load the new page
145- performEnhancedPageLoad ( location . href , /* interceptedLink */ false ) . then ( ( ) => {
146- const scrollPosition = event . state ?. scrollPosition ;
147- if ( scrollPosition !== undefined &&
148- ( scrollPosition . X !== window . scrollX || scrollPosition . Y !== window . scrollY ) ) {
149- window . scrollTo ( scrollPosition . X , scrollPosition . Y ) ;
150- // let the browser handle scroll restoration for the history produced by forwards/backwards actions
151- removeScrollPositionFromState ( ) ;
152- }
153- } )
124+ performEnhancedPageLoad ( location . href , /* interceptedLink */ false ) ;
154125}
155126
156127function onDocumentSubmit ( event : SubmitEvent ) {
0 commit comments