table.ts (material2-7.3.2) | : | table.ts (material2-7.3.3) | ||
---|---|---|---|---|
skipping to change at line 582 | skipping to change at line 582 | |||
this._footerRowDefChanged = true; | this._footerRowDefChanged = true; | |||
} | } | |||
/** | /** | |||
* Updates the header sticky styles. First resets all applied styles with resp ect to the cells | * Updates the header sticky styles. First resets all applied styles with resp ect to the cells | |||
* sticking to the top. Then, evaluating which cells need to be stuck to the t op. This is | * sticking to the top. Then, evaluating which cells need to be stuck to the t op. This is | |||
* automatically called when the header row changes its displayed set of colum ns, or if its | * automatically called when the header row changes its displayed set of colum ns, or if its | |||
* sticky input changes. May be called manually for cases where the cell conte nt changes outside | * sticky input changes. May be called manually for cases where the cell conte nt changes outside | |||
* of these events. | * of these events. | |||
*/ | */ | |||
updateStickyHeaderRowStyles() { | updateStickyHeaderRowStyles(): void { | |||
const headerRows = this._getRenderedRows(this._headerRowOutlet); | const headerRows = this._getRenderedRows(this._headerRowOutlet); | |||
this._stickyStyler.clearStickyPositioning(headerRows, ['top']); | const tableElement = this._elementRef.nativeElement as HTMLElement; | |||
// Hide the thead element if there are no header rows. This is necessary to | ||||
satisfy | ||||
// overzealous a11y checkers that fail because the `rowgroup` element does n | ||||
ot contain | ||||
// required child `row`. | ||||
const thead = tableElement.querySelector('thead'); | ||||
if (thead) { | ||||
thead.style.display = headerRows.length ? '' : 'none'; | ||||
} | ||||
const stickyStates = this._headerRowDefs.map(def => def.sticky); | const stickyStates = this._headerRowDefs.map(def => def.sticky); | |||
this._stickyStyler.clearStickyPositioning(headerRows, ['top']); | ||||
this._stickyStyler.stickRows(headerRows, stickyStates, 'top'); | this._stickyStyler.stickRows(headerRows, stickyStates, 'top'); | |||
// Reset the dirty state of the sticky input change since it has been used. | // Reset the dirty state of the sticky input change since it has been used. | |||
this._headerRowDefs.forEach(def => def.resetStickyChanged()); | this._headerRowDefs.forEach(def => def.resetStickyChanged()); | |||
} | } | |||
/** | /** | |||
* Updates the footer sticky styles. First resets all applied styles with resp ect to the cells | * Updates the footer sticky styles. First resets all applied styles with resp ect to the cells | |||
* sticking to the bottom. Then, evaluating which cells need to be stuck to th e bottom. This is | * sticking to the bottom. Then, evaluating which cells need to be stuck to th e bottom. This is | |||
* automatically called when the footer row changes its displayed set of colum ns, or if its | * automatically called when the footer row changes its displayed set of colum ns, or if its | |||
* sticky input changes. May be called manually for cases where the cell conte nt changes outside | * sticky input changes. May be called manually for cases where the cell conte nt changes outside | |||
* of these events. | * of these events. | |||
*/ | */ | |||
updateStickyFooterRowStyles() { | updateStickyFooterRowStyles(): void { | |||
const footerRows = this._getRenderedRows(this._footerRowOutlet); | const footerRows = this._getRenderedRows(this._footerRowOutlet); | |||
this._stickyStyler.clearStickyPositioning(footerRows, ['bottom']); | const tableElement = this._elementRef.nativeElement as HTMLElement; | |||
// Hide the tfoot element if there are no footer rows. This is necessary to | ||||
satisfy | ||||
// overzealous a11y checkers that fail because the `rowgroup` element does n | ||||
ot contain | ||||
// required child `row`. | ||||
const tfoot = tableElement.querySelector('tfoot'); | ||||
if (tfoot) { | ||||
tfoot.style.display = footerRows.length ? '' : 'none'; | ||||
} | ||||
const stickyStates = this._footerRowDefs.map(def => def.sticky); | const stickyStates = this._footerRowDefs.map(def => def.sticky); | |||
this._stickyStyler.clearStickyPositioning(footerRows, ['bottom']); | ||||
this._stickyStyler.stickRows(footerRows, stickyStates, 'bottom'); | this._stickyStyler.stickRows(footerRows, stickyStates, 'bottom'); | |||
this._stickyStyler.updateStickyFooterContainer(this._elementRef.nativeElemen t, stickyStates); | this._stickyStyler.updateStickyFooterContainer(this._elementRef.nativeElemen t, stickyStates); | |||
// Reset the dirty state of the sticky input change since it has been used. | // Reset the dirty state of the sticky input change since it has been used. | |||
this._footerRowDefs.forEach(def => def.resetStickyChanged()); | this._footerRowDefs.forEach(def => def.resetStickyChanged()); | |||
} | } | |||
/** | /** | |||
* Updates the column sticky styles. First resets all applied styles with resp ect to the cells | * Updates the column sticky styles. First resets all applied styles with resp ect to the cells | |||
* sticking to the left and right. Then sticky styles are added for the left a nd right according | * sticking to the left and right. Then sticky styles are added for the left a nd right according | |||
skipping to change at line 868 | skipping to change at line 886 | |||
throw getTableUnknownColumnError(columnName); | throw getTableUnknownColumnError(columnName); | |||
} | } | |||
return columnDef!; | return columnDef!; | |||
}); | }); | |||
const stickyStartStates = columnDefs.map(columnDef => columnDef.sticky); | const stickyStartStates = columnDefs.map(columnDef => columnDef.sticky); | |||
const stickyEndStates = columnDefs.map(columnDef => columnDef.stickyEnd); | const stickyEndStates = columnDefs.map(columnDef => columnDef.stickyEnd); | |||
this._stickyStyler.updateStickyColumns(rows, stickyStartStates, stickyEndSta tes); | this._stickyStyler.updateStickyColumns(rows, stickyStartStates, stickyEndSta tes); | |||
} | } | |||
/** Gets the list of rows that have been rendered in the row outlet. */ | /** Gets the list of rows that have been rendered in the row outlet. */ | |||
_getRenderedRows(rowOutlet: RowOutlet) { | _getRenderedRows(rowOutlet: RowOutlet): HTMLElement[] { | |||
const renderedRows: HTMLElement[] = []; | const renderedRows: HTMLElement[] = []; | |||
for (let i = 0; i < rowOutlet.viewContainer.length; i++) { | for (let i = 0; i < rowOutlet.viewContainer.length; i++) { | |||
const viewRef = (rowOutlet.viewContainer.get(i)! as EmbeddedViewRef<any>); | const viewRef = (rowOutlet.viewContainer.get(i)! as EmbeddedViewRef<any>); | |||
renderedRows.push(viewRef.rootNodes[0]); | renderedRows.push(viewRef.rootNodes[0]); | |||
} | } | |||
return renderedRows; | return renderedRows; | |||
} | } | |||
skipping to change at line 986 | skipping to change at line 1004 | |||
const documentRef = this._document || document; | const documentRef = this._document || document; | |||
const documentFragment = documentRef.createDocumentFragment(); | const documentFragment = documentRef.createDocumentFragment(); | |||
const sections = [ | const sections = [ | |||
{tag: 'thead', outlet: this._headerRowOutlet}, | {tag: 'thead', outlet: this._headerRowOutlet}, | |||
{tag: 'tbody', outlet: this._rowOutlet}, | {tag: 'tbody', outlet: this._rowOutlet}, | |||
{tag: 'tfoot', outlet: this._footerRowOutlet}, | {tag: 'tfoot', outlet: this._footerRowOutlet}, | |||
]; | ]; | |||
for (const section of sections) { | for (const section of sections) { | |||
const element = documentRef.createElement(section.tag); | const element = documentRef.createElement(section.tag); | |||
element.setAttribute('role', 'rowgroup'); | ||||
element.appendChild(section.outlet.elementRef.nativeElement); | element.appendChild(section.outlet.elementRef.nativeElement); | |||
documentFragment.appendChild(element); | documentFragment.appendChild(element); | |||
} | } | |||
// Use a DocumentFragment so we don't hit the DOM on each iteration. | // Use a DocumentFragment so we don't hit the DOM on each iteration. | |||
this._elementRef.nativeElement.appendChild(documentFragment); | this._elementRef.nativeElement.appendChild(documentFragment); | |||
} | } | |||
/** | /** | |||
* Forces a re-render of the data rows. Should be called in cases where there has been an input | * Forces a re-render of the data rows. Should be called in cases where there has been an input | |||
End of changes. 8 change blocks. | ||||
5 lines changed or deleted | 28 lines changed or added |