Skip to content

Commit 5721159

Browse files
committed
comments
1 parent bad56ed commit 5721159

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cdk/table/sticky-styler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export class StickyStyler {
3535
* @param direction The directionality context of the table (ltr/rtl); affects column positioning
3636
* by reversing left/right positions.
3737
* @param _isBrowser Whether the table is currently being rendered on the server or the client.
38+
* @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
39+
* using inline styles. If false, it is assumed that position: sticky is included in
40+
* the component stylesheet for _stickCellCss.
3841
*/
3942
constructor(private _isNativeHtmlTable: boolean,
4043
private _stickCellCss: string,
@@ -209,11 +212,14 @@ export class StickyStyler {
209212

210213
// If the element no longer has any more sticky directions, remove sticky positioning and
211214
// the sticky CSS class.
215+
// Short-circuit checking element.style[dir] for stickyDirections as they
216+
// were already removed above.
212217
const hasDirection = STICKY_DIRECTIONS.some(dir =>
213-
stickyDirections.indexOf(dir) === -1 && !!element.style[dir]);
218+
stickyDirections.indexOf(dir) === -1 && element.style[dir]);
214219
if (hasDirection) {
215220
element.style.zIndex = this._getCalculatedZIndex(element);
216221
} else {
222+
// When not hasDirection, _getCalculatedZIndex will always return ''.
217223
element.style.zIndex = '';
218224
if (this._needsPositionStickyOnElement) {
219225
element.style.position = '';

0 commit comments

Comments
 (0)