@@ -316,6 +316,22 @@ describe('CdkTable', () => {
316
316
expect ( tableElement . firstElementChild ) . toBe ( caption ) ;
317
317
} ) ) ;
318
318
319
+ it ( 'should be able to project colgroup and col' , fakeAsync ( ( ) => {
320
+ setupTableTestApp ( NativeHtmlTableWithColgroupAndCol ) ;
321
+ fixture . detectChanges ( ) ;
322
+
323
+ const colgroupsAndCols = Array . from ( tableElement . querySelectorAll ( 'colgroup, col' ) ) ;
324
+
325
+ expect ( colgroupsAndCols . length ) . toBe ( 3 ) ;
326
+ expect ( colgroupsAndCols [ 0 ] . childNodes [ 0 ] ) . toBe ( colgroupsAndCols [ 1 ] ) ;
327
+ expect ( colgroupsAndCols [ 2 ] . parentNode ! . nodeName . toLowerCase ( ) ) . toBe ( 'table' ) ;
328
+ expect ( colgroupsAndCols . map ( e => e . nodeName . toLowerCase ( ) ) ) . toEqual ( [
329
+ 'colgroup' ,
330
+ 'col' ,
331
+ 'col' ,
332
+ ] ) ;
333
+ } ) ) ;
334
+
319
335
describe ( 'with different data inputs other than data source' , ( ) => {
320
336
let baseData : TestData [ ] = [
321
337
{ a : 'a_1' , b : 'b_1' , c : 'c_1' } ,
@@ -2326,6 +2342,34 @@ class NativeHtmlTableWithCaptionApp {
2326
2342
@ViewChild ( CdkTable ) table : CdkTable < TestData > ;
2327
2343
}
2328
2344
2345
+ @Component ( {
2346
+ template : `
2347
+ <table cdk-table [dataSource]="dataSource">
2348
+ <colgroup>
2349
+ <col>
2350
+ </colgroup>
2351
+ <col>
2352
+ <ng-container cdkColumnDef="column_a">
2353
+ <th cdk-header-cell *cdkHeaderCellDef> Column A</th>
2354
+ <td cdk-cell *cdkCellDef="let row"> {{row.a}}</td>
2355
+ </ng-container>
2356
+ <ng-container cdkColumnDef="column_b">
2357
+ <th cdk-header-cell *cdkHeaderCellDef> Column B</th>
2358
+ <td cdk-cell *cdkCellDef="let row"> {{row.b}}</td>
2359
+ </ng-container>
2360
+
2361
+ <tr cdk-header-row *cdkHeaderRowDef="columnsToRender"></tr>
2362
+ <tr cdk-row *cdkRowDef="let row; columns: columnsToRender" class="customRowClass"></tr>
2363
+ </table>
2364
+ `
2365
+ } )
2366
+ class NativeHtmlTableWithColgroupAndCol {
2367
+ dataSource : FakeDataSource | undefined = new FakeDataSource ( ) ;
2368
+ columnsToRender = [ 'column_a' , 'column_b' ] ;
2369
+
2370
+ @ViewChild ( CdkTable ) table : CdkTable < TestData > ;
2371
+ }
2372
+
2329
2373
@Component ( {
2330
2374
// Note that we need the `ngSwitch` below in order to surface the issue we're testing for.
2331
2375
template : `
0 commit comments