@tickean/checkout-elements 0.2.0 → 0.2.1

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/index.d.mts CHANGED
@@ -68,6 +68,7 @@ declare class TickeanCheckout extends TickeanElementBase {
68
68
  connectedCallback(): void;
69
69
  disconnectedCallback(): void;
70
70
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
71
+ private teardownOwnedController;
71
72
  private ensureController;
72
73
  protected renderBody(): string;
73
74
  }
package/dist/index.d.ts CHANGED
@@ -68,6 +68,7 @@ declare class TickeanCheckout extends TickeanElementBase {
68
68
  connectedCallback(): void;
69
69
  disconnectedCallback(): void;
70
70
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
71
+ private teardownOwnedController;
71
72
  private ensureController;
72
73
  protected renderBody(): string;
73
74
  }
package/dist/index.js CHANGED
@@ -654,32 +654,38 @@ var TickeanCheckout = class extends TickeanElementBase {
654
654
  }
655
655
  disconnectedCallback() {
656
656
  super.disconnectedCallback();
657
- if (this.ownedControllerId) {
658
- this.ownedController?.dispose();
659
- unregisterController(this.ownedControllerId);
660
- this.ownedControllerId = null;
661
- this.ownedController = null;
662
- }
657
+ this.teardownOwnedController();
663
658
  }
664
659
  attributeChangedCallback(name, oldValue, newValue) {
665
660
  if (["publishable-key", "event-slug", "api-base-url", "return-url", "demo"].includes(
666
661
  name
667
662
  ) && oldValue !== newValue) {
668
- if (this.ownedControllerId) {
669
- this.ownedController?.dispose();
670
- unregisterController(this.ownedControllerId);
671
- this.ownedControllerId = null;
672
- this.ownedController = null;
663
+ if (this.isConnected) {
664
+ this.teardownOwnedController();
665
+ this.ensureController();
673
666
  }
674
- this.ensureController();
675
667
  }
676
668
  super.attributeChangedCallback(name, oldValue, newValue);
677
669
  }
670
+ teardownOwnedController() {
671
+ this.ownedController?.dispose();
672
+ if (this.ownedControllerId) {
673
+ unregisterController(this.ownedControllerId);
674
+ }
675
+ this.ownedControllerId = null;
676
+ this.ownedController = null;
677
+ if (this.hasAttribute(controllerAttr())) {
678
+ this.removeAttribute(controllerAttr());
679
+ }
680
+ }
678
681
  ensureController() {
679
- if (this.getAttribute(controllerAttr())) return;
682
+ if (this.ownedController) return;
680
683
  const eventSlug = this.getAttribute("event-slug");
681
684
  const publishableKey = this.getAttribute("publishable-key") || "";
682
685
  if (!eventSlug) return;
686
+ if (this.getAttribute(controllerAttr())) {
687
+ this.removeAttribute(controllerAttr());
688
+ }
683
689
  const options = {
684
690
  publishableKey,
685
691
  eventSlug,
package/dist/index.mjs CHANGED
@@ -618,32 +618,38 @@ var TickeanCheckout = class extends TickeanElementBase {
618
618
  }
619
619
  disconnectedCallback() {
620
620
  super.disconnectedCallback();
621
- if (this.ownedControllerId) {
622
- this.ownedController?.dispose();
623
- unregisterController(this.ownedControllerId);
624
- this.ownedControllerId = null;
625
- this.ownedController = null;
626
- }
621
+ this.teardownOwnedController();
627
622
  }
628
623
  attributeChangedCallback(name, oldValue, newValue) {
629
624
  if (["publishable-key", "event-slug", "api-base-url", "return-url", "demo"].includes(
630
625
  name
631
626
  ) && oldValue !== newValue) {
632
- if (this.ownedControllerId) {
633
- this.ownedController?.dispose();
634
- unregisterController(this.ownedControllerId);
635
- this.ownedControllerId = null;
636
- this.ownedController = null;
627
+ if (this.isConnected) {
628
+ this.teardownOwnedController();
629
+ this.ensureController();
637
630
  }
638
- this.ensureController();
639
631
  }
640
632
  super.attributeChangedCallback(name, oldValue, newValue);
641
633
  }
634
+ teardownOwnedController() {
635
+ this.ownedController?.dispose();
636
+ if (this.ownedControllerId) {
637
+ unregisterController(this.ownedControllerId);
638
+ }
639
+ this.ownedControllerId = null;
640
+ this.ownedController = null;
641
+ if (this.hasAttribute(controllerAttr())) {
642
+ this.removeAttribute(controllerAttr());
643
+ }
644
+ }
642
645
  ensureController() {
643
- if (this.getAttribute(controllerAttr())) return;
646
+ if (this.ownedController) return;
644
647
  const eventSlug = this.getAttribute("event-slug");
645
648
  const publishableKey = this.getAttribute("publishable-key") || "";
646
649
  if (!eventSlug) return;
650
+ if (this.getAttribute(controllerAttr())) {
651
+ this.removeAttribute(controllerAttr());
652
+ }
647
653
  const options = {
648
654
  publishableKey,
649
655
  eventSlug,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tickean/checkout-elements",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Tickean Checkout web components (Custom Elements)",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",