turbo-rails 2.0.10 → 2.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/turbo.js +27 -20
- data/app/assets/javascripts/turbo.min.js +6 -6
- data/app/assets/javascripts/turbo.min.js.map +1 -1
- data/app/channels/turbo/streams/broadcasts.rb +2 -2
- data/app/controllers/turbo/native/navigation.rb +11 -8
- data/lib/turbo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caaac3cb2273385e8f6ce553077cda24dfe79dec5b67c01aa2895b9c0053ea55
|
4
|
+
data.tar.gz: 95760946d353827c09cd57d9f88a678ea56f21f3365a78df5b996ee654bffbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d447ead41f0524f3177e4d25a4b7085bc282de2b66234f4a01cf515b00600959172c23bf9d0640929e460246b511d08e55f262b5e2901aadc2bc8add5ade9c
|
7
|
+
data.tar.gz: e822ce8f0ada6d357a4ba28787d8d62dcbfa29001d84239abd026ee6808cf8adfdb4be9b054a3f60b6091b21bff00980ebcb3847dc34fe7932100d6366990278
|
data/README.md
CHANGED
@@ -127,7 +127,7 @@ If the call to `Message#save!` executes quickly enough, it might beat-out any
|
|
127
127
|
Messages"`.
|
128
128
|
|
129
129
|
To wait for any disconnected `<turbo-cable-stream-source>` elements to connect,
|
130
|
-
call [`#connect_turbo_cable_stream_sources`](
|
130
|
+
call [`#connect_turbo_cable_stream_sources`](https://github.com/hotwired/turbo-rails/blob/main/lib/turbo/system_test_helper.rb):
|
131
131
|
|
132
132
|
```diff
|
133
133
|
test "renders broadcasted Messages" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
Turbo 8.0.
|
2
|
+
Turbo 8.0.12
|
3
3
|
Copyright © 2024 37signals LLC
|
4
4
|
*/
|
5
5
|
(function(prototype) {
|
@@ -181,7 +181,7 @@ function activateScriptElement(element) {
|
|
181
181
|
return element;
|
182
182
|
} else {
|
183
183
|
const createdScriptElement = document.createElement("script");
|
184
|
-
const cspNonce =
|
184
|
+
const cspNonce = getCspNonce();
|
185
185
|
if (cspNonce) {
|
186
186
|
createdScriptElement.nonce = cspNonce;
|
187
187
|
}
|
@@ -353,6 +353,14 @@ function getMetaContent(name) {
|
|
353
353
|
return element && element.content;
|
354
354
|
}
|
355
355
|
|
356
|
+
function getCspNonce() {
|
357
|
+
const element = getMetaElement("csp-nonce");
|
358
|
+
if (element) {
|
359
|
+
const {nonce: nonce, content: content} = element;
|
360
|
+
return nonce == "" ? content : nonce;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
356
364
|
function setMetaContent(name, content) {
|
357
365
|
let element = getMetaElement(name);
|
358
366
|
if (!element) {
|
@@ -1531,12 +1539,13 @@ function createPlaceholderForPermanentElement(permanentElement) {
|
|
1531
1539
|
|
1532
1540
|
class Renderer {
|
1533
1541
|
#activeElement=null;
|
1534
|
-
|
1542
|
+
static renderElement(currentElement, newElement) {}
|
1543
|
+
constructor(currentSnapshot, newSnapshot, isPreview, willRender = true) {
|
1535
1544
|
this.currentSnapshot = currentSnapshot;
|
1536
1545
|
this.newSnapshot = newSnapshot;
|
1537
1546
|
this.isPreview = isPreview;
|
1538
1547
|
this.willRender = willRender;
|
1539
|
-
this.renderElement = renderElement;
|
1548
|
+
this.renderElement = this.constructor.renderElement;
|
1540
1549
|
this.promise = new Promise(((resolve, reject) => this.resolvingFunctions = {
|
1541
1550
|
resolve: resolve,
|
1542
1551
|
reject: reject
|
@@ -2289,6 +2298,9 @@ class MorphingFrameRenderer extends FrameRenderer {
|
|
2289
2298
|
});
|
2290
2299
|
morphChildren(currentElement, newElement);
|
2291
2300
|
}
|
2301
|
+
async preservingPermanentElements(callback) {
|
2302
|
+
return await callback();
|
2303
|
+
}
|
2292
2304
|
}
|
2293
2305
|
|
2294
2306
|
class ProgressBar {
|
@@ -2380,8 +2392,9 @@ class ProgressBar {
|
|
2380
2392
|
const element = document.createElement("style");
|
2381
2393
|
element.type = "text/css";
|
2382
2394
|
element.textContent = ProgressBar.defaultCSS;
|
2383
|
-
|
2384
|
-
|
2395
|
+
const cspNonce = getCspNonce();
|
2396
|
+
if (cspNonce) {
|
2397
|
+
element.nonce = cspNonce;
|
2385
2398
|
}
|
2386
2399
|
return element;
|
2387
2400
|
}
|
@@ -2390,9 +2403,6 @@ class ProgressBar {
|
|
2390
2403
|
element.className = "turbo-progress-bar";
|
2391
2404
|
return element;
|
2392
2405
|
}
|
2393
|
-
get cspNonce() {
|
2394
|
-
return getMetaContent("csp-nonce");
|
2395
|
-
}
|
2396
2406
|
}
|
2397
2407
|
|
2398
2408
|
class HeadSnapshot extends Snapshot {
|
@@ -4013,7 +4023,7 @@ class PageView extends View {
|
|
4013
4023
|
renderPage(snapshot, isPreview = false, willRender = true, visit) {
|
4014
4024
|
const shouldMorphPage = this.isPageRefresh(visit) && this.snapshot.shouldMorphPage;
|
4015
4025
|
const rendererClass = shouldMorphPage ? MorphingPageRenderer : PageRenderer;
|
4016
|
-
const renderer = new rendererClass(this.snapshot, snapshot,
|
4026
|
+
const renderer = new rendererClass(this.snapshot, snapshot, isPreview, willRender);
|
4017
4027
|
if (!renderer.shouldRender) {
|
4018
4028
|
this.forceReloaded = true;
|
4019
4029
|
} else {
|
@@ -4023,7 +4033,7 @@ class PageView extends View {
|
|
4023
4033
|
}
|
4024
4034
|
renderError(snapshot, visit) {
|
4025
4035
|
visit?.changeHistory();
|
4026
|
-
const renderer = new ErrorRenderer(this.snapshot, snapshot,
|
4036
|
+
const renderer = new ErrorRenderer(this.snapshot, snapshot, false);
|
4027
4037
|
return this.render(renderer);
|
4028
4038
|
}
|
4029
4039
|
clearSnapshotCache() {
|
@@ -4589,6 +4599,7 @@ class FrameController {
|
|
4589
4599
|
#connected=false;
|
4590
4600
|
#hasBeenLoaded=false;
|
4591
4601
|
#ignoredAttributes=new Set;
|
4602
|
+
#shouldMorphFrame=false;
|
4592
4603
|
action=null;
|
4593
4604
|
constructor(element) {
|
4594
4605
|
this.element = element;
|
@@ -4636,14 +4647,8 @@ class FrameController {
|
|
4636
4647
|
}
|
4637
4648
|
}
|
4638
4649
|
sourceURLReloaded() {
|
4639
|
-
|
4640
|
-
|
4641
|
-
detail.render = MorphingFrameRenderer.renderElement;
|
4642
|
-
}), {
|
4643
|
-
once: true
|
4644
|
-
});
|
4645
|
-
}
|
4646
|
-
const {src: src} = this.element;
|
4650
|
+
const {refresh: refresh, src: src} = this.element;
|
4651
|
+
this.#shouldMorphFrame = src && refresh === "morph";
|
4647
4652
|
this.element.removeAttribute("complete");
|
4648
4653
|
this.element.src = null;
|
4649
4654
|
this.element.src = src;
|
@@ -4681,6 +4686,7 @@ class FrameController {
|
|
4681
4686
|
}
|
4682
4687
|
}
|
4683
4688
|
} finally {
|
4689
|
+
this.#shouldMorphFrame = false;
|
4684
4690
|
this.fetchResponseLoaded = () => Promise.resolve();
|
4685
4691
|
}
|
4686
4692
|
}
|
@@ -4793,9 +4799,10 @@ class FrameController {
|
|
4793
4799
|
};
|
4794
4800
|
async #loadFrameResponse(fetchResponse, document) {
|
4795
4801
|
const newFrameElement = await this.extractForeignFrameElement(document.body);
|
4802
|
+
const rendererClass = this.#shouldMorphFrame ? MorphingFrameRenderer : FrameRenderer;
|
4796
4803
|
if (newFrameElement) {
|
4797
4804
|
const snapshot = new Snapshot(newFrameElement);
|
4798
|
-
const renderer = new
|
4805
|
+
const renderer = new rendererClass(this, this.view.snapshot, snapshot, false, false);
|
4799
4806
|
if (this.view.renderPromise) await this.view.renderPromise;
|
4800
4807
|
this.changeHistory();
|
4801
4808
|
await this.view.render(renderer);
|