Skip to content

Commit

Permalink
fix: 🐛 lifecycle callbacks are called after creating widget
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed Nov 15, 2024
1 parent fd69676 commit 45b4c21
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/integration-custom-element/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function registerCustomElement(options) {
super._init();
const customWidgetDefinition = deepMerge({}, widgetDefinition);

(async () => {
this._widgetPromise = (async () => {
this._shadow = this.attachShadow({ mode: 'open' });

try {
Expand Down Expand Up @@ -130,7 +130,9 @@ function registerCustomElement(options) {
}
}

connectedCallback() {
async connectedCallback() {
await this._widgetPromise;

this._widget?.connectedCallback?.({
shadow: this._shadow,
customElement: this,
Expand All @@ -142,7 +144,9 @@ function registerCustomElement(options) {
});
}

disconnectedCallback() {
async disconnectedCallback() {
await this._widgetPromise;

this._widget?.disconnectedCallback?.({
shadow: this._shadow,
customElement: this,
Expand All @@ -154,7 +158,9 @@ function registerCustomElement(options) {
});
}

adoptedCallback() {
async adoptedCallback() {
await this._widgetPromise;

this._widget?.adoptedCallback?.({
shadow: this._shadow,
customElement: this,
Expand All @@ -166,7 +172,9 @@ function registerCustomElement(options) {
});
}

attributeChangedCallback(name, oldValue, newValue) {
async attributeChangedCallback(name, oldValue, newValue) {
await this._widgetPromise;

this._widget?.attributeChangedCallback?.(
this._widget,
name,
Expand Down

0 comments on commit 45b4c21

Please sign in to comment.