Skip to content

Commit

Permalink
fix: 🐛 attributeChangedCallback waits for widget instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.kucera committed Nov 15, 2024
1 parent b631550 commit 35828df
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 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 @@ -167,27 +167,29 @@ function registerCustomElement(options) {
}

attributeChangedCallback(name, oldValue, newValue) {
this._widget?.attributeChangedCallback?.(
this._widget,
name,
oldValue,
newValue,
{
shadow: this._shadow,
customElement: this,
},
);

callbacks?.attributeChangedCallback?.(
this._widget,
name,
oldValue,
newValue,
{
shadow: this._shadow,
customElement: this,
},
);
this._widgetPromise.then(() => {
this._widget?.attributeChangedCallback?.(
this._widget,
name,
oldValue,
newValue,
{
shadow: this._shadow,
customElement: this,
},
);

callbacks?.attributeChangedCallback?.(
this._widget,
name,
oldValue,
newValue,
{
shadow: this._shadow,
customElement: this,
},
);
});
}
}

Expand Down

0 comments on commit 35828df

Please sign in to comment.