@@ -28,6 +28,7 @@ import {
2828 iterateRowCells ,
2929 updateBooleanRowStates ,
3030 updateCellsPart ,
31+ updatePart ,
3132 updateState ,
3233} from './vaadin-grid-helpers.js' ;
3334import { KeyboardNavigationMixin } from './vaadin-grid-keyboard-navigation-mixin.js' ;
@@ -641,10 +642,12 @@ export const GridMixin = (superClass) =>
641642
642643 if ( row . parentElement === this . $ . header ) {
643644 this . $ . table . toggleAttribute ( 'has-header' , this . $ . header . querySelector ( 'tr:not([hidden])' ) ) ;
645+ this . __updateHeaderFooterRowParts ( 'header' ) ;
644646 }
645647
646648 if ( row . parentElement === this . $ . footer ) {
647649 this . $ . table . toggleAttribute ( 'has-footer' , this . $ . footer . querySelector ( 'tr:not([hidden])' ) ) ;
650+ this . __updateHeaderFooterRowParts ( 'footer' ) ;
648651 }
649652
650653 // Make sure the section has a tabbable element
@@ -710,13 +713,13 @@ export const GridMixin = (superClass) =>
710713
711714 while ( this . $ . header . children . length < columnTree . length ) {
712715 const headerRow = document . createElement ( 'tr' ) ;
713- headerRow . setAttribute ( 'part' , 'row' ) ;
716+ headerRow . setAttribute ( 'part' , 'row header-row ' ) ;
714717 headerRow . setAttribute ( 'role' , 'row' ) ;
715718 headerRow . setAttribute ( 'tabindex' , '-1' ) ;
716719 this . $ . header . appendChild ( headerRow ) ;
717720
718721 const footerRow = document . createElement ( 'tr' ) ;
719- footerRow . setAttribute ( 'part' , 'row' ) ;
722+ footerRow . setAttribute ( 'part' , 'row footer-row ' ) ;
720723 footerRow . setAttribute ( 'role' , 'row' ) ;
721724 footerRow . setAttribute ( 'tabindex' , '-1' ) ;
722725 this . $ . footer . appendChild ( footerRow ) ;
@@ -726,25 +729,19 @@ export const GridMixin = (superClass) =>
726729 this . $ . footer . removeChild ( this . $ . footer . firstElementChild ) ;
727730 }
728731
729- iterateChildren ( this . $ . header , ( headerRow , index , rows ) => {
732+ iterateChildren ( this . $ . header , ( headerRow , index ) => {
730733 this . __initRow ( headerRow , columnTree [ index ] , 'header' , index === columnTree . length - 1 ) ;
731-
732- const cells = getBodyRowCells ( headerRow ) ;
733- updateCellsPart ( cells , 'first-header-row-cell' , index === 0 ) ;
734- updateCellsPart ( cells , 'last-header-row-cell' , index === rows . length - 1 ) ;
735734 } ) ;
736735
737- iterateChildren ( this . $ . footer , ( footerRow , index , rows ) => {
736+ iterateChildren ( this . $ . footer , ( footerRow , index ) => {
738737 this . __initRow ( footerRow , columnTree [ columnTree . length - 1 - index ] , 'footer' , index === 0 ) ;
739-
740- const cells = getBodyRowCells ( footerRow ) ;
741- updateCellsPart ( cells , 'first-footer-row-cell' , index === 0 ) ;
742- updateCellsPart ( cells , 'last-footer-row-cell' , index === rows . length - 1 ) ;
743738 } ) ;
744739
745740 // Sizer rows
746741 this . __initRow ( this . $ . sizer , columnTree [ columnTree . length - 1 ] ) ;
747742
743+ this . __updateHeaderFooterRowParts ( 'header' ) ;
744+ this . __updateHeaderFooterRowParts ( 'footer' ) ;
748745 this . _resizeHandler ( ) ;
749746 this . _frozenCellsChanged ( ) ;
750747 this . _updateFirstAndLastColumn ( ) ;
@@ -756,6 +753,20 @@ export const GridMixin = (superClass) =>
756753 this . __updateHeaderAndFooter ( ) ;
757754 }
758755
756+ /** @private */
757+ __updateHeaderFooterRowParts ( section ) {
758+ const visibleRows = [ ...this . $ [ section ] . querySelectorAll ( 'tr:not([hidden])' ) ] ;
759+ [ ...this . $ [ section ] . children ] . forEach ( ( row ) => {
760+ updatePart ( row , row === visibleRows . at ( 0 ) , `first-${ section } -row` ) ;
761+ updatePart ( row , row === visibleRows . at ( - 1 ) , `last-${ section } -row` ) ;
762+
763+ getBodyRowCells ( row ) . forEach ( ( cell ) => {
764+ updatePart ( cell , row === visibleRows . at ( 0 ) , `first-${ section } -row-cell` ) ;
765+ updatePart ( cell , row === visibleRows . at ( - 1 ) , `last-${ section } -row-cell` ) ;
766+ } ) ;
767+ } ) ;
768+ }
769+
759770 /**
760771 * @param {!HTMLElement } row
761772 * @param {boolean } loading
0 commit comments