@@ -183,9 +183,11 @@ export class CdkHeaderCell extends BaseCdkCell {
183
183
export class CdkFooterCell extends BaseCdkCell {
184
184
constructor ( columnDef : CdkColumnDef , elementRef : ElementRef ) {
185
185
super ( columnDef , elementRef ) ;
186
- const role = columnDef . _table . _elementRef . nativeElement
187
- . getAttribute ( 'role' ) === 'table' ? 'cell' : 'gridcell' ;
188
- elementRef . nativeElement . setAttribute ( 'role' , role ) ;
186
+ if ( columnDef . _table ?. _elementRef . nativeElement . nodeType === 1 ) {
187
+ const role = columnDef . _table . _elementRef . nativeElement
188
+ . getAttribute ( 'role' ) === 'table' ? 'cell' : 'gridcell' ;
189
+ elementRef . nativeElement . setAttribute ( 'role' , role ) ;
190
+ }
189
191
}
190
192
}
191
193
@@ -199,8 +201,10 @@ export class CdkFooterCell extends BaseCdkCell {
199
201
export class CdkCell extends BaseCdkCell {
200
202
constructor ( columnDef : CdkColumnDef , elementRef : ElementRef ) {
201
203
super ( columnDef , elementRef ) ;
202
- const role = columnDef . _table . _elementRef . nativeElement
203
- . getAttribute ( 'role' ) === 'table' ? 'cell' : 'gridcell' ;
204
- elementRef . nativeElement . setAttribute ( 'role' , role ) ;
204
+ if ( columnDef . _table ?. _elementRef . nativeElement . nodeType === 1 ) {
205
+ const role = columnDef . _table . _elementRef . nativeElement
206
+ . getAttribute ( 'role' ) === 'table' ? 'cell' : 'gridcell' ;
207
+ elementRef . nativeElement . setAttribute ( 'role' , role ) ;
208
+ }
205
209
}
206
210
}
0 commit comments