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
|
@@ -756,7 +756,7 @@ var LiveView = (() => {
|
|
|
756
756
|
return FOCUSABLE_INPUTS.indexOf(el.type) >= 0;
|
|
757
757
|
},
|
|
758
758
|
isNowTriggerFormExternal(el, phxTriggerExternal) {
|
|
759
|
-
return el.getAttribute && el.getAttribute(phxTriggerExternal) !== null;
|
|
759
|
+
return el.getAttribute && el.getAttribute(phxTriggerExternal) !== null && document.body.contains(el);
|
|
760
760
|
},
|
|
761
761
|
cleanChildNodes(container, phxUpdate) {
|
|
762
762
|
if (DOM.isPhxUpdate(container, phxUpdate, ["append", "prepend"])) {
|
|
@@ -1971,6 +1971,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1971
1971
|
let focused = liveSocket.getActiveElement();
|
|
1972
1972
|
let { selectionStart, selectionEnd } = focused && dom_default.hasSelectionRange(focused) ? focused : {};
|
|
1973
1973
|
let phxUpdate = liveSocket.binding(PHX_UPDATE);
|
|
1974
|
+
let externalFormTriggered = null;
|
|
1974
1975
|
morphdom_esm_default(container, clonedTree, {
|
|
1975
1976
|
childrenOnly: false,
|
|
1976
1977
|
onBeforeElUpdated: (fromEl, toEl) => {
|
|
@@ -1985,8 +1986,15 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1985
1986
|
dom_default.mergeFocusedInput(fromEl, toEl);
|
|
1986
1987
|
return false;
|
|
1987
1988
|
}
|
|
1989
|
+
if (dom_default.isNowTriggerFormExternal(toEl, liveSocket.binding(PHX_TRIGGER_ACTION))) {
|
|
1990
|
+
externalFormTriggered = toEl;
|
|
1991
|
+
}
|
|
1988
1992
|
}
|
|
1989
1993
|
});
|
|
1994
|
+
if (externalFormTriggered) {
|
|
1995
|
+
liveSocket.unload();
|
|
1996
|
+
Object.getPrototypeOf(externalFormTriggered).submit.call(externalFormTriggered);
|
|
1997
|
+
}
|
|
1990
1998
|
liveSocket.silenceEvents(() => dom_default.restoreFocus(focused, selectionStart, selectionEnd));
|
|
1991
1999
|
}
|
|
1992
2000
|
constructor(view, container, id, html, streams, targetCID) {
|
|
@@ -2783,7 +2791,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2783
2791
|
let pushOpts = { loading, value, target, page_loading: !!page_loading };
|
|
2784
2792
|
let targetSrc = eventType === "change" && dispatcher ? dispatcher : sourceEl;
|
|
2785
2793
|
let phxTarget = target || targetSrc.getAttribute(view.binding("target")) || targetSrc;
|
|
2786
|
-
|
|
2794
|
+
const handler = (targetView, targetCtx) => {
|
|
2787
2795
|
if (!targetView.isConnected()) {
|
|
2788
2796
|
return;
|
|
2789
2797
|
}
|
|
@@ -2800,7 +2808,12 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
2800
2808
|
} else {
|
|
2801
2809
|
targetView.pushEvent(eventType, sourceEl, targetCtx, event || phxEvent, data, pushOpts, callback);
|
|
2802
2810
|
}
|
|
2803
|
-
}
|
|
2811
|
+
};
|
|
2812
|
+
if (args.targetView && args.targetCtx) {
|
|
2813
|
+
handler(args.targetView, args.targetCtx);
|
|
2814
|
+
} else {
|
|
2815
|
+
view.withinTargets(phxTarget, handler);
|
|
2816
|
+
}
|
|
2804
2817
|
},
|
|
2805
2818
|
exec_navigate(e, eventType, phxEvent, view, sourceEl, el, { href, replace }) {
|
|
2806
2819
|
view.liveSocket.historyRedirect(e, href, replace ? "replace" : "push", null, sourceEl);
|
|
@@ -4613,12 +4626,19 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
4613
4626
|
this.withinTargets(phxTarget, (targetView, targetCtx) => {
|
|
4614
4627
|
const cid = this.targetComponentID(newForm, targetCtx);
|
|
4615
4628
|
pending++;
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4629
|
+
let e = new CustomEvent("phx:form-recovery", { detail: { sourceElement: oldForm } });
|
|
4630
|
+
js_default.exec(e, "change", phxEvent, this, input, ["push", {
|
|
4631
|
+
_target: input.name,
|
|
4632
|
+
targetView,
|
|
4633
|
+
targetCtx,
|
|
4634
|
+
newCid: cid,
|
|
4635
|
+
callback: () => {
|
|
4636
|
+
pending--;
|
|
4637
|
+
if (pending === 0) {
|
|
4638
|
+
callback();
|
|
4639
|
+
}
|
|
4620
4640
|
}
|
|
4621
|
-
});
|
|
4641
|
+
}]);
|
|
4622
4642
|
}, templateDom, templateDom);
|
|
4623
4643
|
}
|
|
4624
4644
|
pushLinkPatch(e, href, targetEl, callback) {
|
|
@@ -4760,7 +4780,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
4760
4780
|
}
|
|
4761
4781
|
// public
|
|
4762
4782
|
version() {
|
|
4763
|
-
return "1.0.
|
|
4783
|
+
return "1.0.2";
|
|
4764
4784
|
}
|
|
4765
4785
|
isProfileEnabled() {
|
|
4766
4786
|
return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
|
|
@@ -4946,7 +4966,11 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
4946
4966
|
if (!this.main) {
|
|
4947
4967
|
this.main = view;
|
|
4948
4968
|
}
|
|
4949
|
-
window.requestAnimationFrame(() =>
|
|
4969
|
+
window.requestAnimationFrame(() => {
|
|
4970
|
+
var _a;
|
|
4971
|
+
view.execNewMounted();
|
|
4972
|
+
this.maybeScroll((_a = history.state) == null ? void 0 : _a.scroll);
|
|
4973
|
+
});
|
|
4950
4974
|
}
|
|
4951
4975
|
}
|
|
4952
4976
|
joinRootViews() {
|