Skip to content

Commit b6d95f0

Browse files
authored
Update table.ts
I'm using Angular version 18.2 with material version 15.2.x. In this combination, I'm trying to render table using mat-table. "tbody" or "thead" is not created in the DOM and throwing error in the edited line. Hence I'm checking whether the "tbody" is available or not before adding a class to it
1 parent d593195 commit b6d95f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/material/table/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class MatTable<T> extends CdkTable<T> implements OnInit {
7676
// this only applies to native tables, because we don't wrap the content of flexbox-based ones.
7777
if (this._isNativeHtmlTable) {
7878
const tbody = this._elementRef.nativeElement.querySelector('tbody');
79-
tbody.classList.add('mdc-data-table__content');
79+
tbody && tbody.classList.add('mdc-data-table__content');
8080
}
8181
}
8282
}

0 commit comments

Comments
 (0)