@hotwired/turbo 8.0.0-beta.3 → 8.0.0-beta.4

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-beta.3
2
+ Turbo 8.0.0-beta.4
3
3
  Copyright © 2024 37signals LLC
4
4
  */
5
5
  /**
@@ -1937,8 +1937,6 @@ function readScrollBehavior(value, defaultValue) {
1937
1937
  }
1938
1938
  }
1939
1939
 
1940
- const ProgressBarID = "turbo-progress-bar";
1941
-
1942
1940
  class ProgressBar {
1943
1941
  static animationDuration = 300 /*ms*/
1944
1942
 
@@ -2043,8 +2041,6 @@ class ProgressBar {
2043
2041
 
2044
2042
  createStylesheetElement() {
2045
2043
  const element = document.createElement("style");
2046
- element.id = ProgressBarID;
2047
- element.setAttribute("data-turbo-permanent", "");
2048
2044
  element.type = "text/css";
2049
2045
  element.textContent = ProgressBar.defaultCSS;
2050
2046
  if (this.cspNonce) {
@@ -3173,14 +3169,11 @@ class LinkPrefetchObserver {
3173
3169
 
3174
3170
  request.headers["Sec-Purpose"] = "prefetch";
3175
3171
 
3176
- if (link.dataset.turboFrame && link.dataset.turboFrame !== "_top") {
3177
- request.headers["Turbo-Frame"] = link.dataset.turboFrame;
3178
- } else if (link.dataset.turboFrame !== "_top") {
3179
- const turboFrame = link.closest("turbo-frame");
3172
+ const turboFrame = link.closest("turbo-frame");
3173
+ const turboFrameTarget = link.getAttribute("data-turbo-frame") || turboFrame?.getAttribute("target") || turboFrame?.id;
3180
3174
 
3181
- if (turboFrame) {
3182
- request.headers["Turbo-Frame"] = turboFrame.id;
3183
- }
3175
+ if (turboFrameTarget && turboFrameTarget !== "_top") {
3176
+ request.headers["Turbo-Frame"] = turboFrameTarget;
3184
3177
  }
3185
3178
 
3186
3179
  if (link.hasAttribute("data-turbo-stream")) {
@@ -4717,7 +4710,7 @@ class PageRenderer extends Renderer {
4717
4710
  await newStylesheetElements;
4718
4711
 
4719
4712
  if (this.willRender) {
4720
- this.removeUnusedHeadStylesheetElements();
4713
+ this.removeUnusedDynamicStylesheetElements();
4721
4714
  }
4722
4715
  }
4723
4716
 
@@ -4750,8 +4743,8 @@ class PageRenderer extends Renderer {
4750
4743
  }
4751
4744
  }
4752
4745
 
4753
- removeUnusedHeadStylesheetElements() {
4754
- for (const element of this.unusedHeadStylesheetElements) {
4746
+ removeUnusedDynamicStylesheetElements() {
4747
+ for (const element of this.unusedDynamicStylesheetElements) {
4755
4748
  document.head.removeChild(element);
4756
4749
  }
4757
4750
  }
@@ -4821,13 +4814,9 @@ class PageRenderer extends Renderer {
4821
4814
  await this.renderElement(this.currentElement, this.newElement);
4822
4815
  }
4823
4816
 
4824
- get unusedHeadStylesheetElements() {
4817
+ get unusedDynamicStylesheetElements() {
4825
4818
  return this.oldHeadStylesheetElements.filter((element) => {
4826
- return !(element.hasAttribute("data-turbo-permanent") ||
4827
- // Trix dynamically adds styles to the head that we want to keep around which have a
4828
- // `data-tag-name` attribute. Long term we should moves those styles to Trix's CSS file
4829
- // but for now we'll just skip removing them
4830
- element.hasAttribute("data-tag-name"))
4819
+ return element.getAttribute("data-turbo-track") === "dynamic"
4831
4820
  })
4832
4821
  }
4833
4822
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Turbo 8.0.0-beta.3
2
+ Turbo 8.0.0-beta.4
3
3
  Copyright © 2024 37signals LLC
4
4
  */
5
5
  (function (global, factory) {
@@ -1943,8 +1943,6 @@ Copyright © 2024 37signals LLC
1943
1943
  }
1944
1944
  }
1945
1945
 
1946
- const ProgressBarID = "turbo-progress-bar";
1947
-
1948
1946
  class ProgressBar {
1949
1947
  static animationDuration = 300 /*ms*/
1950
1948
 
@@ -2049,8 +2047,6 @@ Copyright © 2024 37signals LLC
2049
2047
 
2050
2048
  createStylesheetElement() {
2051
2049
  const element = document.createElement("style");
2052
- element.id = ProgressBarID;
2053
- element.setAttribute("data-turbo-permanent", "");
2054
2050
  element.type = "text/css";
2055
2051
  element.textContent = ProgressBar.defaultCSS;
2056
2052
  if (this.cspNonce) {
@@ -3179,14 +3175,11 @@ Copyright © 2024 37signals LLC
3179
3175
 
3180
3176
  request.headers["Sec-Purpose"] = "prefetch";
3181
3177
 
3182
- if (link.dataset.turboFrame && link.dataset.turboFrame !== "_top") {
3183
- request.headers["Turbo-Frame"] = link.dataset.turboFrame;
3184
- } else if (link.dataset.turboFrame !== "_top") {
3185
- const turboFrame = link.closest("turbo-frame");
3178
+ const turboFrame = link.closest("turbo-frame");
3179
+ const turboFrameTarget = link.getAttribute("data-turbo-frame") || turboFrame?.getAttribute("target") || turboFrame?.id;
3186
3180
 
3187
- if (turboFrame) {
3188
- request.headers["Turbo-Frame"] = turboFrame.id;
3189
- }
3181
+ if (turboFrameTarget && turboFrameTarget !== "_top") {
3182
+ request.headers["Turbo-Frame"] = turboFrameTarget;
3190
3183
  }
3191
3184
 
3192
3185
  if (link.hasAttribute("data-turbo-stream")) {
@@ -4723,7 +4716,7 @@ Copyright © 2024 37signals LLC
4723
4716
  await newStylesheetElements;
4724
4717
 
4725
4718
  if (this.willRender) {
4726
- this.removeUnusedHeadStylesheetElements();
4719
+ this.removeUnusedDynamicStylesheetElements();
4727
4720
  }
4728
4721
  }
4729
4722
 
@@ -4756,8 +4749,8 @@ Copyright © 2024 37signals LLC
4756
4749
  }
4757
4750
  }
4758
4751
 
4759
- removeUnusedHeadStylesheetElements() {
4760
- for (const element of this.unusedHeadStylesheetElements) {
4752
+ removeUnusedDynamicStylesheetElements() {
4753
+ for (const element of this.unusedDynamicStylesheetElements) {
4761
4754
  document.head.removeChild(element);
4762
4755
  }
4763
4756
  }
@@ -4827,13 +4820,9 @@ Copyright © 2024 37signals LLC
4827
4820
  await this.renderElement(this.currentElement, this.newElement);
4828
4821
  }
4829
4822
 
4830
- get unusedHeadStylesheetElements() {
4823
+ get unusedDynamicStylesheetElements() {
4831
4824
  return this.oldHeadStylesheetElements.filter((element) => {
4832
- return !(element.hasAttribute("data-turbo-permanent") ||
4833
- // Trix dynamically adds styles to the head that we want to keep around which have a
4834
- // `data-tag-name` attribute. Long term we should moves those styles to Trix's CSS file
4835
- // but for now we'll just skip removing them
4836
- element.hasAttribute("data-tag-name"))
4825
+ return element.getAttribute("data-turbo-track") === "dynamic"
4837
4826
  })
4838
4827
  }
4839
4828
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "8.0.0-beta.3",
3
+ "version": "8.0.0-beta.4",
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",