mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-12 01:09:20 +00:00
Only track headings that are included in the table of contents
Headings can also appear in templates inside divs and subtitles. These do not get rendered in the table of contents and should not be tracked. This also excludes headings from the legacy table of contents which may be in the article during the A/B test See English Wikipedia examples [[Portal:Biography]] and [[Main page]] Change-Id: I4ca8933a0e7736157f80e5e68077b153e5bfc81d
This commit is contained in:
parent
607f3279bd
commit
94c7f31082
|
@ -186,8 +186,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 )
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue