@hotwired/turbo 8.0.1 → 8.0.2
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.
- package/dist/turbo.es2017-esm.js +38 -40
- package/dist/turbo.es2017-umd.js +38 -40
- package/package.json +1 -1
package/dist/turbo.es2017-esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Turbo 8.0.
|
|
2
|
+
Turbo 8.0.2
|
|
3
3
|
Copyright © 2024 37signals LLC
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -3191,10 +3191,6 @@ class LinkPrefetchObserver {
|
|
|
3191
3191
|
if (turboFrameTarget && turboFrameTarget !== "_top") {
|
|
3192
3192
|
request.headers["Turbo-Frame"] = turboFrameTarget;
|
|
3193
3193
|
}
|
|
3194
|
-
|
|
3195
|
-
if (link.hasAttribute("data-turbo-stream")) {
|
|
3196
|
-
request.acceptResponseType(StreamMessage.contentType);
|
|
3197
|
-
}
|
|
3198
3194
|
}
|
|
3199
3195
|
|
|
3200
3196
|
// Fetch request interface
|
|
@@ -3218,52 +3214,54 @@ class LinkPrefetchObserver {
|
|
|
3218
3214
|
#isPrefetchable(link) {
|
|
3219
3215
|
const href = link.getAttribute("href");
|
|
3220
3216
|
|
|
3221
|
-
if (!href
|
|
3222
|
-
return false
|
|
3223
|
-
}
|
|
3217
|
+
if (!href) return false
|
|
3224
3218
|
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3219
|
+
if (unfetchableLink(link)) return false
|
|
3220
|
+
if (linkToTheSamePage(link)) return false
|
|
3221
|
+
if (linkOptsOut(link)) return false
|
|
3222
|
+
if (nonSafeLink(link)) return false
|
|
3223
|
+
if (eventPrevented(link)) return false
|
|
3229
3224
|
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3225
|
+
return true
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3233
3228
|
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3229
|
+
const unfetchableLink = (link) => {
|
|
3230
|
+
return link.origin !== document.location.origin || !["http:", "https:"].includes(link.protocol) || link.hasAttribute("target")
|
|
3231
|
+
};
|
|
3237
3232
|
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3233
|
+
const linkToTheSamePage = (link) => {
|
|
3234
|
+
return (link.pathname + link.search === document.location.pathname + document.location.search) || link.href.startsWith("#")
|
|
3235
|
+
};
|
|
3241
3236
|
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3237
|
+
const linkOptsOut = (link) => {
|
|
3238
|
+
if (link.getAttribute("data-turbo-prefetch") === "false") return true
|
|
3239
|
+
if (link.getAttribute("data-turbo") === "false") return true
|
|
3245
3240
|
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
return false
|
|
3249
|
-
}
|
|
3241
|
+
const turboPrefetchParent = findClosestRecursively(link, "[data-turbo-prefetch]");
|
|
3242
|
+
if (turboPrefetchParent && turboPrefetchParent.getAttribute("data-turbo-prefetch") === "false") return true
|
|
3250
3243
|
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
}
|
|
3244
|
+
return false
|
|
3245
|
+
};
|
|
3254
3246
|
|
|
3255
|
-
|
|
3247
|
+
const nonSafeLink = (link) => {
|
|
3248
|
+
const turboMethod = link.getAttribute("data-turbo-method");
|
|
3249
|
+
if (turboMethod && turboMethod.toLowerCase() !== "get") return true
|
|
3256
3250
|
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3251
|
+
if (isUJS(link)) return true
|
|
3252
|
+
if (link.hasAttribute("data-turbo-confirm")) return true
|
|
3253
|
+
if (link.hasAttribute("data-turbo-stream")) return true
|
|
3260
3254
|
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3255
|
+
return false
|
|
3256
|
+
};
|
|
3257
|
+
|
|
3258
|
+
const isUJS = (link) => {
|
|
3259
|
+
return link.hasAttribute("data-remote") || link.hasAttribute("data-behavior") || link.hasAttribute("data-confirm") || link.hasAttribute("data-method")
|
|
3260
|
+
};
|
|
3264
3261
|
|
|
3265
|
-
const
|
|
3266
|
-
|
|
3262
|
+
const eventPrevented = (link) => {
|
|
3263
|
+
const event = dispatch("turbo:before-prefetch", { target: link, cancelable: true });
|
|
3264
|
+
return event.defaultPrevented
|
|
3267
3265
|
};
|
|
3268
3266
|
|
|
3269
3267
|
class Navigator {
|
package/dist/turbo.es2017-umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Turbo 8.0.
|
|
2
|
+
Turbo 8.0.2
|
|
3
3
|
Copyright © 2024 37signals LLC
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -3197,10 +3197,6 @@ Copyright © 2024 37signals LLC
|
|
|
3197
3197
|
if (turboFrameTarget && turboFrameTarget !== "_top") {
|
|
3198
3198
|
request.headers["Turbo-Frame"] = turboFrameTarget;
|
|
3199
3199
|
}
|
|
3200
|
-
|
|
3201
|
-
if (link.hasAttribute("data-turbo-stream")) {
|
|
3202
|
-
request.acceptResponseType(StreamMessage.contentType);
|
|
3203
|
-
}
|
|
3204
3200
|
}
|
|
3205
3201
|
|
|
3206
3202
|
// Fetch request interface
|
|
@@ -3224,52 +3220,54 @@ Copyright © 2024 37signals LLC
|
|
|
3224
3220
|
#isPrefetchable(link) {
|
|
3225
3221
|
const href = link.getAttribute("href");
|
|
3226
3222
|
|
|
3227
|
-
if (!href
|
|
3228
|
-
return false
|
|
3229
|
-
}
|
|
3223
|
+
if (!href) return false
|
|
3230
3224
|
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3225
|
+
if (unfetchableLink(link)) return false
|
|
3226
|
+
if (linkToTheSamePage(link)) return false
|
|
3227
|
+
if (linkOptsOut(link)) return false
|
|
3228
|
+
if (nonSafeLink(link)) return false
|
|
3229
|
+
if (eventPrevented(link)) return false
|
|
3235
3230
|
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3231
|
+
return true
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3239
3234
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3235
|
+
const unfetchableLink = (link) => {
|
|
3236
|
+
return link.origin !== document.location.origin || !["http:", "https:"].includes(link.protocol) || link.hasAttribute("target")
|
|
3237
|
+
};
|
|
3243
3238
|
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3239
|
+
const linkToTheSamePage = (link) => {
|
|
3240
|
+
return (link.pathname + link.search === document.location.pathname + document.location.search) || link.href.startsWith("#")
|
|
3241
|
+
};
|
|
3247
3242
|
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3243
|
+
const linkOptsOut = (link) => {
|
|
3244
|
+
if (link.getAttribute("data-turbo-prefetch") === "false") return true
|
|
3245
|
+
if (link.getAttribute("data-turbo") === "false") return true
|
|
3251
3246
|
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
return false
|
|
3255
|
-
}
|
|
3247
|
+
const turboPrefetchParent = findClosestRecursively(link, "[data-turbo-prefetch]");
|
|
3248
|
+
if (turboPrefetchParent && turboPrefetchParent.getAttribute("data-turbo-prefetch") === "false") return true
|
|
3256
3249
|
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
}
|
|
3250
|
+
return false
|
|
3251
|
+
};
|
|
3260
3252
|
|
|
3261
|
-
|
|
3253
|
+
const nonSafeLink = (link) => {
|
|
3254
|
+
const turboMethod = link.getAttribute("data-turbo-method");
|
|
3255
|
+
if (turboMethod && turboMethod.toLowerCase() !== "get") return true
|
|
3262
3256
|
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3257
|
+
if (isUJS(link)) return true
|
|
3258
|
+
if (link.hasAttribute("data-turbo-confirm")) return true
|
|
3259
|
+
if (link.hasAttribute("data-turbo-stream")) return true
|
|
3266
3260
|
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3261
|
+
return false
|
|
3262
|
+
};
|
|
3263
|
+
|
|
3264
|
+
const isUJS = (link) => {
|
|
3265
|
+
return link.hasAttribute("data-remote") || link.hasAttribute("data-behavior") || link.hasAttribute("data-confirm") || link.hasAttribute("data-method")
|
|
3266
|
+
};
|
|
3270
3267
|
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3268
|
+
const eventPrevented = (link) => {
|
|
3269
|
+
const event = dispatch("turbo:before-prefetch", { target: link, cancelable: true });
|
|
3270
|
+
return event.defaultPrevented
|
|
3273
3271
|
};
|
|
3274
3272
|
|
|
3275
3273
|
class Navigator {
|
package/package.json
CHANGED