mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 03:54:46 +00:00
Fix hash link reliability (fix #434)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<a href="tall-page#foo">scroll to foo</a>
|
||||
<div style="height: 9999px"></div>
|
||||
|
||||
<div id="foo">
|
||||
|
||||
@@ -33,6 +33,24 @@ describe('scroll', function() {
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
});
|
||||
|
||||
it('scrolls to any deeplink if it was already active', async () => {
|
||||
await page.goto(`${base}/tall-page#foo`);
|
||||
await start();
|
||||
|
||||
let scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
|
||||
scrollY = await page.evaluate(() => {
|
||||
window.scrollTo(0, 0)
|
||||
return window.scrollY
|
||||
});
|
||||
assert.ok(scrollY === 0, scrollY);
|
||||
|
||||
await page.click('[href="tall-page#foo"]');
|
||||
scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
});
|
||||
|
||||
it('resets scroll when a link is clicked', async () => {
|
||||
await page.goto(`${base}/tall-page#foo`);
|
||||
await start();
|
||||
|
||||
Reference in New Issue
Block a user