From 1c629b4705805dc8b0393eeafcd841ed73ce2ad1 Mon Sep 17 00:00:00 2001 From: Dom Christie Date: Mon, 25 Sep 2023 21:46:21 +0100 Subject: [PATCH] Tidy notifier method signatures --- src/core/session.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/session.js b/src/core/session.js index fff40cd7c..29b4721c2 100644 --- a/src/core/session.js +++ b/src/core/session.js @@ -192,7 +192,8 @@ export class Session { } extendURLWithDeprecatedProperties(visit.location) if (!visit.silent) { - this.notifyApplicationAfterVisitingLocation(visit.location, visit.action, visit.direction, visit.initiator) + const options = { action, direction, initiator } = visit + this.notifyApplicationAfterVisitingLocation(visit.location, options) } } @@ -298,7 +299,7 @@ export class Session { } applicationAllowsVisitingLocation(location, options) { - const event = this.notifyApplicationBeforeVisitingLocation(location, options.initiator) + const event = this.notifyApplicationBeforeVisitingLocation(location, options) return !event.defaultPrevented } @@ -310,15 +311,16 @@ export class Session { }) } - notifyApplicationBeforeVisitingLocation(location, target) { + notifyApplicationBeforeVisitingLocation(location, options = {}) { return dispatch("turbo:before-visit", { - target, + target: options.initiator, detail: { url: location.href }, cancelable: true }) } - notifyApplicationAfterVisitingLocation(location, action, direction, target) { + notifyApplicationAfterVisitingLocation(location, options = {}) { + const { action, direction, initiator: target } = options return dispatch("turbo:visit", { target, detail: { url: location.href, action, direction } }) }