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.
@@ -689,7 +689,9 @@ var LiveView = (() => {
689
689
  if (this.once(el, "bind-debounce")) {
690
690
  el.addEventListener("blur", () => {
691
691
  clearTimeout(this.private(el, THROTTLED));
692
- this.triggerCycle(el, DEBOUNCE_TRIGGER);
692
+ if (asyncFilter()) {
693
+ this.triggerCycle(el, DEBOUNCE_TRIGGER);
694
+ }
693
695
  });
694
696
  }
695
697
  }
@@ -2847,7 +2849,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
2847
2849
  transitionPendingRemoves() {
2848
2850
  const { pendingRemoves, liveSocket } = this;
2849
2851
  if (pendingRemoves.length > 0) {
2850
- liveSocket.transitionRemoves(pendingRemoves, () => {
2852
+ liveSocket.transitionRemoves(pendingRemoves, this.view, () => {
2851
2853
  pendingRemoves.forEach((el) => {
2852
2854
  const child = dom_default.firstPhxChild(el);
2853
2855
  if (child) {
@@ -4476,6 +4478,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4476
4478
  if (container) {
4477
4479
  const [tag, attrs] = container;
4478
4480
  this.el = dom_default.replaceRootContainer(this.el, tag, attrs);
4481
+ dom_default.putPrivate(this.el, "view", this);
4479
4482
  }
4480
4483
  this.childJoins = 0;
4481
4484
  this.joinPending = true;
@@ -4562,6 +4565,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4562
4565
  throw new Error("unable to find root element for view");
4563
4566
  }
4564
4567
  this.el = el;
4568
+ dom_default.putPrivate(this.el, "view", this);
4565
4569
  this.el.setAttribute(PHX_ROOT_ID, this.root.id);
4566
4570
  }
4567
4571
  // this is invoked for dead and live views, so we must filter by
@@ -4752,6 +4756,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4752
4756
  rootEl.setAttribute(PHX_SESSION, this.getSession());
4753
4757
  rootEl.setAttribute(PHX_STATIC, (_a = this.getStatic()) != null ? _a : "");
4754
4758
  this.parent && rootEl.setAttribute(PHX_PARENT_ID, this.parent.id);
4759
+ dom_default.putPrivate(rootEl, "view", this);
4755
4760
  const formsToRecover = (
4756
4761
  // we go over all forms in the new DOM; because this is only the HTML for the current
4757
4762
  // view, we can be sure that all forms are owned by this view:
@@ -5047,6 +5052,9 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
5047
5052
  });
5048
5053
  }
5049
5054
  onJoinError(resp) {
5055
+ if (resp.events) {
5056
+ this.liveSocket.dispatchEvents(resp.events);
5057
+ }
5050
5058
  if (resp.reason === "reload") {
5051
5059
  this.log("error", () => [
5052
5060
  `failed mount with ${resp.status}. Falling back to page reload`,
@@ -6109,7 +6117,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6109
6117
  * Returns the version of the LiveView client.
6110
6118
  */
6111
6119
  version() {
6112
- return "1.2.0-rc.3";
6120
+ return "1.2.1";
6113
6121
  }
6114
6122
  /**
6115
6123
  * Returns true if profiling is enabled. See {@link enableProfiling} and {@link disableProfiling}.
@@ -6133,7 +6141,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6133
6141
  * Enables debugging.
6134
6142
  *
6135
6143
  * When debugging is enabled, the LiveView client will log debug information to the console.
6136
- * See [Debugging client events](https://hexdocs.pm/phoenix_live_view/js-interop.html#debugging-client-events) for more information.
6144
+ * See [Debugging client events](https://phoenix-live-view.hexdocs.pm/js-interop.html#debugging-client-events) for more information.
6137
6145
  */
6138
6146
  enableDebug() {
6139
6147
  this.sessionStorage.setItem(PHX_LV_DEBUG, "true");
@@ -6162,7 +6170,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6162
6170
  * Enables latency simulation.
6163
6171
  *
6164
6172
  * When latency simulation is enabled, the LiveView client will add a delay to requests and responses from the server.
6165
- * See [Simulating Latency](https://hexdocs.pm/phoenix_live_view/js-interop.html#simulating-latency) for more information.
6173
+ * See [Simulating Latency](https://phoenix-live-view.hexdocs.pm/js-interop.html#simulating-latency) for more information.
6166
6174
  */
6167
6175
  enableLatencySim(upperBoundMs) {
6168
6176
  this.enableDebug();
@@ -6237,7 +6245,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6237
6245
  /**
6238
6246
  * Executes an encoded JS command, targeting the given element.
6239
6247
  *
6240
- * See [`Phoenix.LiveView.JS`](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.JS.html) for more information.
6248
+ * See [`Phoenix.LiveView.JS`](https://phoenix-live-view.hexdocs.pm/Phoenix.LiveView.JS.html) for more information.
6241
6249
  */
6242
6250
  execJS(el, encodedJS, eventType = null) {
6243
6251
  const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
@@ -6247,7 +6255,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6247
6255
  * Returns an object with methods to manipulate the DOM and execute JavaScript.
6248
6256
  * The applied changes integrate with server DOM patching.
6249
6257
  *
6250
- * See [JavaScript interoperability](https://hexdocs.pm/phoenix_live_view/js-interop.html) for more information.
6258
+ * See [JavaScript interoperability](https://phoenix-live-view.hexdocs.pm/js-interop.html) for more information.
6251
6259
  */
6252
6260
  js() {
6253
6261
  return js_commands_default(this, "js");
@@ -6463,11 +6471,12 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6463
6471
  `[${this.binding("remove")}]`
6464
6472
  ).filter((el) => !dom_default.isChildOfAny(el, stickies));
6465
6473
  const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
6466
- this.main.showLoader(this.loaderTimeout);
6467
- this.main.destroy();
6474
+ const oldMainView = this.main;
6475
+ oldMainView.showLoader(this.loaderTimeout);
6476
+ oldMainView.destroy();
6468
6477
  this.main = this.newRootView(newMainEl, flash, liveReferer);
6469
6478
  this.main.setRedirect(href);
6470
- this.transitionRemoves(removeEls);
6479
+ this.transitionRemoves(removeEls, oldMainView);
6471
6480
  this.main.join((joinCount, onDone) => {
6472
6481
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
6473
6482
  this.requestDOMUpdate(() => {
@@ -6482,7 +6491,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6482
6491
  });
6483
6492
  }
6484
6493
  /** @internal */
6485
- transitionRemoves(elements, callback) {
6494
+ transitionRemoves(elements, view, callback) {
6486
6495
  const removeAttr = this.binding("remove");
6487
6496
  const silenceEvents = (e) => {
6488
6497
  e.preventDefault();
@@ -6492,7 +6501,8 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6492
6501
  for (const event of this.boundEventNames) {
6493
6502
  el.addEventListener(event, silenceEvents, true);
6494
6503
  }
6495
- this.execJS(el, el.getAttribute(removeAttr), "remove");
6504
+ const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
6505
+ js_default.exec(e, "remove", el.getAttribute(removeAttr), view, el);
6496
6506
  });
6497
6507
  this.requestDOMUpdate(() => {
6498
6508
  elements.forEach((el) => {
@@ -6518,7 +6528,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6518
6528
  let view;
6519
6529
  const viewEl = dom_default.closestViewEl(childEl);
6520
6530
  if (viewEl) {
6521
- view = this.getViewByEl(viewEl);
6531
+ view = dom_default.private(viewEl, "view");
6522
6532
  } else {
6523
6533
  if (!childEl.isConnected) {
6524
6534
  return null;