phoenix_live_view 0.18.8 → 0.18.10

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.
@@ -634,8 +634,8 @@ export default class LiveSocket {
634
634
  }
635
635
  let phxEvent = target && target.getAttribute(click)
636
636
  if(!phxEvent){
637
- let href = e.target.href
638
- if(!capture && href !== undefined && !DOM.wantsNewTab(e) && DOM.isNewPageHref(href, window.location)){
637
+ let href = e.target instanceof HTMLAnchorElement ? e.target.getAttribute("href") : null
638
+ if(!capture && href !== null && !DOM.wantsNewTab(e) && DOM.isNewPageHref(href, window.location)){
639
639
  this.unload()
640
640
  }
641
641
  return
@@ -801,17 +801,23 @@ export default class LiveSocket {
801
801
  if(!externalFormSubmitted && phxChange && !phxSubmit){
802
802
  externalFormSubmitted = true
803
803
  e.preventDefault()
804
- this.unload()
805
804
  this.withinOwners(e.target, view => {
806
805
  view.disableForm(e.target)
807
- window.requestAnimationFrame(() => e.target.submit()) // safari needs next tick
806
+ // safari needs next tick
807
+ window.requestAnimationFrame(() => {
808
+ if(!DOM.wantsNewTab(e)){ this.unload() }
809
+ e.target.submit()
810
+ })
808
811
  })
809
812
  }
810
813
  }, true)
811
814
 
812
815
  this.on("submit", e => {
813
816
  let phxEvent = e.target.getAttribute(this.binding("submit"))
814
- if(!phxEvent){ return this.unload() }
817
+ if(!phxEvent){
818
+ if(!DOM.wantsNewTab(e)){ this.unload() }
819
+ return
820
+ }
815
821
  e.preventDefault()
816
822
  e.target.disabled = true
817
823
  this.withinOwners(e.target, view => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phoenix_live_view",
3
- "version": "0.18.8",
3
+ "version": "0.18.10",
4
4
  "description": "The Phoenix LiveView JavaScript client.",
5
5
  "license": "MIT",
6
6
  "repository": {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phoenix_live_view",
3
- "version": "0.18.8",
3
+ "version": "0.18.10",
4
4
  "description": "The Phoenix LiveView JavaScript client.",
5
5
  "license": "MIT",
6
6
  "module": "./priv/static/phoenix_live_view.esm.js",
@@ -3848,8 +3848,8 @@ var LiveSocket = class {
3848
3848
  }
3849
3849
  let phxEvent = target && target.getAttribute(click);
3850
3850
  if (!phxEvent) {
3851
- let href = e.target.href;
3852
- if (!capture && href !== void 0 && !dom_default.wantsNewTab(e) && dom_default.isNewPageHref(href, window.location)) {
3851
+ let href = e.target instanceof HTMLAnchorElement ? e.target.getAttribute("href") : null;
3852
+ if (!capture && href !== null && !dom_default.wantsNewTab(e) && dom_default.isNewPageHref(href, window.location)) {
3853
3853
  this.unload();
3854
3854
  }
3855
3855
  return;
@@ -4014,17 +4014,24 @@ var LiveSocket = class {
4014
4014
  if (!externalFormSubmitted && phxChange && !phxSubmit) {
4015
4015
  externalFormSubmitted = true;
4016
4016
  e.preventDefault();
4017
- this.unload();
4018
4017
  this.withinOwners(e.target, (view) => {
4019
4018
  view.disableForm(e.target);
4020
- window.requestAnimationFrame(() => e.target.submit());
4019
+ window.requestAnimationFrame(() => {
4020
+ if (!dom_default.wantsNewTab(e)) {
4021
+ this.unload();
4022
+ }
4023
+ e.target.submit();
4024
+ });
4021
4025
  });
4022
4026
  }
4023
4027
  }, true);
4024
4028
  this.on("submit", (e) => {
4025
4029
  let phxEvent = e.target.getAttribute(this.binding("submit"));
4026
4030
  if (!phxEvent) {
4027
- return this.unload();
4031
+ if (!dom_default.wantsNewTab(e)) {
4032
+ this.unload();
4033
+ }
4034
+ return;
4028
4035
  }
4029
4036
  e.preventDefault();
4030
4037
  e.target.disabled = true;