Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support navigating a Frame to its current src #248

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/core/frames/frame_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
formSubmission?: FormSubmission
private resolveVisitPromise = () => {}
private connected = false
private hasBeenLoaded = false
private willEagerLoad = true
private settingSourceURL = false

constructor(element: FrameElement) {
Expand All @@ -38,6 +38,7 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
if (!this.connected) {
this.connected = true
if (this.loadingStyle == FrameLoadingStyle.lazy) {
this.willEagerLoad = false
this.appearanceObserver.start()
}
this.linkInterceptor.start()
Expand All @@ -62,7 +63,7 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
}

sourceURLChanged() {
if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) {
if (this.loadingStyle == FrameLoadingStyle.eager || this.willEagerLoad) {
this.loadSourceURL()
}
}
Expand All @@ -85,7 +86,6 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
this.element.loaded = this.visit(this.sourceURL)
this.appearanceObserver.stop()
await this.element.loaded
this.hasBeenLoaded = true
} catch (error) {
this.currentURL = previousURL
throw error
Expand Down Expand Up @@ -116,6 +116,7 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
// Appearance observer delegate

elementAppearedInViewport(element: Element) {
this.willEagerLoad = true
this.loadSourceURL()
}

Expand Down Expand Up @@ -312,6 +313,7 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest
set sourceURL(sourceURL: string | undefined) {
this.settingSourceURL = true
this.element.src = sourceURL ?? null
this.currentURL = sourceURL
this.settingSourceURL = false
}

Expand Down