Skip to content

Commit

Permalink
Contain VisitOption munging within Navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Sep 20, 2023
1 parent 4eed166 commit 3e49d80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/core/drive/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class Navigator {
proposeVisit(location, options = {}) {
if (this.delegate.allowsVisitingLocation(location, options)) {
if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {
this.withVisitOptions(options, () => {
this.delegate.visitProposedToLocation(location, options)
this.withTransferableVisitOptions(options, (transferableOptions) => {
this.delegate.visitProposedToLocation(location, transferableOptions)
})
} else {
window.location.href = location.toString()
Expand Down Expand Up @@ -160,9 +160,14 @@ export class Navigator {

// Private

withVisitOptions(options, callback) {
withTransferableVisitOptions(options, callback) {
this.currentVisitOptions = options
callback.call(this)
callback.call(this, this.sanitizeVisitOptionsForTransfer(options))
this.currentVisitOptions = {}
}

sanitizeVisitOptionsForTransfer(options) {
const { initiator, referrer, visitCachedSnapshot, ...rest } = options
return rest
}
}
7 changes: 1 addition & 6 deletions src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class Session {

visitProposedToLocation(location, options) {
extendURLWithDeprecatedProperties(location)
this.adapter.visitProposedToLocation(location, this.sanitizeVisitOptionsForTransfer(options))
this.adapter.visitProposedToLocation(location, options)
}

// Visit delegate
Expand Down Expand Up @@ -404,11 +404,6 @@ export class Session {
}
}

sanitizeVisitOptionsForTransfer(options) {
const { initiator, referrer, visitCachedSnapshot, ...rest } = options
return rest
}

// Private

getActionForLink(link) {
Expand Down

0 comments on commit 3e49d80

Please sign in to comment.