Skip to content

Commit a779f3b

Browse files
committed
comments
1 parent bb60dd2 commit a779f3b

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
@@ -34,6 +34,9 @@ export class StickyStyler {
3434
* @param direction The directionality context of the table (ltr/rtl); affects column positioning
3535
* by reversing left/right positions.
3636
* @param _isBrowser Whether the table is currently being rendered on the server or the client.
37+
* @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
38+
* using inline styles. If false, it is assumed that position: sticky is included in
39+
* the component stylesheet for _stickCellCss.
3740
*/
3841
constructor(private _isNativeHtmlTable: boolean,
3942
private _stickCellCss: string,
@@ -183,11 +186,14 @@ export class StickyStyler {
183186

184187
// If the element no longer has any more sticky directions, remove sticky positioning and
185188
// the sticky CSS class.
189+
// Short-circuit checking element.style[dir] for stickyDirections as they
190+
// were already removed above.
186191
const hasDirection = STICKY_DIRECTIONS.some(dir =>
187-
stickyDirections.indexOf(dir) === -1 && !!element.style[dir]);
192+
stickyDirections.indexOf(dir) === -1 && element.style[dir]);
188193
if (hasDirection) {
189194
element.style.zIndex = this._getCalculatedZIndex(element);
190195
} else {
196+
// When not hasDirection, _getCalculatedZIndex will always return ''.
191197
element.style.zIndex = '';
192198
if (this._needsPositionStickyOnElement) {
193199
element.style.position = '';

0 commit comments

Comments
 (0)