phoenix_live_view 1.1.13 → 1.1.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.
@@ -38,6 +38,8 @@ import {
38
38
  PHX_VIEWPORT_BOTTOM,
39
39
  MAX_CHILD_JOIN_ATTEMPTS,
40
40
  PHX_LV_PID,
41
+ PHX_PORTAL,
42
+ PHX_TELEPORTED_REF,
41
43
  } from "./constants";
42
44
 
43
45
  import {
@@ -398,7 +400,7 @@ export default class View {
398
400
  this.log(type, () => ["", clone(rawDiff)]);
399
401
  const { diff, reply, events, title } = Rendered.extract(rawDiff);
400
402
  callback({ diff, reply, events });
401
- if (typeof title === "string" || type == "mount") {
403
+ if (typeof title === "string" || (type == "mount" && this.isMain())) {
402
404
  window.requestAnimationFrame(() => DOM.putTitle(title));
403
405
  }
404
406
  }
@@ -724,6 +726,15 @@ export default class View {
724
726
  // recovery events are done.
725
727
  const template = document.createElement("template");
726
728
  template.innerHTML = html;
729
+
730
+ // we special case <.portal> here and teleport it into our temporary DOM for recovery
731
+ // as we'd otherwise not find teleported forms
732
+ DOM.all(template.content, `[${PHX_PORTAL}]`).forEach((portalTemplate) => {
733
+ template.content.firstElementChild.appendChild(
734
+ portalTemplate.content.firstElementChild,
735
+ );
736
+ });
737
+
727
738
  // because we work with a template element, we must manually copy the attributes
728
739
  // otherwise the owner / target helpers don't work properly
729
740
  const rootEl = template.content.firstElementChild;
@@ -2089,7 +2100,10 @@ export default class View {
2089
2100
 
2090
2101
  const phxChange = this.binding("change");
2091
2102
 
2092
- return DOM.all(this.el, `form[${phxChange}]`)
2103
+ return DOM.all(
2104
+ document,
2105
+ `#${CSS.escape(this.id)} form[${phxChange}], [${PHX_TELEPORTED_REF}="${CSS.escape(this.id)}"] form[${phxChange}]`,
2106
+ )
2093
2107
  .filter((form) => form.id)
2094
2108
  .filter((form) => form.elements.length > 0)
2095
2109
  .filter(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phoenix_live_view",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "The Phoenix LiveView JavaScript client.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -4276,7 +4276,7 @@ var View = class _View {
4276
4276
  this.log(type, () => ["", clone(rawDiff)]);
4277
4277
  const { diff, reply, events, title } = Rendered.extract(rawDiff);
4278
4278
  callback({ diff, reply, events });
4279
- if (typeof title === "string" || type == "mount") {
4279
+ if (typeof title === "string" || type == "mount" && this.isMain()) {
4280
4280
  window.requestAnimationFrame(() => dom_default.putTitle(title));
4281
4281
  }
4282
4282
  }
@@ -4538,6 +4538,11 @@ var View = class _View {
4538
4538
  const oldForms = this.root.formsForRecovery;
4539
4539
  const template = document.createElement("template");
4540
4540
  template.innerHTML = html;
4541
+ dom_default.all(template.content, `[${PHX_PORTAL}]`).forEach((portalTemplate) => {
4542
+ template.content.firstElementChild.appendChild(
4543
+ portalTemplate.content.firstElementChild
4544
+ );
4545
+ });
4541
4546
  const rootEl = template.content.firstElementChild;
4542
4547
  rootEl.id = this.id;
4543
4548
  rootEl.setAttribute(PHX_ROOT_ID, this.root.id);
@@ -5638,7 +5643,10 @@ var View = class _View {
5638
5643
  return {};
5639
5644
  }
5640
5645
  const phxChange = this.binding("change");
5641
- return dom_default.all(this.el, `form[${phxChange}]`).filter((form) => form.id).filter((form) => form.elements.length > 0).filter(
5646
+ return dom_default.all(
5647
+ document,
5648
+ `#${CSS.escape(this.id)} form[${phxChange}], [${PHX_TELEPORTED_REF}="${CSS.escape(this.id)}"] form[${phxChange}]`
5649
+ ).filter((form) => form.id).filter((form) => form.elements.length > 0).filter(
5642
5650
  (form) => form.getAttribute(this.binding(PHX_AUTO_RECOVER)) !== "ignore"
5643
5651
  ).map((form) => {
5644
5652
  const clonedForm = form.cloneNode(true);
@@ -5795,7 +5803,7 @@ var LiveSocket = class {
5795
5803
  }
5796
5804
  // public
5797
5805
  version() {
5798
- return "1.1.13";
5806
+ return "1.1.14";
5799
5807
  }
5800
5808
  isProfileEnabled() {
5801
5809
  return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";