Skip to content

Commit b4156f6

Browse files
committed
Update dist
1 parent 282739a commit b4156f6

File tree

2 files changed

+150
-48
lines changed

2 files changed

+150
-48
lines changed

dist/turbo.es2017-esm.js

+75-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
Turbo 8.0.2
2+
Turbo 8.0.4
33
Copyright © 2024 37signals LLC
44
*/
55
/**
@@ -126,7 +126,7 @@ class FrameElement extends HTMLElement {
126126
loaded = Promise.resolve()
127127

128128
static get observedAttributes() {
129-
return ["disabled", "complete", "loading", "src"]
129+
return ["disabled", "loading", "src"]
130130
}
131131

132132
constructor() {
@@ -149,11 +149,9 @@ class FrameElement extends HTMLElement {
149149
attributeChangedCallback(name) {
150150
if (name == "loading") {
151151
this.delegate.loadingStyleChanged();
152-
} else if (name == "complete") {
153-
this.delegate.completeChanged();
154152
} else if (name == "src") {
155153
this.delegate.sourceURLChanged();
156-
} else {
154+
} else if (name == "disabled") {
157155
this.delegate.disabledChanged();
158156
}
159157
}
@@ -4806,7 +4804,6 @@ class MorphRenderer extends PageRenderer {
48064804
this.isMorphingTurboFrame = this.#isFrameReloadedWithMorph(currentElement);
48074805

48084806
Idiomorph.morph(currentElement, newElement, {
4809-
ignoreActiveValue: true,
48104807
morphStyle: morphStyle,
48114808
callbacks: {
48124809
beforeNodeAdded: this.#shouldAddElement,
@@ -5200,8 +5197,7 @@ class Session {
52005197
refresh(url, requestId) {
52015198
const isRecentRequest = requestId && this.recentRequests.has(requestId);
52025199
if (!isRecentRequest) {
5203-
this.cache.exemptPageFromPreview();
5204-
this.visit(url, { action: "replace" });
5200+
this.visit(url, { action: "replace", shouldCacheSnapshot: false });
52055201
}
52065202
}
52075203

@@ -5775,20 +5771,12 @@ class FrameController {
57755771

57765772
sourceURLReloaded() {
57775773
const { src } = this.element;
5778-
this.#ignoringChangesToAttribute("complete", () => {
5779-
this.element.removeAttribute("complete");
5780-
});
5774+
this.element.removeAttribute("complete");
57815775
this.element.src = null;
57825776
this.element.src = src;
57835777
return this.element.loaded
57845778
}
57855779

5786-
completeChanged() {
5787-
if (this.#isIgnoringChangesTo("complete")) return
5788-
5789-
this.#loadSourceURL();
5790-
}
5791-
57925780
loadingStyleChanged() {
57935781
if (this.loadingStyle == FrameLoadingStyle.lazy) {
57945782
this.appearanceObserver.start();
@@ -6213,13 +6201,11 @@ class FrameController {
62136201
}
62146202

62156203
set complete(value) {
6216-
this.#ignoringChangesToAttribute("complete", () => {
6217-
if (value) {
6218-
this.element.setAttribute("complete", "");
6219-
} else {
6220-
this.element.removeAttribute("complete");
6221-
}
6222-
});
6204+
if (value) {
6205+
this.element.setAttribute("complete", "");
6206+
} else {
6207+
this.element.removeAttribute("complete");
6208+
}
62236209
}
62246210

62256211
get isActive() {
@@ -6276,6 +6262,67 @@ function activateElement(element, currentURL) {
62766262
}
62776263
}
62786264

6265+
function morph(streamElement) {
6266+
const morphStyle = streamElement.hasAttribute("children-only") ? "innerHTML" : "outerHTML";
6267+
streamElement.targetElements.forEach((element) => {
6268+
Idiomorph.morph(element, streamElement.templateContent, {
6269+
morphStyle: morphStyle,
6270+
callbacks: {
6271+
beforeNodeAdded,
6272+
beforeNodeMorphed,
6273+
beforeAttributeUpdated,
6274+
beforeNodeRemoved,
6275+
afterNodeMorphed
6276+
}
6277+
});
6278+
});
6279+
}
6280+
6281+
function beforeNodeAdded(node) {
6282+
return !(node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id))
6283+
}
6284+
6285+
function beforeNodeRemoved(node) {
6286+
return beforeNodeAdded(node)
6287+
}
6288+
6289+
function beforeNodeMorphed(target, newElement) {
6290+
if (target instanceof HTMLElement && !target.hasAttribute("data-turbo-permanent")) {
6291+
const event = dispatch("turbo:before-morph-element", {
6292+
cancelable: true,
6293+
target,
6294+
detail: {
6295+
newElement
6296+
}
6297+
});
6298+
return !event.defaultPrevented
6299+
}
6300+
return false
6301+
}
6302+
6303+
function beforeAttributeUpdated(attributeName, target, mutationType) {
6304+
const event = dispatch("turbo:before-morph-attribute", {
6305+
cancelable: true,
6306+
target,
6307+
detail: {
6308+
attributeName,
6309+
mutationType
6310+
}
6311+
});
6312+
return !event.defaultPrevented
6313+
}
6314+
6315+
function afterNodeMorphed(target, newElement) {
6316+
if (newElement instanceof HTMLElement) {
6317+
dispatch("turbo:morph-element", {
6318+
target,
6319+
detail: {
6320+
newElement
6321+
}
6322+
});
6323+
}
6324+
}
6325+
62796326
const StreamActions = {
62806327
after() {
62816328
this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e.nextSibling));
@@ -6312,6 +6359,10 @@ const StreamActions = {
63126359

63136360
refresh() {
63146361
session.refresh(this.baseURI, this.requestId);
6362+
},
6363+
6364+
morph() {
6365+
morph(this);
63156366
}
63166367
};
63176368

dist/turbo.es2017-umd.js

+75-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
Turbo 8.0.2
2+
Turbo 8.0.4
33
Copyright © 2024 37signals LLC
44
*/
55
(function (global, factory) {
@@ -132,7 +132,7 @@ Copyright © 2024 37signals LLC
132132
loaded = Promise.resolve()
133133

134134
static get observedAttributes() {
135-
return ["disabled", "complete", "loading", "src"]
135+
return ["disabled", "loading", "src"]
136136
}
137137

138138
constructor() {
@@ -155,11 +155,9 @@ Copyright © 2024 37signals LLC
155155
attributeChangedCallback(name) {
156156
if (name == "loading") {
157157
this.delegate.loadingStyleChanged();
158-
} else if (name == "complete") {
159-
this.delegate.completeChanged();
160158
} else if (name == "src") {
161159
this.delegate.sourceURLChanged();
162-
} else {
160+
} else if (name == "disabled") {
163161
this.delegate.disabledChanged();
164162
}
165163
}
@@ -4812,7 +4810,6 @@ Copyright © 2024 37signals LLC
48124810
this.isMorphingTurboFrame = this.#isFrameReloadedWithMorph(currentElement);
48134811

48144812
Idiomorph.morph(currentElement, newElement, {
4815-
ignoreActiveValue: true,
48164813
morphStyle: morphStyle,
48174814
callbacks: {
48184815
beforeNodeAdded: this.#shouldAddElement,
@@ -5206,8 +5203,7 @@ Copyright © 2024 37signals LLC
52065203
refresh(url, requestId) {
52075204
const isRecentRequest = requestId && this.recentRequests.has(requestId);
52085205
if (!isRecentRequest) {
5209-
this.cache.exemptPageFromPreview();
5210-
this.visit(url, { action: "replace" });
5206+
this.visit(url, { action: "replace", shouldCacheSnapshot: false });
52115207
}
52125208
}
52135209

@@ -5781,20 +5777,12 @@ Copyright © 2024 37signals LLC
57815777

57825778
sourceURLReloaded() {
57835779
const { src } = this.element;
5784-
this.#ignoringChangesToAttribute("complete", () => {
5785-
this.element.removeAttribute("complete");
5786-
});
5780+
this.element.removeAttribute("complete");
57875781
this.element.src = null;
57885782
this.element.src = src;
57895783
return this.element.loaded
57905784
}
57915785

5792-
completeChanged() {
5793-
if (this.#isIgnoringChangesTo("complete")) return
5794-
5795-
this.#loadSourceURL();
5796-
}
5797-
57985786
loadingStyleChanged() {
57995787
if (this.loadingStyle == FrameLoadingStyle.lazy) {
58005788
this.appearanceObserver.start();
@@ -6219,13 +6207,11 @@ Copyright © 2024 37signals LLC
62196207
}
62206208

62216209
set complete(value) {
6222-
this.#ignoringChangesToAttribute("complete", () => {
6223-
if (value) {
6224-
this.element.setAttribute("complete", "");
6225-
} else {
6226-
this.element.removeAttribute("complete");
6227-
}
6228-
});
6210+
if (value) {
6211+
this.element.setAttribute("complete", "");
6212+
} else {
6213+
this.element.removeAttribute("complete");
6214+
}
62296215
}
62306216

62316217
get isActive() {
@@ -6282,6 +6268,67 @@ Copyright © 2024 37signals LLC
62826268
}
62836269
}
62846270

6271+
function morph(streamElement) {
6272+
const morphStyle = streamElement.hasAttribute("children-only") ? "innerHTML" : "outerHTML";
6273+
streamElement.targetElements.forEach((element) => {
6274+
Idiomorph.morph(element, streamElement.templateContent, {
6275+
morphStyle: morphStyle,
6276+
callbacks: {
6277+
beforeNodeAdded,
6278+
beforeNodeMorphed,
6279+
beforeAttributeUpdated,
6280+
beforeNodeRemoved,
6281+
afterNodeMorphed
6282+
}
6283+
});
6284+
});
6285+
}
6286+
6287+
function beforeNodeAdded(node) {
6288+
return !(node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id))
6289+
}
6290+
6291+
function beforeNodeRemoved(node) {
6292+
return beforeNodeAdded(node)
6293+
}
6294+
6295+
function beforeNodeMorphed(target, newElement) {
6296+
if (target instanceof HTMLElement && !target.hasAttribute("data-turbo-permanent")) {
6297+
const event = dispatch("turbo:before-morph-element", {
6298+
cancelable: true,
6299+
target,
6300+
detail: {
6301+
newElement
6302+
}
6303+
});
6304+
return !event.defaultPrevented
6305+
}
6306+
return false
6307+
}
6308+
6309+
function beforeAttributeUpdated(attributeName, target, mutationType) {
6310+
const event = dispatch("turbo:before-morph-attribute", {
6311+
cancelable: true,
6312+
target,
6313+
detail: {
6314+
attributeName,
6315+
mutationType
6316+
}
6317+
});
6318+
return !event.defaultPrevented
6319+
}
6320+
6321+
function afterNodeMorphed(target, newElement) {
6322+
if (newElement instanceof HTMLElement) {
6323+
dispatch("turbo:morph-element", {
6324+
target,
6325+
detail: {
6326+
newElement
6327+
}
6328+
});
6329+
}
6330+
}
6331+
62856332
const StreamActions = {
62866333
after() {
62876334
this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e.nextSibling));
@@ -6318,6 +6365,10 @@ Copyright © 2024 37signals LLC
63186365

63196366
refresh() {
63206367
session.refresh(this.baseURI, this.requestId);
6368+
},
6369+
6370+
morph() {
6371+
morph(this);
63216372
}
63226373
};
63236374

0 commit comments

Comments
 (0)