@@ -316,6 +316,22 @@ describe('CdkTable', () => {
316316 expect ( tableElement . firstElementChild ) . toBe ( caption ) ;
317317 } ) ) ;
318318
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+
319335 describe ( 'with different data inputs other than data source' , ( ) => {
320336 let baseData : TestData [ ] = [
321337 { a : 'a_1' , b : 'b_1' , c : 'c_1' } ,
@@ -2326,6 +2342,34 @@ class NativeHtmlTableWithCaptionApp {
23262342 @ViewChild ( CdkTable ) table : CdkTable < TestData > ;
23272343}
23282344
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+
23292373@Component ( {
23302374 // Note that we need the `ngSwitch` below in order to surface the issue we're testing for.
23312375 template : `
0 commit comments