@saasquatch/squatch-js 2.6.1 → 2.6.2-0
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.
- package/dist/squatch.esm.js +33 -1
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +33 -1
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/dist/widgets/Widget.d.ts +3 -0
- package/package.json +1 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -406,7 +406,6 @@ function _validateAnalyticsConfig(raw) {
|
|
|
406
406
|
return raw;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
// @ts-check
|
|
410
409
|
/** @hidden */
|
|
411
410
|
|
|
412
411
|
var _log$8 = debug("squatch-js:widget");
|
|
@@ -431,6 +430,7 @@ class Widget {
|
|
|
431
430
|
this.context = void 0;
|
|
432
431
|
this.npmCdn = void 0;
|
|
433
432
|
this.container = void 0;
|
|
433
|
+
this.loadEventListener = null;
|
|
434
434
|
|
|
435
435
|
_log$8("widget initializing ...");
|
|
436
436
|
|
|
@@ -491,6 +491,26 @@ class Widget {
|
|
|
491
491
|
return parent.querySelector("iframe#squatchFrame");
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
_detachLoadEventListener(frameDoc) {
|
|
495
|
+
if (this.loadEventListener) {
|
|
496
|
+
frameDoc.removeEventListener("sq:user-registration", this.loadEventListener);
|
|
497
|
+
this.loadEventListener = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
_attachLoadEventListener(frameDoc, sqh) {
|
|
502
|
+
if (this.loadEventListener === null) {
|
|
503
|
+
this.loadEventListener = e => {
|
|
504
|
+
this._loadEvent(_extends({}, sqh, {
|
|
505
|
+
userId: e.detail.userId,
|
|
506
|
+
accountId: e.detail.accountId
|
|
507
|
+
}));
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
frameDoc.addEventListener("sq:user-registration", this.loadEventListener);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
494
514
|
_loadEvent(sqh) {
|
|
495
515
|
var _this$analyticsApi$pu;
|
|
496
516
|
|
|
@@ -812,6 +832,8 @@ class EmbedWidget extends Widget {
|
|
|
812
832
|
this._loadEvent(_sqh);
|
|
813
833
|
|
|
814
834
|
_log$7("loaded");
|
|
835
|
+
} else {
|
|
836
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
815
837
|
}
|
|
816
838
|
});
|
|
817
839
|
}
|
|
@@ -839,6 +861,10 @@ class EmbedWidget extends Widget {
|
|
|
839
861
|
this._loadEvent(_sqh);
|
|
840
862
|
|
|
841
863
|
_log$7("loaded");
|
|
864
|
+
} else {
|
|
865
|
+
if (!frame.contentDocument) return;
|
|
866
|
+
|
|
867
|
+
this._attachLoadEventListener(frame.contentDocument, _sqh);
|
|
842
868
|
}
|
|
843
869
|
}
|
|
844
870
|
|
|
@@ -846,6 +872,7 @@ class EmbedWidget extends Widget {
|
|
|
846
872
|
var frame = this._findFrame();
|
|
847
873
|
|
|
848
874
|
if (!frame) return _log$7("no target element to close");
|
|
875
|
+
if (frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
849
876
|
|
|
850
877
|
var element = this._findElement();
|
|
851
878
|
|
|
@@ -1052,11 +1079,16 @@ class PopupWidget extends Widget {
|
|
|
1052
1079
|
this._loadEvent(_sqh);
|
|
1053
1080
|
|
|
1054
1081
|
_log$6("Popup opened");
|
|
1082
|
+
} else {
|
|
1083
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1055
1084
|
}
|
|
1056
1085
|
});
|
|
1057
1086
|
}
|
|
1058
1087
|
|
|
1059
1088
|
close() {
|
|
1089
|
+
var frame = this._findFrame();
|
|
1090
|
+
|
|
1091
|
+
if (frame != null && frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
1060
1092
|
var element = this.container ? this._findElement() : document.body;
|
|
1061
1093
|
var parent = element.shadowRoot || element;
|
|
1062
1094
|
var dialog = parent.querySelector("#" + this.id);
|