Skip to content

Commit

Permalink
fix: 🐛 all callbacks are optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed May 8, 2024
1 parent bc58fd6 commit 52e7b99
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/integration-custom-element/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function registerCustomElement(options) {
constructor() {
super();

const widget = callbacks?.getSingleton();
const widget = callbacks?.getSingleton?.();

if (widget && widget.name && widget.version) {
this._widget = widget;
Expand All @@ -62,27 +62,27 @@ function registerCustomElement(options) {
this._widget = await createSPAWidget(widgetDefinition);
this._widget.mount();

callbacks?.constructor(this._widget);
callbacks?.constructor?.(this._widget);
} catch (error) {
console.error(error);
}
})();
}

connectedCallback() {
callbacks?.connectedCallback(this._widget);
callbacks?.connectedCallback?.(this._widget);
}

disconnectedCallback() {
callbacks?.disconnectedCallback(this._widget);
callbacks?.disconnectedCallback?.(this._widget);
}

adoptedCallback() {
callbacks?.adoptedCallback(this._widget);
callbacks?.adoptedCallback?.(this._widget);
}

attributeChangedCallback(name, oldValue, newValue) {
callbacks?.attributeChangedCallback(
callbacks?.attributeChangedCallback?.(
this._widget,
name,
oldValue,
Expand Down

0 comments on commit 52e7b99

Please sign in to comment.