@saasquatch/squatch-js 2.8.2-4 → 2.8.2-6

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.js CHANGED
@@ -2466,25 +2466,52 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2466
2466
  break;
2467
2467
  }
2468
2468
  }
2469
+ // async connectedCallback() {
2470
+ // this.loaded = true;
2471
+ // this.container = this.getAttribute("container");
2472
+ // // Dynamically assign arbitrary HTML content before rendering the widget
2473
+ // const dynamicContent = `
2474
+ // <div>
2475
+ // <h1>Dynamic Content</h1>
2476
+ // <p>This content was dynamically added to the widget before it loaded.</p>
2477
+ // </div>
2478
+ // `;
2479
+ // if (this.container) {
2480
+ // const containerElement = document.querySelector(this.container);
2481
+ // if (containerElement) {
2482
+ // containerElement.innerHTML = dynamicContent;
2483
+ // }
2484
+ // }
2485
+ // // Render the widget after setting the dynamic content
2486
+ // await this.renderWidget();
2487
+ // const slot = (
2488
+ // this.shadowRoot && Array.from(this.shadowRoot.children)
2489
+ // )?.find((c) => c.tagName === "SLOT") as Node;
2490
+ // if (slot) this.shadowRoot?.removeChild(slot);
2491
+ // if (this.getAttribute("open") !== null) this.open();
2492
+ // }
2493
+ // }
2469
2494
  async connectedCallback() {
2470
- var _a2, _b;
2495
+ var _a2;
2471
2496
  this.loaded = true;
2472
2497
  this.container = this.getAttribute("container");
2473
2498
  const dynamicContent = `
2474
- <div>
2499
+ <div id="dynamic-content">
2475
2500
  <h1>Dynamic Content</h1>
2476
2501
  <p>This content was dynamically added to the widget before it loaded.</p>
2477
2502
  </div>
2478
2503
  `;
2479
- if (this.container) {
2480
- const containerElement = document.querySelector(this.container);
2481
- if (containerElement) {
2482
- containerElement.innerHTML = dynamicContent;
2483
- }
2504
+ if (!this.shadowRoot) {
2505
+ this.attachShadow({ mode: "open" });
2506
+ }
2507
+ if (this.shadowRoot) {
2508
+ this.shadowRoot.innerHTML = dynamicContent;
2484
2509
  }
2485
2510
  await this.renderWidget();
2486
- const slot = (_a2 = this.shadowRoot && Array.from(this.shadowRoot.children)) == null ? void 0 : _a2.find((c) => c.tagName === "SLOT");
2487
- if (slot) (_b = this.shadowRoot) == null ? void 0 : _b.removeChild(slot);
2511
+ const dynamicElement = (_a2 = this.shadowRoot) == null ? void 0 : _a2.getElementById("dynamic-content");
2512
+ if (dynamicElement) {
2513
+ dynamicElement.remove();
2514
+ }
2488
2515
  if (this.getAttribute("open") !== null) this.open();
2489
2516
  }
2490
2517
  }