This repository was archived by the owner on Jan 11, 2023. It is now read-only.
File tree 3 files changed +23
-0
lines changed
templates/src/client/start
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ function handle_click(event: MouseEvent) {
83
83
const svg = typeof a . href === 'object' && a . href . constructor . name === 'SVGAnimatedString' ;
84
84
const href = String ( svg ? ( < SVGAElement > a ) . href . baseVal : a . href ) ;
85
85
86
+ if ( location . hash && href === location . href ) {
87
+ return ;
88
+ }
89
+
86
90
if ( href === location . href ) {
87
91
event . preventDefault ( ) ;
88
92
return ;
Original file line number Diff line number Diff line change
1
+ < a href ="tall-page#foo "> scroll to foo</ a >
1
2
< div style ="height: 9999px "> </ div >
2
3
3
4
< div id ="foo ">
Original file line number Diff line number Diff line change @@ -33,6 +33,24 @@ describe('scroll', function() {
33
33
assert . ok ( scrollY > 0 , scrollY ) ;
34
34
} ) ;
35
35
36
+ it ( 'scrolls to any deeplink if it was already active' , async ( ) => {
37
+ await page . goto ( `${ base } /tall-page#foo` ) ;
38
+ await start ( ) ;
39
+
40
+ let scrollY = await page . evaluate ( ( ) => window . scrollY ) ;
41
+ assert . ok ( scrollY > 0 , scrollY ) ;
42
+
43
+ scrollY = await page . evaluate ( ( ) => {
44
+ window . scrollTo ( 0 , 0 )
45
+ return window . scrollY
46
+ } ) ;
47
+ assert . ok ( scrollY === 0 , scrollY ) ;
48
+
49
+ await page . click ( '[href="tall-page#foo"]' ) ;
50
+ scrollY = await page . evaluate ( ( ) => window . scrollY ) ;
51
+ assert . ok ( scrollY > 0 , scrollY ) ;
52
+ } ) ;
53
+
36
54
it ( 'resets scroll when a link is clicked' , async ( ) => {
37
55
await page . goto ( `${ base } /tall-page#foo` ) ;
38
56
await start ( ) ;
You can’t perform that action at this time.
0 commit comments