Skip to content

Commit

Permalink
Do not dispatch visit events on non-rendering Visits
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Oct 26, 2023
1 parent f86a376 commit e3fd039
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/core/drive/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Visit {
}

get silent() {
return this.isSamePage
return this.isSamePage || !this.willRender
}

start() {
Expand Down Expand Up @@ -130,10 +130,8 @@ export class Visit {
this.state = VisitState.completed
this.followRedirect()

if (!this.followedRedirect) {
this.adapter.visitCompleted(this)
this.delegate.visitCompleted(this)
}
this.adapter.visitCompleted(this)
this.delegate.visitCompleted(this)
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ export class Session {

visitCompleted(visit) {
clearBusyState(document.documentElement)
this.notifyApplicationAfterPageLoad(visit.getTimingMetrics())
if (!visit.silent) {
this.notifyApplicationAfterPageLoad(visit.getTimingMetrics())
}
}

locationWithActionIsSamePage(location, action) {
Expand Down Expand Up @@ -250,6 +252,8 @@ export class Session {
}

allowsImmediateRender({ element }, isPreview, options) {
if (this.navigator.currentVisit?.silent) return true

const event = this.notifyApplicationBeforeRender(element, isPreview, options)
const {
defaultPrevented,
Expand All @@ -265,7 +269,9 @@ export class Session {

viewRenderedSnapshot(_snapshot, isPreview) {
this.view.lastRenderedLocation = this.history.location
this.notifyApplicationAfterRender(isPreview)
if (!this.navigator.currentVisit?.silent) {
this.notifyApplicationAfterRender(isPreview)
}
}

preloadOnLoadLinksForView(element) {
Expand Down

0 comments on commit e3fd039

Please sign in to comment.