@saasquatch/squatch-js 2.8.2-15 → 2.8.2-17

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.
@@ -1116,6 +1116,72 @@ class EmbedWidget extends Widget {
1116
1116
  this.container = container;
1117
1117
  }
1118
1118
  }
1119
+ //Old code for testing
1120
+ // async load() {
1121
+ // const brandingConfig = this.context.widgetConfig?.values?.brandingConfig;
1122
+ // const sizes = brandingConfig?.widgetSize?.embeddedWidgets;
1123
+ // const maxWidth = sizes?.maxWidth ? formatWidth(sizes.maxWidth) : "";
1124
+ // const minWidth = sizes?.minWidth ? formatWidth(sizes.minWidth) : "";
1125
+ // const frame = this._createFrame({ minWidth, maxWidth });
1126
+ // const element = this._findElement();
1127
+ // if (this.context?.container) {
1128
+ // // Custom container is used
1129
+ // element.style.visibility = "hidden";
1130
+ // element.style.height = "0";
1131
+ // element.style["overflow-y"] = "hidden";
1132
+ // }
1133
+ // if (this.container) {
1134
+ // if (element.shadowRoot) {
1135
+ // if (element.shadowRoot.lastChild?.nodeName === "IFRAME") {
1136
+ // element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
1137
+ // } else {
1138
+ // element.shadowRoot.appendChild(frame);
1139
+ // }
1140
+ // }
1141
+ // // Widget reloaded - replace existing element
1142
+ // else if (element.firstChild) {
1143
+ // element.replaceChild(frame, element.firstChild);
1144
+ // // Add iframe for the first time
1145
+ // } else {
1146
+ // element.appendChild(frame);
1147
+ // }
1148
+ // } else if (!element.firstChild || element.firstChild.nodeName === "#text") {
1149
+ // element.appendChild(frame);
1150
+ // }
1151
+ // const { contentWindow } = frame;
1152
+ // if (!contentWindow) {
1153
+ // throw new Error("Frame needs a content window");
1154
+ // }
1155
+ // const frameDoc = contentWindow.document;
1156
+ // frameDoc.open();
1157
+ // frameDoc.write(this.content);
1158
+ // frameDoc.write(
1159
+ // `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1160
+ // );
1161
+ // frameDoc.close();
1162
+ // domready(frameDoc, async () => {
1163
+ // const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1164
+ // // @ts-ignore -- number will be cast to string by browsers
1165
+ // frame.height = frameDoc.body.scrollHeight;
1166
+ // // Adjust frame height when size of body changes
1167
+ // /* istanbul ignore next: hard to test */
1168
+ // const ro = new contentWindow["ResizeObserver"]((entries) => {
1169
+ // for (const entry of entries) {
1170
+ // const { height } = entry.contentRect;
1171
+ // // @ts-ignore -- number will be cast to string by browsers
1172
+ // frame.height = height;
1173
+ // }
1174
+ // });
1175
+ // const container = await this._findInnerContainer(frame);
1176
+ // ro.observe(container);
1177
+ // if (this._shouldFireLoadEvent()) {
1178
+ // this._loadEvent(_sqh);
1179
+ // _log("loaded");
1180
+ // } else if (frameDoc) {
1181
+ // this._attachLoadEventListener(frameDoc, _sqh);
1182
+ // }
1183
+ // });
1184
+ // }
1119
1185
  async load() {
1120
1186
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1121
1187
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
@@ -1154,8 +1220,7 @@ class EmbedWidget extends Widget {
1154
1220
  injectContents(element.shadowRoot);
1155
1221
  }
1156
1222
  } else if (element.firstChild) {
1157
- element.innerHTML = "";
1158
- injectContents(element);
1223
+ element.replaceChild(frame, element.firstChild);
1159
1224
  } else {
1160
1225
  injectContents(element);
1161
1226
  }
@@ -1187,7 +1252,6 @@ class EmbedWidget extends Widget {
1187
1252
  `);
1188
1253
  frameDoc.close();
1189
1254
  domready(frameDoc, async () => {
1190
- frame.style.display = "block";
1191
1255
  const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1192
1256
  frame.height = initialHeight || frameDoc.body.scrollHeight;
1193
1257
  console.log({ height: frameDoc.body.scrollHeight });