Skip to content

Commit 2eb7279

Browse files
committed
fixup! fixup! fix(cdk/table): set default role of table to 'table'
1 parent 989d017 commit 2eb7279

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/cdk/table/cell.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ export class CdkHeaderCell extends BaseCdkCell {
183183
export class CdkFooterCell extends BaseCdkCell {
184184
constructor(columnDef: CdkColumnDef, elementRef: ElementRef) {
185185
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+
}
189191
}
190192
}
191193

@@ -199,8 +201,10 @@ export class CdkFooterCell extends BaseCdkCell {
199201
export class CdkCell extends BaseCdkCell {
200202
constructor(columnDef: CdkColumnDef, elementRef: ElementRef) {
201203
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+
}
205209
}
206210
}

0 commit comments

Comments
 (0)