Skip to content

Commit d48eea7

Browse files
committed
[LiveComponent] Show component name and id in processRender error
1 parent 941b7d5 commit d48eea7

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,9 @@ class Component {
21042104
}
21052105
}
21062106
catch (error) {
2107-
console.error('There was a problem with the component HTML returned:');
2107+
console.error(`There was a problem with the '${this.name}' component HTML returned:`, {
2108+
id: this.id
2109+
});
21082110
throw error;
21092111
}
21102112
this.externalMutationTracker.handlePendingChanges();

src/LiveComponent/assets/src/Component/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ export default class Component {
363363
throw new Error('A live component template must contain a single root controller element.');
364364
}
365365
} catch (error) {
366-
console.error('There was a problem with the component HTML returned:');
367-
366+
console.error(`There was a problem with the '${this.name}' component HTML returned:`, {
367+
id: this.id
368+
});
368369
throw error;
369370
}
370371

src/LiveComponent/assets/src/dom_utils.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,8 @@ export function htmlToElement(html: string): HTMLElement {
238238
template.innerHTML = html;
239239

240240
if (template.content.childElementCount > 1) {
241-
let identifier = '';
242-
const firstChild = template.content.firstElementChild;
243-
if (firstChild instanceof HTMLElement) {
244-
identifier = ' Id: ' + firstChild.id;
245-
246-
if (firstChild.dataset.liveNameValue) {
247-
identifier += ' Component: ' + firstChild.dataset.liveNameValue;
248-
}
249-
}
250-
251241
throw new Error(
252-
`Component${identifier} HTML contains ${template.content.childElementCount} elements, but only 1 root element is allowed.`
242+
`Component HTML contains ${template.content.childElementCount} elements, but only 1 root element is allowed.`
253243
);
254244
}
255245

0 commit comments

Comments
 (0)