phoenix_live_view 1.0.3 → 1.0.4

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.
@@ -1195,9 +1195,11 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
1195
1195
  aria_default.focusFirst(this.el);
1196
1196
  }
1197
1197
  });
1198
- this.el.addEventListener("phx:show-end", () => this.el.focus());
1199
- if (window.getComputedStyle(this.el).display !== "none") {
1200
- aria_default.focusFirst(this.el);
1198
+ if (!this.el.contains(document.activeElement)) {
1199
+ this.el.addEventListener("phx:show-end", () => this.el.focus());
1200
+ if (window.getComputedStyle(this.el).display !== "none") {
1201
+ aria_default.focusFirst(this.el);
1202
+ }
1201
1203
  }
1202
1204
  }
1203
1205
  }
@@ -1495,7 +1497,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
1495
1497
  }
1496
1498
  };
1497
1499
 
1498
- // node_modules/morphdom/dist/morphdom-esm.js
1500
+ // ../node_modules/morphdom/dist/morphdom-esm.js
1499
1501
  var DOCUMENT_FRAGMENT_NODE = 11;
1500
1502
  function morphAttrs(fromNode, toNode) {
1501
1503
  var toNodeAttrs = toNode.attributes;
@@ -2372,7 +2374,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
2372
2374
  transitionPendingRemoves() {
2373
2375
  let { pendingRemoves, liveSocket } = this;
2374
2376
  if (pendingRemoves.length > 0) {
2375
- liveSocket.transitionRemoves(pendingRemoves, false, () => {
2377
+ liveSocket.transitionRemoves(pendingRemoves, () => {
2376
2378
  pendingRemoves.forEach((el) => {
2377
2379
  let child = dom_default.firstPhxChild(el);
2378
2380
  if (child) {
@@ -2832,10 +2834,10 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
2832
2834
  view.liveSocket.pushHistoryPatch(e, href, replace ? "replace" : "push", sourceEl);
2833
2835
  },
2834
2836
  exec_focus(e, eventType, phxEvent, view, sourceEl, el) {
2835
- window.requestAnimationFrame(() => aria_default.attemptFocus(el));
2837
+ aria_default.attemptFocus(el);
2836
2838
  },
2837
2839
  exec_focus_first(e, eventType, phxEvent, view, sourceEl, el) {
2838
- window.requestAnimationFrame(() => aria_default.focusFirstInteractive(el) || aria_default.focusFirst(el));
2840
+ aria_default.focusFirstInteractive(el) || aria_default.focusFirst(el);
2839
2841
  },
2840
2842
  exec_push_focus(e, eventType, phxEvent, view, sourceEl, el) {
2841
2843
  window.requestAnimationFrame(() => focusStack.push(el || sourceEl));
@@ -2941,18 +2943,14 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
2941
2943
  }
2942
2944
  } else {
2943
2945
  if (this.isVisible(el)) {
2944
- window.requestAnimationFrame(() => {
2945
- el.dispatchEvent(new Event("phx:hide-start"));
2946
- dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = "none");
2947
- el.dispatchEvent(new Event("phx:hide-end"));
2948
- });
2946
+ el.dispatchEvent(new Event("phx:hide-start"));
2947
+ dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = "none");
2948
+ el.dispatchEvent(new Event("phx:hide-end"));
2949
2949
  } else {
2950
- window.requestAnimationFrame(() => {
2951
- el.dispatchEvent(new Event("phx:show-start"));
2952
- let stickyDisplay = display || this.defaultDisplay(el);
2953
- dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
2954
- el.dispatchEvent(new Event("phx:show-end"));
2955
- });
2950
+ el.dispatchEvent(new Event("phx:show-start"));
2951
+ let stickyDisplay = display || this.defaultDisplay(el);
2952
+ dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
2953
+ el.dispatchEvent(new Event("phx:show-end"));
2956
2954
  }
2957
2955
  }
2958
2956
  },
@@ -4796,7 +4794,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
4796
4794
  }
4797
4795
  // public
4798
4796
  version() {
4799
- return "1.0.3";
4797
+ return "1.0.4";
4800
4798
  }
4801
4799
  isProfileEnabled() {
4802
4800
  return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
@@ -5014,20 +5012,21 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
5014
5012
  browser_default.redirect(to, flash);
5015
5013
  }
5016
5014
  replaceMain(href, flash, callback = null, linkRef = this.setPendingLink(href)) {
5017
- let liveReferer = this.currentLocation.href;
5015
+ const liveReferer = this.currentLocation.href;
5018
5016
  this.outgoingMainEl = this.outgoingMainEl || this.main.el;
5019
- let removeEls = dom_default.all(this.outgoingMainEl, `[${this.binding("remove")}]`);
5020
- let newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
5017
+ const stickies = dom_default.findPhxSticky(document) || [];
5018
+ const removeEls = dom_default.all(this.outgoingMainEl, `[${this.binding("remove")}]`).filter((el) => !dom_default.isChildOfAny(el, stickies));
5019
+ const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
5021
5020
  this.main.showLoader(this.loaderTimeout);
5022
5021
  this.main.destroy();
5023
5022
  this.main = this.newRootView(newMainEl, flash, liveReferer);
5024
5023
  this.main.setRedirect(href);
5025
- this.transitionRemoves(removeEls, true);
5024
+ this.transitionRemoves(removeEls);
5026
5025
  this.main.join((joinCount, onDone) => {
5027
5026
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
5028
5027
  this.requestDOMUpdate(() => {
5029
5028
  removeEls.forEach((el) => el.remove());
5030
- dom_default.findPhxSticky(document).forEach((el) => newMainEl.appendChild(el));
5029
+ stickies.forEach((el) => newMainEl.appendChild(el));
5031
5030
  this.outgoingMainEl.replaceWith(newMainEl);
5032
5031
  this.outgoingMainEl = null;
5033
5032
  callback && callback(linkRef);
@@ -5036,12 +5035,8 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
5036
5035
  }
5037
5036
  });
5038
5037
  }
5039
- transitionRemoves(elements, skipSticky, callback) {
5038
+ transitionRemoves(elements, callback) {
5040
5039
  let removeAttr = this.binding("remove");
5041
- if (skipSticky) {
5042
- const stickies = dom_default.findPhxSticky(document) || [];
5043
- elements = elements.filter((el) => !dom_default.isChildOfAny(el, stickies));
5044
- }
5045
5040
  let silenceEvents = (e) => {
5046
5041
  e.preventDefault();
5047
5042
  e.stopImmediatePropagation();
@@ -5401,7 +5396,8 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
5401
5396
  this.registerNewLocation(window.location);
5402
5397
  }
5403
5398
  historyRedirect(e, href, linkState, flash, targetEl) {
5404
- if (targetEl && e.isTrusted && e.type !== "popstate") {
5399
+ const clickLoading = targetEl && e.isTrusted && e.type !== "popstate";
5400
+ if (clickLoading) {
5405
5401
  targetEl.classList.add("phx-click-loading");
5406
5402
  }
5407
5403
  if (!this.isConnected() || !this.main.isMain()) {
@@ -5427,6 +5423,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
5427
5423
  dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false, direction: "forward" } });
5428
5424
  this.registerNewLocation(window.location);
5429
5425
  }
5426
+ if (clickLoading) {
5427
+ targetEl.classList.remove("phx-click-loading");
5428
+ }
5430
5429
  done();
5431
5430
  });
5432
5431
  });