Skip to content

Commit

Permalink
feat: show tag name on error during render
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiksta committed Nov 6, 2023
1 parent 6238acb commit 28b51c4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,15 @@ export default abstract class Component<
(this.shadowRoot || this).innerHTML = '';

this._lifecycleHooks = { removed: [], render: [] };
this._template = this.render();
this.lifecycleState = "added";
for (let el of this._template) {
(this.shadowRoot || this).appendChild(this._renderTemplate(el));
try {
this._template = this.render();
this.lifecycleState = "added";
for (let el of this._template) {
(this.shadowRoot || this).appendChild(this._renderTemplate(el));
}
} catch(e) {
console.warn(`Mvui: Error while rendering ${this.tagName}`);
throw e;
}

if ((this.constructor as any).styles)
Expand Down Expand Up @@ -683,9 +688,11 @@ export default abstract class Component<
const val = el.params.style[key]!;
if (isSubscribable<ToStringable>(val)) {
this.subscribe(val, v => {
if (v === undefined) return;
thisEl.style[key] = v.toString();
});
} else {
if (val === undefined) return;
thisEl.style[key] = val.toString();
}
}
Expand Down

0 comments on commit 28b51c4

Please sign in to comment.