Skip to content

Commit

Permalink
Ensure all original VisitOptions are passed to Visit constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Sep 30, 2022
1 parent 066104d commit 122fd26
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/drive/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Navigator {
formSubmission?: FormSubmission
currentVisit?: Visit
lastVisit?: Visit
currentInitiator?: Element
currentVisitOptions?: Partial<VisitOptions>

constructor(delegate: NavigatorDelegate) {
this.delegate = delegate
Expand All @@ -27,7 +27,7 @@ export class Navigator {
proposeVisit(location: URL, options: Partial<VisitOptions> = {}) {
if (this.delegate.allowsVisitingLocation(location, options)) {
if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {
this.withInitiator(options.initiator, () => {
this.withVisitOptions(options, () => {
this.delegate.visitProposedToLocation(location, options)
})
} else {
Expand All @@ -40,8 +40,8 @@ export class Navigator {
this.lastVisit = this.currentVisit
this.stop()
this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, {
initiator: this.currentInitiator,
referrer: this.location,
...this.currentVisitOptions,
...options,
})
this.currentVisit.start()
Expand Down Expand Up @@ -179,9 +179,9 @@ export class Navigator {

// Private

withInitiator(initiator: Element | undefined, callback: () => void) {
this.currentInitiator = initiator
withVisitOptions(options: Partial<VisitOptions>, callback: () => void) {
this.currentVisitOptions = options
callback.call(this)
delete this.currentInitiator
delete this.currentVisitOptions
}
}

0 comments on commit 122fd26

Please sign in to comment.