turbo-rails 2.0.22 → 2.0.23
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo.js +70 -33
- data/app/assets/javascripts/turbo.min.js +4 -4
- data/app/assets/javascripts/turbo.min.js.map +1 -1
- data/lib/turbo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7fa7bf2e6c2c50efa712150fffb94b7ce0c868c46766e2eefce28102249947ec
|
|
4
|
+
data.tar.gz: b594c86cf49a039f6c7f1cf826f446dfdf71305260f3294b0b87acf9a292d485
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62fb3c56ba02c3d62893326fc2d30303e0aa5aeec9b2fbdd7c9490197680c31bfb922920019086053d53b6948e4aa7972b29ae486d1a29db2ad4f03a2fd72ace
|
|
7
|
+
data.tar.gz: 4f7813b54b50c76ad4918f905781d8e63b63bf706fe236bd2fb66f5593179391eca2b29d899c8c9094de29cbdd4fdaaf26d5e0bd0331363fc5df9a21bd57b2c3
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Turbo 8.0.
|
|
2
|
+
Turbo 8.0.23
|
|
3
3
|
Copyright © 2026 37signals LLC
|
|
4
4
|
*/
|
|
5
5
|
const FrameLoadingStyle = {
|
|
@@ -1720,12 +1720,8 @@ var Idiomorph = function() {
|
|
|
1720
1720
|
}
|
|
1721
1721
|
function morphOuterHTML(ctx, oldNode, newNode) {
|
|
1722
1722
|
const oldParent = normalizeParent(oldNode);
|
|
1723
|
-
let childNodes = Array.from(oldParent.childNodes);
|
|
1724
|
-
const index = childNodes.indexOf(oldNode);
|
|
1725
|
-
const rightMargin = childNodes.length - (index + 1);
|
|
1726
1723
|
morphChildren(ctx, oldParent, newNode, oldNode, oldNode.nextSibling);
|
|
1727
|
-
|
|
1728
|
-
return childNodes.slice(index, childNodes.length - rightMargin);
|
|
1724
|
+
return Array.from(oldParent.childNodes);
|
|
1729
1725
|
}
|
|
1730
1726
|
function saveAndRestoreFocus(ctx, fn) {
|
|
1731
1727
|
if (!ctx.config.restoreFocus) return fn();
|
|
@@ -1735,8 +1731,8 @@ var Idiomorph = function() {
|
|
|
1735
1731
|
}
|
|
1736
1732
|
const {id: activeElementId, selectionStart: selectionStart, selectionEnd: selectionEnd} = activeElement;
|
|
1737
1733
|
const results = fn();
|
|
1738
|
-
if (activeElementId && activeElementId !== document.activeElement?.id) {
|
|
1739
|
-
activeElement = ctx.target.querySelector(
|
|
1734
|
+
if (activeElementId && activeElementId !== document.activeElement?.getAttribute("id")) {
|
|
1735
|
+
activeElement = ctx.target.querySelector(`[id="${activeElementId}"]`);
|
|
1740
1736
|
activeElement?.focus();
|
|
1741
1737
|
}
|
|
1742
1738
|
if (activeElement && !activeElement.selectionEnd && selectionEnd) {
|
|
@@ -1763,11 +1759,14 @@ var Idiomorph = function() {
|
|
|
1763
1759
|
continue;
|
|
1764
1760
|
}
|
|
1765
1761
|
}
|
|
1766
|
-
if (newChild instanceof Element
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1762
|
+
if (newChild instanceof Element) {
|
|
1763
|
+
const newChildId = newChild.getAttribute("id");
|
|
1764
|
+
if (ctx.persistentIds.has(newChildId)) {
|
|
1765
|
+
const movedChild = moveBeforeById(oldParent, newChildId, insertionPoint, ctx);
|
|
1766
|
+
morphNode(movedChild, newChild, ctx);
|
|
1767
|
+
insertionPoint = movedChild.nextSibling;
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1771
1770
|
}
|
|
1772
1771
|
const insertedNode = createNode(oldParent, newChild, insertionPoint, ctx);
|
|
1773
1772
|
if (insertedNode) {
|
|
@@ -1819,7 +1818,7 @@ var Idiomorph = function() {
|
|
|
1819
1818
|
softMatch = undefined;
|
|
1820
1819
|
}
|
|
1821
1820
|
}
|
|
1822
|
-
if (
|
|
1821
|
+
if (ctx.activeElementAndParents.includes(cursor)) break;
|
|
1823
1822
|
cursor = cursor.nextSibling;
|
|
1824
1823
|
}
|
|
1825
1824
|
return softMatch || null;
|
|
@@ -1838,7 +1837,7 @@ var Idiomorph = function() {
|
|
|
1838
1837
|
function isSoftMatch(oldNode, newNode) {
|
|
1839
1838
|
const oldElt = oldNode;
|
|
1840
1839
|
const newElt = newNode;
|
|
1841
|
-
return oldElt.nodeType === newElt.nodeType && oldElt.tagName === newElt.tagName && (!oldElt.id || oldElt.id === newElt.id);
|
|
1840
|
+
return oldElt.nodeType === newElt.nodeType && oldElt.tagName === newElt.tagName && (!oldElt.getAttribute?.("id") || oldElt.getAttribute?.("id") === newElt.getAttribute?.("id"));
|
|
1842
1841
|
}
|
|
1843
1842
|
return findBestMatch;
|
|
1844
1843
|
}();
|
|
@@ -1861,13 +1860,13 @@ var Idiomorph = function() {
|
|
|
1861
1860
|
return cursor;
|
|
1862
1861
|
}
|
|
1863
1862
|
function moveBeforeById(parentNode, id, after, ctx) {
|
|
1864
|
-
const target = ctx.target.querySelector(
|
|
1863
|
+
const target = ctx.target.getAttribute?.("id") === id && ctx.target || ctx.target.querySelector(`[id="${id}"]`) || ctx.pantry.querySelector(`[id="${id}"]`);
|
|
1865
1864
|
removeElementFromAncestorsIdMaps(target, ctx);
|
|
1866
1865
|
moveBefore(parentNode, target, after);
|
|
1867
1866
|
return target;
|
|
1868
1867
|
}
|
|
1869
1868
|
function removeElementFromAncestorsIdMaps(element, ctx) {
|
|
1870
|
-
const id = element.id;
|
|
1869
|
+
const id = element.getAttribute("id");
|
|
1871
1870
|
while (element = element.parentNode) {
|
|
1872
1871
|
let idSet = ctx.idMap.get(element);
|
|
1873
1872
|
if (idSet) {
|
|
@@ -2111,6 +2110,7 @@ var Idiomorph = function() {
|
|
|
2111
2110
|
idMap: idMap,
|
|
2112
2111
|
persistentIds: persistentIds,
|
|
2113
2112
|
pantry: createPantry(),
|
|
2113
|
+
activeElementAndParents: createActiveElementAndParents(oldNode),
|
|
2114
2114
|
callbacks: mergedConfig.callbacks,
|
|
2115
2115
|
head: mergedConfig.head
|
|
2116
2116
|
};
|
|
@@ -2128,16 +2128,29 @@ var Idiomorph = function() {
|
|
|
2128
2128
|
document.body.insertAdjacentElement("afterend", pantry);
|
|
2129
2129
|
return pantry;
|
|
2130
2130
|
}
|
|
2131
|
+
function createActiveElementAndParents(oldNode) {
|
|
2132
|
+
let activeElementAndParents = [];
|
|
2133
|
+
let elt = document.activeElement;
|
|
2134
|
+
if (elt?.tagName !== "BODY" && oldNode.contains(elt)) {
|
|
2135
|
+
while (elt) {
|
|
2136
|
+
activeElementAndParents.push(elt);
|
|
2137
|
+
if (elt === oldNode) break;
|
|
2138
|
+
elt = elt.parentElement;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
return activeElementAndParents;
|
|
2142
|
+
}
|
|
2131
2143
|
function findIdElements(root) {
|
|
2132
2144
|
let elements = Array.from(root.querySelectorAll("[id]"));
|
|
2133
|
-
if (root.id) {
|
|
2145
|
+
if (root.getAttribute?.("id")) {
|
|
2134
2146
|
elements.push(root);
|
|
2135
2147
|
}
|
|
2136
2148
|
return elements;
|
|
2137
2149
|
}
|
|
2138
2150
|
function populateIdMapWithTree(idMap, persistentIds, root, elements) {
|
|
2139
2151
|
for (const elt of elements) {
|
|
2140
|
-
|
|
2152
|
+
const id = elt.getAttribute("id");
|
|
2153
|
+
if (persistentIds.has(id)) {
|
|
2141
2154
|
let current = elt;
|
|
2142
2155
|
while (current) {
|
|
2143
2156
|
let idSet = idMap.get(current);
|
|
@@ -2145,7 +2158,7 @@ var Idiomorph = function() {
|
|
|
2145
2158
|
idSet = new Set;
|
|
2146
2159
|
idMap.set(current, idSet);
|
|
2147
2160
|
}
|
|
2148
|
-
idSet.add(
|
|
2161
|
+
idSet.add(id);
|
|
2149
2162
|
if (current === root) break;
|
|
2150
2163
|
current = current.parentElement;
|
|
2151
2164
|
}
|
|
@@ -2208,7 +2221,7 @@ var Idiomorph = function() {
|
|
|
2208
2221
|
return newContent;
|
|
2209
2222
|
} else if (newContent instanceof Node) {
|
|
2210
2223
|
if (newContent.parentNode) {
|
|
2211
|
-
return
|
|
2224
|
+
return new SlicedParentNode(newContent);
|
|
2212
2225
|
} else {
|
|
2213
2226
|
const dummyParent = document.createElement("div");
|
|
2214
2227
|
dummyParent.append(newContent);
|
|
@@ -2222,19 +2235,43 @@ var Idiomorph = function() {
|
|
|
2222
2235
|
return dummyParent;
|
|
2223
2236
|
}
|
|
2224
2237
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2238
|
+
class SlicedParentNode {
|
|
2239
|
+
constructor(node) {
|
|
2240
|
+
this.originalNode = node;
|
|
2241
|
+
this.realParentNode = node.parentNode;
|
|
2242
|
+
this.previousSibling = node.previousSibling;
|
|
2243
|
+
this.nextSibling = node.nextSibling;
|
|
2244
|
+
}
|
|
2245
|
+
get childNodes() {
|
|
2246
|
+
const nodes = [];
|
|
2247
|
+
let cursor = this.previousSibling ? this.previousSibling.nextSibling : this.realParentNode.firstChild;
|
|
2248
|
+
while (cursor && cursor != this.nextSibling) {
|
|
2249
|
+
nodes.push(cursor);
|
|
2250
|
+
cursor = cursor.nextSibling;
|
|
2236
2251
|
}
|
|
2237
|
-
|
|
2252
|
+
return nodes;
|
|
2253
|
+
}
|
|
2254
|
+
querySelectorAll(selector) {
|
|
2255
|
+
return this.childNodes.reduce(((results, node) => {
|
|
2256
|
+
if (node instanceof Element) {
|
|
2257
|
+
if (node.matches(selector)) results.push(node);
|
|
2258
|
+
const nodeList = node.querySelectorAll(selector);
|
|
2259
|
+
for (let i = 0; i < nodeList.length; i++) {
|
|
2260
|
+
results.push(nodeList[i]);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
return results;
|
|
2264
|
+
}), []);
|
|
2265
|
+
}
|
|
2266
|
+
insertBefore(node, referenceNode) {
|
|
2267
|
+
return this.realParentNode.insertBefore(node, referenceNode);
|
|
2268
|
+
}
|
|
2269
|
+
moveBefore(node, referenceNode) {
|
|
2270
|
+
return this.realParentNode.moveBefore(node, referenceNode);
|
|
2271
|
+
}
|
|
2272
|
+
get __idiomorphRoot() {
|
|
2273
|
+
return this.originalNode;
|
|
2274
|
+
}
|
|
2238
2275
|
}
|
|
2239
2276
|
function parseContent(newContent) {
|
|
2240
2277
|
let parser = new DOMParser;
|