@hotwired/turbo-rails 7.2.0-rc.3 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2115,8 +2115,8 @@ class FrameRedirector {
2115
2115
  this.linkClickObserver.stop();
2116
2116
  this.formSubmitObserver.stop();
2117
2117
  }
2118
- willFollowLinkToLocation(element) {
2119
- return this.shouldRedirect(element);
2118
+ willFollowLinkToLocation(element, location, event) {
2119
+ return this.shouldRedirect(element) && this.frameAllowsVisitingLocation(element, location, event);
2120
2120
  }
2121
2121
  followedLinkToLocation(element, url) {
2122
2122
  const frame = this.findFrameElement(element);
@@ -2133,6 +2133,17 @@ class FrameRedirector {
2133
2133
  frame.delegate.formSubmitted(element, submitter);
2134
2134
  }
2135
2135
  }
2136
+ frameAllowsVisitingLocation(target, {href: url}, originalEvent) {
2137
+ const event = dispatch("turbo:click", {
2138
+ target: target,
2139
+ detail: {
2140
+ url: url,
2141
+ originalEvent: originalEvent
2142
+ },
2143
+ cancelable: true
2144
+ });
2145
+ return !event.defaultPrevented;
2146
+ }
2136
2147
  shouldSubmit(form, submitter) {
2137
2148
  var _a;
2138
2149
  const action = getAction(form, submitter);
@@ -3395,8 +3406,8 @@ class FrameController {
3395
3406
  const frame = this.findFrameElement(link);
3396
3407
  if (frame) form.setAttribute("data-turbo-frame", frame.id);
3397
3408
  }
3398
- willFollowLinkToLocation(element) {
3399
- return this.shouldInterceptNavigation(element);
3409
+ willFollowLinkToLocation(element, location, event) {
3410
+ return this.shouldInterceptNavigation(element) && this.frameAllowsVisitingLocation(element, location, event);
3400
3411
  }
3401
3412
  followedLinkToLocation(element, location) {
3402
3413
  this.navigateFrame(element, location.href);
@@ -3660,6 +3671,17 @@ class FrameController {
3660
3671
  const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/";
3661
3672
  return expandURL(root);
3662
3673
  }
3674
+ frameAllowsVisitingLocation(target, {href: url}, originalEvent) {
3675
+ const event = dispatch("turbo:click", {
3676
+ target: target,
3677
+ detail: {
3678
+ url: url,
3679
+ originalEvent: originalEvent
3680
+ },
3681
+ cancelable: true
3682
+ });
3683
+ return !event.defaultPrevented;
3684
+ }
3663
3685
  isIgnoringChangesTo(attributeName) {
3664
3686
  return this.ignoredAttributes.has(attributeName);
3665
3687
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo-rails",
3
- "version": "7.2.0-rc.3",
3
+ "version": "7.2.0",
4
4
  "description": "The speed of a single-page web application without having to write any JavaScript",
5
5
  "module": "app/javascript/turbo/index.js",
6
6
  "main": "app/assets/javascripts/turbo.js",
@@ -13,7 +13,7 @@
13
13
  "release": "npm publish && git commit -am \"$npm_package_name v$npm_package_version\" && git push"
14
14
  },
15
15
  "dependencies": {
16
- "@hotwired/turbo": "^7.2.0-rc.3",
16
+ "@hotwired/turbo": "^7.2.0",
17
17
  "@rails/actioncable": "^7.0"
18
18
  },
19
19
  "devDependencies": {