Merge "Only track headings that are included in the table of contents"

This commit is contained in:
jenkins-bot 2022-04-05 22:10:33 +00:00 committed by Gerrit Code Review
commit ec3b66e0ed
1 changed files with 4 additions and 1 deletions

View File

@ -207,8 +207,11 @@ const main = () => {
tableOfContents.toggleExpandSection( id );
}
} );
const headingSelector = [
'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
].map( ( tag ) => `.mw-parser-output > ${tag}` ).join( ',' );
const sectionObserver = initSectionObserver( {
elements: bodyContent.querySelectorAll( 'h1, h2, h3, h4, h5, h6, .mw-body-content' ),
elements: bodyContent.querySelectorAll( `${headingSelector}, .mw-body-content` ),
topMargin: header ? header.getBoundingClientRect().height : 0,
onIntersection: getHeadingIntersectionHandler( tableOfContents.changeActiveSection )
} );