phoenix_live_view 1.0.1 → 1.0.2
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 +1 -1
- package/assets/js/phoenix_live_view/dom_patch.js +12 -1
- package/assets/js/phoenix_live_view/js.js +9 -2
- package/assets/js/phoenix_live_view/live_socket.js +5 -1
- package/assets/js/phoenix_live_view/view.js +12 -4
- package/assets/package.json +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +33 -10
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +33 -10
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +34 -10
- package/priv/static/phoenix_live_view.min.js +5 -5
|
@@ -700,7 +700,7 @@ var DOM = {
|
|
|
700
700
|
return FOCUSABLE_INPUTS.indexOf(el.type) >= 0;
|
|
701
701
|
},
|
|
702
702
|
isNowTriggerFormExternal(el, phxTriggerExternal) {
|
|
703
|
-
return el.getAttribute && el.getAttribute(phxTriggerExternal) !== null;
|
|
703
|
+
return el.getAttribute && el.getAttribute(phxTriggerExternal) !== null && document.body.contains(el);
|
|
704
704
|
},
|
|
705
705
|
cleanChildNodes(container, phxUpdate) {
|
|
706
706
|
if (DOM.isPhxUpdate(container, phxUpdate, ["append", "prepend"])) {
|
|
@@ -1915,6 +1915,7 @@ var DOMPatch = class {
|
|
|
1915
1915
|
let focused = liveSocket.getActiveElement();
|
|
1916
1916
|
let { selectionStart, selectionEnd } = focused && dom_default.hasSelectionRange(focused) ? focused : {};
|
|
1917
1917
|
let phxUpdate = liveSocket.binding(PHX_UPDATE);
|
|
1918
|
+
let externalFormTriggered = null;
|
|
1918
1919
|
morphdom_esm_default(container, clonedTree, {
|
|
1919
1920
|
childrenOnly: false,
|
|
1920
1921
|
onBeforeElUpdated: (fromEl, toEl) => {
|
|
@@ -1929,8 +1930,15 @@ var DOMPatch = class {
|
|
|
1929
1930
|
dom_default.mergeFocusedInput(fromEl, toEl);
|
|
1930
1931
|
return false;
|
|
1931
1932
|
}
|
|
1933
|
+
if (dom_default.isNowTriggerFormExternal(toEl, liveSocket.binding(PHX_TRIGGER_ACTION))) {
|
|
1934
|
+
externalFormTriggered = toEl;
|
|
1935
|
+
}
|
|
1932
1936
|
}
|
|
1933
1937
|
});
|
|
1938
|
+
if (externalFormTriggered) {
|
|
1939
|
+
liveSocket.unload();
|
|
1940
|
+
Object.getPrototypeOf(externalFormTriggered).submit.call(externalFormTriggered);
|
|
1941
|
+
}
|
|
1934
1942
|
liveSocket.silenceEvents(() => dom_default.restoreFocus(focused, selectionStart, selectionEnd));
|
|
1935
1943
|
}
|
|
1936
1944
|
constructor(view, container, id, html, streams, targetCID) {
|
|
@@ -2727,7 +2735,7 @@ var JS = {
|
|
|
2727
2735
|
let pushOpts = { loading, value, target, page_loading: !!page_loading };
|
|
2728
2736
|
let targetSrc = eventType === "change" && dispatcher ? dispatcher : sourceEl;
|
|
2729
2737
|
let phxTarget = target || targetSrc.getAttribute(view.binding("target")) || targetSrc;
|
|
2730
|
-
|
|
2738
|
+
const handler = (targetView, targetCtx) => {
|
|
2731
2739
|
if (!targetView.isConnected()) {
|
|
2732
2740
|
return;
|
|
2733
2741
|
}
|
|
@@ -2744,7 +2752,12 @@ var JS = {
|
|
|
2744
2752
|
} else {
|
|
2745
2753
|
targetView.pushEvent(eventType, sourceEl, targetCtx, event || phxEvent, data, pushOpts, callback);
|
|
2746
2754
|
}
|
|
2747
|
-
}
|
|
2755
|
+
};
|
|
2756
|
+
if (args.targetView && args.targetCtx) {
|
|
2757
|
+
handler(args.targetView, args.targetCtx);
|
|
2758
|
+
} else {
|
|
2759
|
+
view.withinTargets(phxTarget, handler);
|
|
2760
|
+
}
|
|
2748
2761
|
},
|
|
2749
2762
|
exec_navigate(e, eventType, phxEvent, view, sourceEl, el, { href, replace }) {
|
|
2750
2763
|
view.liveSocket.historyRedirect(e, href, replace ? "replace" : "push", null, sourceEl);
|
|
@@ -4557,12 +4570,19 @@ var View = class _View {
|
|
|
4557
4570
|
this.withinTargets(phxTarget, (targetView, targetCtx) => {
|
|
4558
4571
|
const cid = this.targetComponentID(newForm, targetCtx);
|
|
4559
4572
|
pending++;
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4573
|
+
let e = new CustomEvent("phx:form-recovery", { detail: { sourceElement: oldForm } });
|
|
4574
|
+
js_default.exec(e, "change", phxEvent, this, input, ["push", {
|
|
4575
|
+
_target: input.name,
|
|
4576
|
+
targetView,
|
|
4577
|
+
targetCtx,
|
|
4578
|
+
newCid: cid,
|
|
4579
|
+
callback: () => {
|
|
4580
|
+
pending--;
|
|
4581
|
+
if (pending === 0) {
|
|
4582
|
+
callback();
|
|
4583
|
+
}
|
|
4564
4584
|
}
|
|
4565
|
-
});
|
|
4585
|
+
}]);
|
|
4566
4586
|
}, templateDom, templateDom);
|
|
4567
4587
|
}
|
|
4568
4588
|
pushLinkPatch(e, href, targetEl, callback) {
|
|
@@ -4704,7 +4724,7 @@ var LiveSocket = class {
|
|
|
4704
4724
|
}
|
|
4705
4725
|
// public
|
|
4706
4726
|
version() {
|
|
4707
|
-
return "1.0.
|
|
4727
|
+
return "1.0.2";
|
|
4708
4728
|
}
|
|
4709
4729
|
isProfileEnabled() {
|
|
4710
4730
|
return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
|
|
@@ -4890,7 +4910,10 @@ var LiveSocket = class {
|
|
|
4890
4910
|
if (!this.main) {
|
|
4891
4911
|
this.main = view;
|
|
4892
4912
|
}
|
|
4893
|
-
window.requestAnimationFrame(() =>
|
|
4913
|
+
window.requestAnimationFrame(() => {
|
|
4914
|
+
view.execNewMounted();
|
|
4915
|
+
this.maybeScroll(history.state?.scroll);
|
|
4916
|
+
});
|
|
4894
4917
|
}
|
|
4895
4918
|
}
|
|
4896
4919
|
joinRootViews() {
|