phoenix_live_view 1.2.0-rc.3 → 1.2.1

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.
@@ -642,7 +642,9 @@ var DOM = {
642
642
  if (this.once(el, "bind-debounce")) {
643
643
  el.addEventListener("blur", () => {
644
644
  clearTimeout(this.private(el, THROTTLED));
645
- this.triggerCycle(el, DEBOUNCE_TRIGGER);
645
+ if (asyncFilter()) {
646
+ this.triggerCycle(el, DEBOUNCE_TRIGGER);
647
+ }
646
648
  });
647
649
  }
648
650
  }
@@ -2796,7 +2798,7 @@ var DOMPatch = class {
2796
2798
  transitionPendingRemoves() {
2797
2799
  const { pendingRemoves, liveSocket } = this;
2798
2800
  if (pendingRemoves.length > 0) {
2799
- liveSocket.transitionRemoves(pendingRemoves, () => {
2801
+ liveSocket.transitionRemoves(pendingRemoves, this.view, () => {
2800
2802
  pendingRemoves.forEach((el) => {
2801
2803
  const child = dom_default.firstPhxChild(el);
2802
2804
  if (child) {
@@ -4424,6 +4426,7 @@ var View = class _View {
4424
4426
  if (container) {
4425
4427
  const [tag, attrs] = container;
4426
4428
  this.el = dom_default.replaceRootContainer(this.el, tag, attrs);
4429
+ dom_default.putPrivate(this.el, "view", this);
4427
4430
  }
4428
4431
  this.childJoins = 0;
4429
4432
  this.joinPending = true;
@@ -4510,6 +4513,7 @@ var View = class _View {
4510
4513
  throw new Error("unable to find root element for view");
4511
4514
  }
4512
4515
  this.el = el;
4516
+ dom_default.putPrivate(this.el, "view", this);
4513
4517
  this.el.setAttribute(PHX_ROOT_ID, this.root.id);
4514
4518
  }
4515
4519
  // this is invoked for dead and live views, so we must filter by
@@ -4698,6 +4702,7 @@ var View = class _View {
4698
4702
  rootEl.setAttribute(PHX_SESSION, this.getSession());
4699
4703
  rootEl.setAttribute(PHX_STATIC, this.getStatic() ?? "");
4700
4704
  this.parent && rootEl.setAttribute(PHX_PARENT_ID, this.parent.id);
4705
+ dom_default.putPrivate(rootEl, "view", this);
4701
4706
  const formsToRecover = (
4702
4707
  // we go over all forms in the new DOM; because this is only the HTML for the current
4703
4708
  // view, we can be sure that all forms are owned by this view:
@@ -4992,6 +4997,9 @@ var View = class _View {
4992
4997
  });
4993
4998
  }
4994
4999
  onJoinError(resp) {
5000
+ if (resp.events) {
5001
+ this.liveSocket.dispatchEvents(resp.events);
5002
+ }
4995
5003
  if (resp.reason === "reload") {
4996
5004
  this.log("error", () => [
4997
5005
  `failed mount with ${resp.status}. Falling back to page reload`,
@@ -6057,7 +6065,7 @@ var LiveSocket = class {
6057
6065
  * Returns the version of the LiveView client.
6058
6066
  */
6059
6067
  version() {
6060
- return "1.2.0-rc.3";
6068
+ return "1.2.1";
6061
6069
  }
6062
6070
  /**
6063
6071
  * Returns true if profiling is enabled. See {@link enableProfiling} and {@link disableProfiling}.
@@ -6081,7 +6089,7 @@ var LiveSocket = class {
6081
6089
  * Enables debugging.
6082
6090
  *
6083
6091
  * When debugging is enabled, the LiveView client will log debug information to the console.
6084
- * See [Debugging client events](https://hexdocs.pm/phoenix_live_view/js-interop.html#debugging-client-events) for more information.
6092
+ * See [Debugging client events](https://phoenix-live-view.hexdocs.pm/js-interop.html#debugging-client-events) for more information.
6085
6093
  */
6086
6094
  enableDebug() {
6087
6095
  this.sessionStorage.setItem(PHX_LV_DEBUG, "true");
@@ -6110,7 +6118,7 @@ var LiveSocket = class {
6110
6118
  * Enables latency simulation.
6111
6119
  *
6112
6120
  * When latency simulation is enabled, the LiveView client will add a delay to requests and responses from the server.
6113
- * See [Simulating Latency](https://hexdocs.pm/phoenix_live_view/js-interop.html#simulating-latency) for more information.
6121
+ * See [Simulating Latency](https://phoenix-live-view.hexdocs.pm/js-interop.html#simulating-latency) for more information.
6114
6122
  */
6115
6123
  enableLatencySim(upperBoundMs) {
6116
6124
  this.enableDebug();
@@ -6185,7 +6193,7 @@ var LiveSocket = class {
6185
6193
  /**
6186
6194
  * Executes an encoded JS command, targeting the given element.
6187
6195
  *
6188
- * See [`Phoenix.LiveView.JS`](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.JS.html) for more information.
6196
+ * See [`Phoenix.LiveView.JS`](https://phoenix-live-view.hexdocs.pm/Phoenix.LiveView.JS.html) for more information.
6189
6197
  */
6190
6198
  execJS(el, encodedJS, eventType = null) {
6191
6199
  const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
@@ -6195,7 +6203,7 @@ var LiveSocket = class {
6195
6203
  * Returns an object with methods to manipulate the DOM and execute JavaScript.
6196
6204
  * The applied changes integrate with server DOM patching.
6197
6205
  *
6198
- * See [JavaScript interoperability](https://hexdocs.pm/phoenix_live_view/js-interop.html) for more information.
6206
+ * See [JavaScript interoperability](https://phoenix-live-view.hexdocs.pm/js-interop.html) for more information.
6199
6207
  */
6200
6208
  js() {
6201
6209
  return js_commands_default(this, "js");
@@ -6410,11 +6418,12 @@ var LiveSocket = class {
6410
6418
  `[${this.binding("remove")}]`
6411
6419
  ).filter((el) => !dom_default.isChildOfAny(el, stickies));
6412
6420
  const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
6413
- this.main.showLoader(this.loaderTimeout);
6414
- this.main.destroy();
6421
+ const oldMainView = this.main;
6422
+ oldMainView.showLoader(this.loaderTimeout);
6423
+ oldMainView.destroy();
6415
6424
  this.main = this.newRootView(newMainEl, flash, liveReferer);
6416
6425
  this.main.setRedirect(href);
6417
- this.transitionRemoves(removeEls);
6426
+ this.transitionRemoves(removeEls, oldMainView);
6418
6427
  this.main.join((joinCount, onDone) => {
6419
6428
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
6420
6429
  this.requestDOMUpdate(() => {
@@ -6429,7 +6438,7 @@ var LiveSocket = class {
6429
6438
  });
6430
6439
  }
6431
6440
  /** @internal */
6432
- transitionRemoves(elements, callback) {
6441
+ transitionRemoves(elements, view, callback) {
6433
6442
  const removeAttr = this.binding("remove");
6434
6443
  const silenceEvents = (e) => {
6435
6444
  e.preventDefault();
@@ -6439,7 +6448,8 @@ var LiveSocket = class {
6439
6448
  for (const event of this.boundEventNames) {
6440
6449
  el.addEventListener(event, silenceEvents, true);
6441
6450
  }
6442
- this.execJS(el, el.getAttribute(removeAttr), "remove");
6451
+ const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
6452
+ js_default.exec(e, "remove", el.getAttribute(removeAttr), view, el);
6443
6453
  });
6444
6454
  this.requestDOMUpdate(() => {
6445
6455
  elements.forEach((el) => {
@@ -6465,7 +6475,7 @@ var LiveSocket = class {
6465
6475
  let view;
6466
6476
  const viewEl = dom_default.closestViewEl(childEl);
6467
6477
  if (viewEl) {
6468
- view = this.getViewByEl(viewEl);
6478
+ view = dom_default.private(viewEl, "view");
6469
6479
  } else {
6470
6480
  if (!childEl.isConnected) {
6471
6481
  return null;