@hotwired/turbo 8.0.0-rc.2 → 8.0.0-rc.3

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Turbo 8.0.0-rc.2
2
+ Turbo 8.0.0-rc.3
3
3
  Copyright © 2024 37signals LLC
4
4
  */
5
5
  /**
@@ -3132,7 +3132,7 @@ class LinkPrefetchObserver {
3132
3132
  }
3133
3133
 
3134
3134
  #tryToPrefetchRequest = (event) => {
3135
- if (getMetaContent("turbo-prefetch") !== "true") return
3135
+ if (getMetaContent("turbo-prefetch") === "false") return
3136
3136
 
3137
3137
  const target = event.target;
3138
3138
  const isLink = target.matches && target.matches("a[href]:not([target^=_]):not([download])");
@@ -3208,7 +3208,16 @@ class LinkPrefetchObserver {
3208
3208
  #isPrefetchable(link) {
3209
3209
  const href = link.getAttribute("href");
3210
3210
 
3211
- if (!href || href === "#" || link.getAttribute("data-turbo") === "false" || link.getAttribute("data-turbo-prefetch") === "false") {
3211
+ if (!href || href.startsWith("#") || link.getAttribute("data-turbo") === "false" || link.getAttribute("data-turbo-prefetch") === "false") {
3212
+ return false
3213
+ }
3214
+
3215
+ const event = dispatch("turbo:before-prefetch", {
3216
+ target: link,
3217
+ cancelable: true
3218
+ });
3219
+
3220
+ if (event.defaultPrevented) {
3212
3221
  return false
3213
3222
  }
3214
3223
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Turbo 8.0.0-rc.2
2
+ Turbo 8.0.0-rc.3
3
3
  Copyright © 2024 37signals LLC
4
4
  */
5
5
  (function (global, factory) {
@@ -3138,7 +3138,7 @@ Copyright © 2024 37signals LLC
3138
3138
  }
3139
3139
 
3140
3140
  #tryToPrefetchRequest = (event) => {
3141
- if (getMetaContent("turbo-prefetch") !== "true") return
3141
+ if (getMetaContent("turbo-prefetch") === "false") return
3142
3142
 
3143
3143
  const target = event.target;
3144
3144
  const isLink = target.matches && target.matches("a[href]:not([target^=_]):not([download])");
@@ -3214,7 +3214,16 @@ Copyright © 2024 37signals LLC
3214
3214
  #isPrefetchable(link) {
3215
3215
  const href = link.getAttribute("href");
3216
3216
 
3217
- if (!href || href === "#" || link.getAttribute("data-turbo") === "false" || link.getAttribute("data-turbo-prefetch") === "false") {
3217
+ if (!href || href.startsWith("#") || link.getAttribute("data-turbo") === "false" || link.getAttribute("data-turbo-prefetch") === "false") {
3218
+ return false
3219
+ }
3220
+
3221
+ const event = dispatch("turbo:before-prefetch", {
3222
+ target: link,
3223
+ cancelable: true
3224
+ });
3225
+
3226
+ if (event.defaultPrevented) {
3218
3227
  return false
3219
3228
  }
3220
3229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "8.0.0-rc.2",
3
+ "version": "8.0.0-rc.3",
4
4
  "description": "The speed of a single-page web application without having to write any JavaScript",
5
5
  "module": "dist/turbo.es2017-esm.js",
6
6
  "main": "dist/turbo.es2017-umd.js",