From 521043a689e01feddba1f776d26c8f082d432af8 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Tue, 29 Dec 2020 18:11:11 -0500 Subject: [PATCH 01/14] Add test coverage for Turbo Drive and Skip Links Closes https://github.com/hotwired/turbo/issues/42 Navigate with a skip link within our Functional test suite, assert that the correct element is scrolled to, the page's Location path and hash are correct, and that the initial tab stop occurs after the skipped-to content. --- src/tests/fixtures/navigation.html | 6 +++++- src/tests/functional/navigation_tests.ts | 15 +++++++++++++++ src/tests/helpers/functional_test_case.ts | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/tests/fixtures/navigation.html b/src/tests/fixtures/navigation.html index b706c0f7b..245db17f7 100644 --- a/src/tests/fixtures/navigation.html +++ b/src/tests/fixtures/navigation.html @@ -7,7 +7,11 @@ -
+ Skip Link + + Skipped Content + +

Navigation

Same-origin unannotated link

Same-origin data-turbo-action=replace link

diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index fb267298b..84f0dfe90 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -116,6 +116,21 @@ export class NavigationTests extends TurboDriveTestCase { this.assert.equal(await this.pathname, "/src/tests/fixtures/one.html") this.assert.equal(await this.visitAction, "restore") } + + async "test skip link with hash-only path"() { + await this.clickSelector('a[href="#main"]') + + this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") + this.assert.equal(await this.hash, "#main") + this.assert.ok(await this.isScrolledToSelector("#main")) + + await this.pressTab() + const activeElement = await this.remote.getActiveElement() + const skippedLink = await this.querySelector("#ignored-link") + const firstLinkWithinMain = await this.querySelector("#main a:first-of-type") + this.assert.notOk(await activeElement.equals(skippedLink), "skips interactive elements before #main") + this.assert.ok(await activeElement.equals(firstLinkWithinMain), "skips to first interactive element after #main") + } } NavigationTests.registerSuite() diff --git a/src/tests/helpers/functional_test_case.ts b/src/tests/helpers/functional_test_case.ts index 9d1a6edef..dd0b3b9c0 100644 --- a/src/tests/helpers/functional_test_case.ts +++ b/src/tests/helpers/functional_test_case.ts @@ -41,6 +41,10 @@ export class FunctionalTestCase extends InternTestCase { return this.evaluate(element => element.scrollIntoView(), element) } + async pressTab(): Promise { + return this.remote.getActiveElement().then(activeElement => activeElement.type(('\uE004'))) // TAB + } + async outerHTMLForSelector(selector: string): Promise { const element = await this.remote.findByCssSelector(selector) return this.evaluate(element => element.outerHTML, element) From 14c8fd0dcbe23c01a61abab12cf46a9ae57958b5 Mon Sep 17 00:00:00 2001 From: domchristie Date: Mon, 25 Jan 2021 16:05:13 -0800 Subject: [PATCH 02/14] Discern URLs with blank hash vs no hash. getAnchor returns an empty string for blank hashes (#) and undefined when no hash is set at all --- src/core/drive/visit.ts | 5 +++-- src/core/snapshot.ts | 4 ++-- src/core/url.ts | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 7ba354a54..6dd9df626 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -310,8 +310,9 @@ export class Visit implements FetchRequestDelegate { } scrollToAnchor() { - if (getAnchor(this.location) != null) { - this.view.scrollToAnchor(getAnchor(this.location)) + const anchor = getAnchor(this.location) + if (anchor != null) { + this.view.scrollToAnchor(anchor) return true } } diff --git a/src/core/snapshot.ts b/src/core/snapshot.ts index ba39867a4..7132c978a 100644 --- a/src/core/snapshot.ts +++ b/src/core/snapshot.ts @@ -9,11 +9,11 @@ export class Snapshot { return [ ...this.element.children ] } - hasAnchor(anchor: string) { + hasAnchor(anchor: string | undefined) { return this.getElementForAnchor(anchor) != null } - getElementForAnchor(anchor: string) { + getElementForAnchor(anchor: string | undefined) { try { return this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`) } catch { diff --git a/src/core/url.ts b/src/core/url.ts index 60e1d099c..9f9de0f28 100644 --- a/src/core/url.ts +++ b/src/core/url.ts @@ -12,8 +12,6 @@ export function getAnchor(url: URL) { return url.hash.slice(1) } else if (anchorMatch = url.href.match(/#(.*)$/)) { return anchorMatch[1] - } else { - return "" } } From e8e0557bd293bb1b9b012b416e27c3bb3664e313 Mon Sep 17 00:00:00 2001 From: domchristie Date: Thu, 21 Jan 2021 15:05:35 -0800 Subject: [PATCH 03/14] Prevent re-rendering when tapping same-page anchor --- src/core/drive/visit.ts | 39 ++++++++++++++++++++++++------ src/core/native/browser_adapter.ts | 1 + src/core/url.ts | 14 ++++++----- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 6dd9df626..cf9c51269 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -2,7 +2,7 @@ import { Adapter } from "../native/adapter" import { FetchMethod, FetchRequest, FetchRequestDelegate } from "../../http/fetch_request" import { FetchResponse } from "../../http/fetch_response" import { History } from "./history" -import { getAnchor } from "../url" +import { getAnchor, getRequestURL } from "../url" import { PageSnapshot } from "./page_snapshot" import { Action } from "../types" import { uuid } from "../../util" @@ -70,6 +70,7 @@ export class Visit implements FetchRequestDelegate { frame?: number historyChanged = false location: URL + isSamePage: boolean redirectedToLocation?: URL request?: FetchRequest response?: VisitResponse @@ -81,6 +82,11 @@ export class Visit implements FetchRequestDelegate { constructor(delegate: VisitDelegate, location: URL, restorationIdentifier: string | undefined, options: Partial = {}) { this.delegate = delegate this.location = location + this.isSamePage = ( + getAnchor(location) != null && + getRequestURL(location) === getRequestURL(new URL(window.location.href)) + ) + this.restorationIdentifier = restorationIdentifier || uuid() const { action, historyChanged, referrer, snapshotHTML, response } = { ...defaultOptions, ...options } @@ -234,10 +240,14 @@ export class Visit implements FetchRequestDelegate { const isPreview = this.shouldIssueRequest() this.render(async () => { this.cacheSnapshot() - await this.view.renderPage(snapshot) - this.adapter.visitRendered(this) - if (!isPreview) { - this.complete() + if (this.isSamePage) { + this.adapter.visitRendered(this) + } else { + await this.view.renderPage(snapshot) + this.adapter.visitRendered(this) + if (!isPreview) { + this.complete() + } } }) } @@ -251,6 +261,15 @@ export class Visit implements FetchRequestDelegate { } } + goToSamePageAnchor() { + if (this.isSamePage) { + this.render(async () => { + this.cacheSnapshot() + this.adapter.visitRendered(this) + }) + } + } + // Fetch request delegate requestStarted() { @@ -346,9 +365,13 @@ export class Visit implements FetchRequestDelegate { } shouldIssueRequest() { - return this.action == "restore" - ? !this.hasCachedSnapshot() - : true + if (this.action == "restore") { + return !this.hasCachedSnapshot() + } else if (this.isSamePage) { + return false + } else { + return true + } } cacheSnapshot() { diff --git a/src/core/native/browser_adapter.ts b/src/core/native/browser_adapter.ts index 28348538d..ed79160c6 100644 --- a/src/core/native/browser_adapter.ts +++ b/src/core/native/browser_adapter.ts @@ -22,6 +22,7 @@ export class BrowserAdapter implements Adapter { visitStarted(visit: Visit) { visit.issueRequest() visit.changeHistory() + visit.goToSamePageAnchor() visit.loadCachedSnapshot() } diff --git a/src/core/url.ts b/src/core/url.ts index 9f9de0f28..f3f4f4647 100644 --- a/src/core/url.ts +++ b/src/core/url.ts @@ -28,13 +28,15 @@ export function isPrefixedBy(baseURL: URL, url: URL) { return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix) } +export function getRequestURL(url: URL) { + const anchor = getAnchor(url) + return anchor != null + ? url.href.slice(0, -(anchor.length + 1)) + : url.href +} + export function toCacheKey(url: URL) { - const anchorLength = url.hash.length - if (anchorLength < 2) { - return url.href - } else { - return url.href.slice(0, -anchorLength) - } + return getRequestURL(url) } function getPathComponents(url: URL) { From aa6b311357310e41af37cfdf3daa49a3f79d993f Mon Sep 17 00:00:00 2001 From: domchristie Date: Mon, 25 Jan 2021 17:56:39 -0800 Subject: [PATCH 04/14] Ensure correct focus when navigating to anchor --- src/core/view.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/view.ts b/src/core/view.ts index 3b5fd46c9..adb1ac8be 100644 --- a/src/core/view.ts +++ b/src/core/view.ts @@ -25,6 +25,7 @@ export abstract class View = Snapshot = Snapshot Date: Mon, 25 Jan 2021 17:58:05 -0800 Subject: [PATCH 05/14] Test page is not reloaded --- src/tests/functional/navigation_tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index 84f0dfe90..62add3ff0 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -118,10 +118,13 @@ export class NavigationTests extends TurboDriveTestCase { } async "test skip link with hash-only path"() { + const bodyElementId = (await this.body).elementId await this.clickSelector('a[href="#main"]') + await this.nextBeat this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") this.assert.equal(await this.hash, "#main") + this.assert.equal((await this.body).elementId, bodyElementId, "does not reload page") this.assert.ok(await this.isScrolledToSelector("#main")) await this.pressTab() From d22dee9be56279c7059296549bc5100ed78db488 Mon Sep 17 00:00:00 2001 From: domchristie Date: Mon, 25 Jan 2021 18:54:37 -0800 Subject: [PATCH 06/14] Fix navigating back to same page anchor --- src/core/drive/visit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index cf9c51269..8cbb85bf2 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -84,7 +84,7 @@ export class Visit implements FetchRequestDelegate { this.location = location this.isSamePage = ( getAnchor(location) != null && - getRequestURL(location) === getRequestURL(new URL(window.location.href)) + getRequestURL(location) === getRequestURL(this.view.lastRenderedLocation) ) this.restorationIdentifier = restorationIdentifier || uuid() From 4c753700e38bd585c09d97fb726beeb131279880 Mon Sep 17 00:00:00 2001 From: domchristie Date: Mon, 25 Jan 2021 19:34:07 -0800 Subject: [PATCH 07/14] Test navigating back to anchored location --- src/tests/functional/navigation_tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index 62add3ff0..7aef1cb93 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -134,6 +134,21 @@ export class NavigationTests extends TurboDriveTestCase { this.assert.notOk(await activeElement.equals(skippedLink), "skips interactive elements before #main") this.assert.ok(await activeElement.equals(firstLinkWithinMain), "skips to first interactive element after #main") } + + async "test navigating back to anchored URL"() { + await this.clickSelector('a[href="#main"]') + this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") + this.assert.equal(await this.hash, "#main") + this.assert.ok(await this.isScrolledToSelector("#main")) + + this.clickSelector("#same-origin-unannotated-link") + await this.nextBody + this.assert.equal(await this.pathname, "/src/tests/fixtures/one.html") + await this.goBack() + this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") + this.assert.equal(await this.hash, "#main") + this.assert.ok(await this.isScrolledToSelector("#main")) + } } NavigationTests.registerSuite() From ea16cf9fe0cb5df027e414b0044c2d28a6e6abdc Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Tue, 26 Jan 2021 09:28:45 -0500 Subject: [PATCH 08/14] pass along restorationIdentifier, split tests --- src/core/drive/visit.ts | 1 + src/core/native/browser_adapter.ts | 3 ++- src/core/session.ts | 4 ++-- src/tests/functional/navigation_tests.ts | 24 ++++++++++++----------- src/tests/helpers/functional_test_case.ts | 4 ++++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 8cbb85bf2..3d7a0c150 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -40,6 +40,7 @@ export type VisitOptions = { referrer?: URL, snapshotHTML?: string, response?: VisitResponse + restorationIdentifier?: string, } const defaultOptions: VisitOptions = { diff --git a/src/core/native/browser_adapter.ts b/src/core/native/browser_adapter.ts index ed79160c6..dc615f318 100644 --- a/src/core/native/browser_adapter.ts +++ b/src/core/native/browser_adapter.ts @@ -16,7 +16,8 @@ export class BrowserAdapter implements Adapter { } visitProposedToLocation(location: Locatable, options?: Partial) { - this.navigator.startVisit(location, uuid(), options) + const restorationIdentifier = options?.restorationIdentifier || uuid() + this.navigator.startVisit(location, restorationIdentifier, options) } visitStarted(visit: Visit) { diff --git a/src/core/session.ts b/src/core/session.ts index f12a7a8f7..0d0a099df 100644 --- a/src/core/session.ts +++ b/src/core/session.ts @@ -105,9 +105,9 @@ export class Session implements HistoryDelegate, LinkClickObserverDelegate, Navi // History delegate - historyPoppedToLocationWithRestorationIdentifier(location: URL) { + historyPoppedToLocationWithRestorationIdentifier(location: URL, restorationIdentifier: string) { if (this.enabled) { - this.navigator.proposeVisit(location, { action: "restore", historyChanged: true }) + this.navigator.proposeVisit(location, { action: "restore", historyChanged: true, restorationIdentifier }) } else { this.adapter.pageInvalidated() } diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index 7aef1cb93..101ca37ef 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -117,18 +117,23 @@ export class NavigationTests extends TurboDriveTestCase { this.assert.equal(await this.visitAction, "restore") } - async "test skip link with hash-only path"() { - const bodyElementId = (await this.body).elementId + async "test skip link with hash-only path scrolls to the anchor"() { await this.clickSelector('a[href="#main"]') - await this.nextBeat + this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") this.assert.equal(await this.hash, "#main") - this.assert.equal((await this.body).elementId, bodyElementId, "does not reload page") + this.assert.notOk(await this.changedBody, "does not reload page") this.assert.ok(await this.isScrolledToSelector("#main")) + } + async "test skip link with hash-only path moves focus and changes tab order"() { + await this.clickSelector('a[href="#main"]') + await this.nextBeat await this.pressTab() - const activeElement = await this.remote.getActiveElement() + await this.nextBeat + + const activeElement = await this.getActiveElement() const skippedLink = await this.querySelector("#ignored-link") const firstLinkWithinMain = await this.querySelector("#main a:first-of-type") this.assert.notOk(await activeElement.equals(skippedLink), "skips interactive elements before #main") @@ -137,14 +142,11 @@ export class NavigationTests extends TurboDriveTestCase { async "test navigating back to anchored URL"() { await this.clickSelector('a[href="#main"]') - this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") - this.assert.equal(await this.hash, "#main") - this.assert.ok(await this.isScrolledToSelector("#main")) - - this.clickSelector("#same-origin-unannotated-link") + await this.clickSelector("#same-origin-unannotated-link") await this.nextBody - this.assert.equal(await this.pathname, "/src/tests/fixtures/one.html") await this.goBack() + await this.nextBody + this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") this.assert.equal(await this.hash, "#main") this.assert.ok(await this.isScrolledToSelector("#main")) diff --git a/src/tests/helpers/functional_test_case.ts b/src/tests/helpers/functional_test_case.ts index dd0b3b9c0..ab56bddb4 100644 --- a/src/tests/helpers/functional_test_case.ts +++ b/src/tests/helpers/functional_test_case.ts @@ -82,6 +82,10 @@ export class FunctionalTestCase extends InternTestCase { return this.evaluate(() => document.body as any) } + async getActiveElement() { + return await this.remote.getActiveElement() + } + get location(): Promise { return this.evaluate(() => location.toString()) } From 078e59740b0d51d601ea60a8d9333db9aad5da4e Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Tue, 26 Jan 2021 11:05:37 -0500 Subject: [PATCH 09/14] try to get tests passing --- src/tests/fixtures/navigation.html | 2 +- src/tests/functional/navigation_tests.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tests/fixtures/navigation.html b/src/tests/fixtures/navigation.html index 245db17f7..5666a62cb 100644 --- a/src/tests/fixtures/navigation.html +++ b/src/tests/fixtures/navigation.html @@ -11,7 +11,7 @@ Skipped Content -
+

Navigation

Same-origin unannotated link

Same-origin data-turbo-action=replace link

diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index 101ca37ef..bfe8d6b37 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -121,23 +121,23 @@ export class NavigationTests extends TurboDriveTestCase { await this.clickSelector('a[href="#main"]') await this.nextBeat + const scrolledToMain = await this.isScrolledToSelector("#main") this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") this.assert.equal(await this.hash, "#main") this.assert.notOk(await this.changedBody, "does not reload page") - this.assert.ok(await this.isScrolledToSelector("#main")) + this.assert.ok(scrolledToMain, "scrolled to #main") } async "test skip link with hash-only path moves focus and changes tab order"() { await this.clickSelector('a[href="#main"]') - await this.nextBeat await this.pressTab() - await this.nextBeat const activeElement = await this.getActiveElement() - const skippedLink = await this.querySelector("#ignored-link") - const firstLinkWithinMain = await this.querySelector("#main a:first-of-type") - this.assert.notOk(await activeElement.equals(skippedLink), "skips interactive elements before #main") - this.assert.ok(await activeElement.equals(firstLinkWithinMain), "skips to first interactive element after #main") + const equalsSkippedLink = await activeElement.equals(await this.querySelector("#ignored-link")) + const equalsFirstLinkWithinMain = await activeElement.equals(await this.querySelector("#main a:first-of-type")) + + this.assert.notOk(equalsSkippedLink, "skips interactive elements before #main") + this.assert.ok(equalsFirstLinkWithinMain, "skips to first interactive element after #main") } async "test navigating back to anchored URL"() { @@ -147,9 +147,10 @@ export class NavigationTests extends TurboDriveTestCase { await this.goBack() await this.nextBody + const scrolledToMain = await this.isScrolledToSelector("#main") this.assert.equal(await this.pathname, "/src/tests/fixtures/navigation.html") this.assert.equal(await this.hash, "#main") - this.assert.ok(await this.isScrolledToSelector("#main")) + this.assert.ok(scrolledToMain, "scrolled to #main") } } From c84ad01a9ece7795b0380d72ae9a5a55105f698f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Uysal?= Date: Wed, 3 Feb 2021 22:04:41 +0300 Subject: [PATCH 10/14] Avoid request on same page --- src/core/drive/visit.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 3d7a0c150..433e3dab4 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -366,10 +366,10 @@ export class Visit implements FetchRequestDelegate { } shouldIssueRequest() { - if (this.action == "restore") { - return !this.hasCachedSnapshot() - } else if (this.isSamePage) { + if (this.isSamePage) { return false + } else if (this.action == "restore") { + return !this.hasCachedSnapshot() } else { return true } From 426fe277615ce294f6da5ff1470e4abff31bd7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Uysal?= Date: Sun, 20 Jun 2021 18:12:33 +0300 Subject: [PATCH 11/14] Add mising comma --- src/core/drive/visit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 433e3dab4..5091ff126 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -39,7 +39,7 @@ export type VisitOptions = { historyChanged: boolean, referrer?: URL, snapshotHTML?: string, - response?: VisitResponse + response?: VisitResponse, restorationIdentifier?: string, } From 19c2420fdf24e8b3cbadb059584bd648a098b1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Uysal?= Date: Sun, 20 Jun 2021 18:31:07 +0300 Subject: [PATCH 12/14] Attempts to fx conflicts --- src/core/drive/visit.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 5091ff126..a6263d6b7 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -241,14 +241,10 @@ export class Visit implements FetchRequestDelegate { const isPreview = this.shouldIssueRequest() this.render(async () => { this.cacheSnapshot() - if (this.isSamePage) { - this.adapter.visitRendered(this) - } else { - await this.view.renderPage(snapshot) - this.adapter.visitRendered(this) - if (!isPreview) { - this.complete() - } + await this.view.renderPage(snapshot, isPreview) + this.adapter.visitRendered(this) + if (!isPreview) { + this.complete() } }) } @@ -330,9 +326,8 @@ export class Visit implements FetchRequestDelegate { } scrollToAnchor() { - const anchor = getAnchor(this.location) - if (anchor != null) { - this.view.scrollToAnchor(anchor) + if (getAnchor(this.location)) { + this.view.scrollToAnchor(getAnchor(this.location) as string) return true } } From 2d7e8b217708133c939c419093fd8be768dfd582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Uysal?= Date: Sun, 20 Jun 2021 18:32:28 +0300 Subject: [PATCH 13/14] Fix conflict --- src/core/drive/visit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index a6263d6b7..97c68093e 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -327,7 +327,7 @@ export class Visit implements FetchRequestDelegate { scrollToAnchor() { if (getAnchor(this.location)) { - this.view.scrollToAnchor(getAnchor(this.location) as string) + this.view.scrollToAnchor(getAnchor(this.location)) return true } } From f03079fd4864d13d4ef63a58d0280c1709ce10e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Uysal?= Date: Wed, 23 Jun 2021 21:26:07 +0300 Subject: [PATCH 14/14] Fix TS error --- src/core/drive/visit.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 97c68093e..99d3a597e 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -326,8 +326,10 @@ export class Visit implements FetchRequestDelegate { } scrollToAnchor() { - if (getAnchor(this.location)) { - this.view.scrollToAnchor(getAnchor(this.location)) + const anchor = getAnchor(this.location); + + if (anchor) { + this.view.scrollToAnchor(anchor) return true } }