phoenix_live_view 1.0.13 → 1.0.14

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.
@@ -1464,7 +1464,10 @@ export default class View {
1464
1464
  const phxTarget = newForm.getAttribute(this.binding("target")) || newForm
1465
1465
  const phxEvent = newForm.getAttribute(this.binding(PHX_AUTO_RECOVER)) || newForm.getAttribute(this.binding("change"))
1466
1466
  const inputs = Array.from(oldForm.elements).filter(el => DOM.isFormInput(el) && el.name && !el.hasAttribute(phxChange))
1467
- if(inputs.length === 0){ return }
1467
+ if(inputs.length === 0){
1468
+ callback()
1469
+ return
1470
+ }
1468
1471
 
1469
1472
  // we must clear tracked uploads before recovery as they no longer have valid refs
1470
1473
  inputs.forEach(input => input.hasAttribute(PHX_UPLOAD_REF) && LiveUploader.clearFiles(input))
@@ -1529,7 +1532,19 @@ export default class View {
1529
1532
  .filter(form => form.id)
1530
1533
  .filter(form => form.elements.length > 0)
1531
1534
  .filter(form => form.getAttribute(this.binding(PHX_AUTO_RECOVER)) !== "ignore")
1532
- .map(form => form.cloneNode(true))
1535
+ .map(form => {
1536
+ // we perform a shallow clone and manually copy all elementsAdd commentMore actions
1537
+ const clonedForm = form.cloneNode(false)
1538
+ // we need to copy the private data as it contains
1539
+ // the information about touched fields
1540
+ DOM.copyPrivates(clonedForm, form)
1541
+ Array.from(form.elements).forEach((el) => {
1542
+ const clonedEl = el.cloneNode(false)
1543
+ DOM.copyPrivates(clonedEl, el)
1544
+ clonedForm.appendChild(clonedEl)
1545
+ })
1546
+ return clonedForm
1547
+ })
1533
1548
  .reduce((acc, form) => {
1534
1549
  acc[form.id] = form
1535
1550
  return acc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phoenix_live_view",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "The Phoenix LiveView JavaScript client.",
5
5
  "license": "MIT",
6
6
  "module": "./priv/static/phoenix_live_view.esm.js",
@@ -4691,6 +4691,7 @@ var View = class _View {
4691
4691
  const phxEvent = newForm.getAttribute(this.binding(PHX_AUTO_RECOVER)) || newForm.getAttribute(this.binding("change"));
4692
4692
  const inputs = Array.from(oldForm.elements).filter((el) => dom_default.isFormInput(el) && el.name && !el.hasAttribute(phxChange));
4693
4693
  if (inputs.length === 0) {
4694
+ callback();
4694
4695
  return;
4695
4696
  }
4696
4697
  inputs.forEach((input2) => input2.hasAttribute(PHX_UPLOAD_REF) && LiveUploader.clearFiles(input2));
@@ -4742,7 +4743,16 @@ var View = class _View {
4742
4743
  return {};
4743
4744
  }
4744
4745
  let phxChange = this.binding("change");
4745
- return dom_default.all(this.el, `form[${phxChange}]`).filter((form) => form.id).filter((form) => form.elements.length > 0).filter((form) => form.getAttribute(this.binding(PHX_AUTO_RECOVER)) !== "ignore").map((form) => form.cloneNode(true)).reduce((acc, form) => {
4746
+ return dom_default.all(this.el, `form[${phxChange}]`).filter((form) => form.id).filter((form) => form.elements.length > 0).filter((form) => form.getAttribute(this.binding(PHX_AUTO_RECOVER)) !== "ignore").map((form) => {
4747
+ const clonedForm = form.cloneNode(false);
4748
+ dom_default.copyPrivates(clonedForm, form);
4749
+ Array.from(form.elements).forEach((el) => {
4750
+ const clonedEl = el.cloneNode(false);
4751
+ dom_default.copyPrivates(clonedEl, el);
4752
+ clonedForm.appendChild(clonedEl);
4753
+ });
4754
+ return clonedForm;
4755
+ }).reduce((acc, form) => {
4746
4756
  acc[form.id] = form;
4747
4757
  return acc;
4748
4758
  }, {});
@@ -4854,7 +4864,7 @@ var LiveSocket = class {
4854
4864
  }
4855
4865
  // public
4856
4866
  version() {
4857
- return "1.0.13";
4867
+ return "1.0.14";
4858
4868
  }
4859
4869
  isProfileEnabled() {
4860
4870
  return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";