phoenix_live_view 0.20.2 → 0.20.3
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/assets/js/phoenix_live_view/dom.js +3 -3
- package/assets/js/phoenix_live_view/dom_patch.js +7 -15
- package/assets/js/phoenix_live_view/js.js +14 -4
- package/assets/js/phoenix_live_view/rendered.js +24 -43
- package/assets/js/phoenix_live_view/view.js +5 -1
- package/assets/package.json +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +51 -70
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +51 -70
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +51 -70
- package/priv/static/phoenix_live_view.min.js +4 -5
|
@@ -639,7 +639,7 @@ var LiveView = (() => {
|
|
|
639
639
|
for (let i = targetAttrs.length - 1; i >= 0; i--) {
|
|
640
640
|
let name = targetAttrs[i].name;
|
|
641
641
|
if (isIgnored) {
|
|
642
|
-
if (name.startsWith("data-") && !source.hasAttribute(name)) {
|
|
642
|
+
if (name.startsWith("data-") && !source.hasAttribute(name) && ![PHX_REF, PHX_REF_SRC].includes(name)) {
|
|
643
643
|
target.removeAttribute(name);
|
|
644
644
|
}
|
|
645
645
|
} else {
|
|
@@ -650,9 +650,7 @@ var LiveView = (() => {
|
|
|
650
650
|
}
|
|
651
651
|
},
|
|
652
652
|
mergeFocusedInput(target, source) {
|
|
653
|
-
|
|
654
|
-
DOM.mergeAttrs(target, source, { exclude: ["value"] });
|
|
655
|
-
}
|
|
653
|
+
DOM.mergeAttrs(target, source, { exclude: ["value"] });
|
|
656
654
|
if (source.readOnly) {
|
|
657
655
|
target.setAttribute("readonly", true);
|
|
658
656
|
} else {
|
|
@@ -1883,7 +1881,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1883
1881
|
},
|
|
1884
1882
|
onNodeAdded: (el) => {
|
|
1885
1883
|
if (el.getAttribute) {
|
|
1886
|
-
this.maybeReOrderStream(el);
|
|
1884
|
+
this.maybeReOrderStream(el, true);
|
|
1887
1885
|
}
|
|
1888
1886
|
if (el instanceof HTMLImageElement && el.srcset) {
|
|
1889
1887
|
el.srcset = el.srcset;
|
|
@@ -1907,17 +1905,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1907
1905
|
Array.from(fromEl.children).filter((child) => {
|
|
1908
1906
|
let { resetKept } = this.getStreamInsert(child);
|
|
1909
1907
|
return resetKept;
|
|
1910
|
-
}).
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
if (aIdx === bIdx) {
|
|
1914
|
-
return 0;
|
|
1915
|
-
} else if (aIdx < bIdx) {
|
|
1916
|
-
return -1;
|
|
1917
|
-
} else {
|
|
1918
|
-
return 1;
|
|
1919
|
-
}
|
|
1920
|
-
}).forEach((child) => fromEl.appendChild(child));
|
|
1908
|
+
}).forEach((child) => {
|
|
1909
|
+
this.streamInserts[child.id].streamAt = toIds.indexOf(child.id);
|
|
1910
|
+
});
|
|
1921
1911
|
}
|
|
1922
1912
|
},
|
|
1923
1913
|
onNodeDiscarded: (el) => this.onNodeDiscarded(el),
|
|
@@ -1941,7 +1931,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1941
1931
|
externalFormTriggered = el;
|
|
1942
1932
|
}
|
|
1943
1933
|
updates.push(el);
|
|
1944
|
-
this.maybeReOrderStream(el);
|
|
1934
|
+
this.maybeReOrderStream(el, false);
|
|
1945
1935
|
},
|
|
1946
1936
|
onBeforeElUpdated: (fromEl, toEl) => {
|
|
1947
1937
|
dom_default.maybeAddPrivateHooks(toEl, phxViewportTop, phxViewportBottom);
|
|
@@ -2049,9 +2039,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2049
2039
|
let insert = el.id ? this.streamInserts[el.id] : {};
|
|
2050
2040
|
return insert || {};
|
|
2051
2041
|
}
|
|
2052
|
-
maybeReOrderStream(el) {
|
|
2042
|
+
maybeReOrderStream(el, isNew) {
|
|
2053
2043
|
let { ref, streamAt, limit } = this.getStreamInsert(el);
|
|
2054
|
-
if (streamAt === void 0) {
|
|
2044
|
+
if (streamAt === void 0 || streamAt === 0 && !isNew) {
|
|
2055
2045
|
return;
|
|
2056
2046
|
}
|
|
2057
2047
|
dom_default.putSticky(el, PHX_STREAM_REF, (el2) => el2.setAttribute(PHX_STREAM_REF, ref));
|
|
@@ -2129,66 +2119,42 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2129
2119
|
"track",
|
|
2130
2120
|
"wbr"
|
|
2131
2121
|
]);
|
|
2132
|
-
var endingTagNameChars = new Set([">", "/", " ", "\n", " ", "\r"]);
|
|
2133
2122
|
var quoteChars = new Set(["'", '"']);
|
|
2134
2123
|
var modifyRoot = (html, attrs, clearInnerHTML) => {
|
|
2135
2124
|
let i = 0;
|
|
2136
2125
|
let insideComment = false;
|
|
2137
2126
|
let beforeTag, afterTag, tag, tagNameEndsAt, id, newHTML;
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
let iAtOpen = i;
|
|
2127
|
+
let lookahead = html.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);
|
|
2128
|
+
if (lookahead === null) {
|
|
2129
|
+
throw new Error(`malformed html ${html}`);
|
|
2130
|
+
}
|
|
2131
|
+
i = lookahead[0].length;
|
|
2132
|
+
beforeTag = lookahead[1];
|
|
2133
|
+
tag = lookahead[2];
|
|
2134
|
+
tagNameEndsAt = i;
|
|
2135
|
+
for (i; i < html.length; i++) {
|
|
2136
|
+
if (html.charAt(i) === ">") {
|
|
2137
|
+
break;
|
|
2138
|
+
}
|
|
2139
|
+
if (html.charAt(i) === "=") {
|
|
2140
|
+
let isId = html.slice(i - 3, i) === " id";
|
|
2153
2141
|
i++;
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2142
|
+
let char = html.charAt(i);
|
|
2143
|
+
if (quoteChars.has(char)) {
|
|
2144
|
+
let attrStartsAt = i;
|
|
2145
|
+
i++;
|
|
2146
|
+
for (i; i < html.length; i++) {
|
|
2147
|
+
if (html.charAt(i) === char) {
|
|
2148
|
+
break;
|
|
2149
|
+
}
|
|
2157
2150
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
tag = html.slice(iAtOpen + 1, tagNameEndsAt);
|
|
2161
|
-
for (i; i < html.length; i++) {
|
|
2162
|
-
if (html.charAt(i) === ">") {
|
|
2151
|
+
if (isId) {
|
|
2152
|
+
id = html.slice(attrStartsAt + 1, i);
|
|
2163
2153
|
break;
|
|
2164
2154
|
}
|
|
2165
|
-
if (html.charAt(i) === "=") {
|
|
2166
|
-
let isId = html.slice(i - 3, i) === " id";
|
|
2167
|
-
i++;
|
|
2168
|
-
let char2 = html.charAt(i);
|
|
2169
|
-
if (quoteChars.has(char2)) {
|
|
2170
|
-
let attrStartsAt = i;
|
|
2171
|
-
i++;
|
|
2172
|
-
for (i; i < html.length; i++) {
|
|
2173
|
-
if (html.charAt(i) === char2) {
|
|
2174
|
-
break;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
if (isId) {
|
|
2178
|
-
id = html.slice(attrStartsAt + 1, i);
|
|
2179
|
-
break;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
2155
|
}
|
|
2184
|
-
break;
|
|
2185
|
-
} else {
|
|
2186
|
-
i++;
|
|
2187
2156
|
}
|
|
2188
2157
|
}
|
|
2189
|
-
if (!tag) {
|
|
2190
|
-
throw new Error(`malformed html ${html}`);
|
|
2191
|
-
}
|
|
2192
2158
|
let closeAt = html.length - 1;
|
|
2193
2159
|
insideComment = false;
|
|
2194
2160
|
while (closeAt >= beforeTag.length + tag.length) {
|
|
@@ -2563,14 +2529,14 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2563
2529
|
dom_default.dispatchEvent(el, event, { detail, bubbles });
|
|
2564
2530
|
},
|
|
2565
2531
|
exec_push(eventType, phxEvent, view, sourceEl, el, args) {
|
|
2566
|
-
if (!view.isConnected()) {
|
|
2567
|
-
return;
|
|
2568
|
-
}
|
|
2569
2532
|
let { event, data, target, page_loading, loading, value, dispatcher, callback } = args;
|
|
2570
2533
|
let pushOpts = { loading, value, target, page_loading: !!page_loading };
|
|
2571
2534
|
let targetSrc = eventType === "change" && dispatcher ? dispatcher : sourceEl;
|
|
2572
2535
|
let phxTarget = target || targetSrc.getAttribute(view.binding("target")) || targetSrc;
|
|
2573
2536
|
view.withinTargets(phxTarget, (targetView, targetCtx) => {
|
|
2537
|
+
if (!targetView.isConnected()) {
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2574
2540
|
if (eventType === "change") {
|
|
2575
2541
|
let { newCid, _target } = args;
|
|
2576
2542
|
_target = _target || (dom_default.isFormInput(sourceEl) ? sourceEl.name : void 0);
|
|
@@ -2615,6 +2581,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2615
2581
|
exec_remove_class(eventType, phxEvent, view, sourceEl, el, { names, transition, time }) {
|
|
2616
2582
|
this.addOrRemoveClasses(el, [], names, transition, time, view);
|
|
2617
2583
|
},
|
|
2584
|
+
exec_toggle_class(eventType, phxEvent, view, sourceEl, el, { to, names, transition, time }) {
|
|
2585
|
+
this.toggleClasses(el, names, transition, view);
|
|
2586
|
+
},
|
|
2618
2587
|
exec_transition(eventType, phxEvent, view, sourceEl, el, { time, transition }) {
|
|
2619
2588
|
this.addOrRemoveClasses(el, [], [], transition, time, view);
|
|
2620
2589
|
},
|
|
@@ -2697,6 +2666,14 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2697
2666
|
}
|
|
2698
2667
|
}
|
|
2699
2668
|
},
|
|
2669
|
+
toggleClasses(el, classes, transition, time, view) {
|
|
2670
|
+
window.requestAnimationFrame(() => {
|
|
2671
|
+
let [prevAdds, prevRemoves] = dom_default.getSticky(el, "classes", [[], []]);
|
|
2672
|
+
let newAdds = classes.filter((name) => prevAdds.indexOf(name) < 0 && !el.classList.contains(name));
|
|
2673
|
+
let newRemoves = classes.filter((name) => prevRemoves.indexOf(name) < 0 && el.classList.contains(name));
|
|
2674
|
+
this.addOrRemoveClasses(el, newAdds, newRemoves, transition, time, view);
|
|
2675
|
+
});
|
|
2676
|
+
},
|
|
2700
2677
|
addOrRemoveClasses(el, adds, removes, transition, time, view) {
|
|
2701
2678
|
let [transitionRun, transitionStart, transitionEnd] = transition || [[], [], []];
|
|
2702
2679
|
if (transitionRun.length > 0) {
|
|
@@ -3051,6 +3028,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
3051
3028
|
let updatedHookIds = new Set();
|
|
3052
3029
|
patch.after("added", (el) => {
|
|
3053
3030
|
this.liveSocket.triggerDOM("onNodeAdded", [el]);
|
|
3031
|
+
let phxViewportTop = this.binding(PHX_VIEWPORT_TOP);
|
|
3032
|
+
let phxViewportBottom = this.binding(PHX_VIEWPORT_BOTTOM);
|
|
3033
|
+
dom_default.maybeAddPrivateHooks(el, phxViewportTop, phxViewportBottom);
|
|
3054
3034
|
this.maybeAddNewHook(el);
|
|
3055
3035
|
if (el.getAttribute) {
|
|
3056
3036
|
this.maybeMounted(el);
|
|
@@ -3597,6 +3577,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
3597
3577
|
this.uploadFiles(inputEl.form, targetCtx, ref, cid, (_uploads) => {
|
|
3598
3578
|
callback && callback(resp);
|
|
3599
3579
|
this.triggerAwaitingSubmit(inputEl.form);
|
|
3580
|
+
this.undoRefs(ref);
|
|
3600
3581
|
});
|
|
3601
3582
|
}
|
|
3602
3583
|
} else {
|