Merge "Add data-event-name attributes to legacy and sidebar TOC"

This commit is contained in:
jenkins-bot 2022-03-23 22:00:45 +00:00 committed by Gerrit Code Review
commit 1b8ee10357
3 changed files with 10 additions and 3 deletions

View file

@ -1,4 +1,4 @@
<nav id="mw-panel-toc" class="sidebar-toc" role="navigation" aria-labelledby="sidebar-toc-header"> <nav id="mw-panel-toc" class="sidebar-toc" role="navigation" aria-labelledby="sidebar-toc-header" data-event-name="ui.sidebar-toc">
<div class="sidebar-toc-header"> <div class="sidebar-toc-header">
<h2 class="sidebar-toc-title" aria-hidden="true">{{ msg-vector-toc-heading }}</h2> <h2 class="sidebar-toc-title" aria-hidden="true">{{ msg-vector-toc-heading }}</h2>
</div> </div>

View file

@ -8,6 +8,7 @@ const
initTableOfContents = require( './tableOfContents.js' ), initTableOfContents = require( './tableOfContents.js' ),
deferUntilFrame = require( './deferUntilFrame.js' ), deferUntilFrame = require( './deferUntilFrame.js' ),
TOC_ID = 'mw-panel-toc', TOC_ID = 'mw-panel-toc',
LEGACY_TOC_ID = 'toc',
BODY_CONTENT_ID = 'bodyContent', BODY_CONTENT_ID = 'bodyContent',
HEADLINE_SELECTOR = '.mw-headline', HEADLINE_SELECTOR = '.mw-headline',
TOC_SECTION_ID_PREFIX = 'toc-', TOC_SECTION_ID_PREFIX = 'toc-',
@ -70,8 +71,14 @@ const main = () => {
// Table of contents // Table of contents
const tocElement = document.getElementById( TOC_ID ); const tocElement = document.getElementById( TOC_ID );
const legacyTOCElement = document.getElementById( LEGACY_TOC_ID );
const bodyContent = document.getElementById( BODY_CONTENT_ID ); const bodyContent = document.getElementById( BODY_CONTENT_ID );
// Add event data attributes to legacy TOC
if ( legacyTOCElement ) {
legacyTOCElement.setAttribute( 'data-event-name', 'ui.toc' );
}
if ( !( if ( !(
tocElement && tocElement &&
bodyContent && bodyContent &&

View file

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Table of contents when \`vector-is-collapse-sections-enabled\` is false renders 1`] = ` exports[`Table of contents when \`vector-is-collapse-sections-enabled\` is false renders 1`] = `
"<nav id=\\"mw-panel-toc\\" class=\\"sidebar-toc\\" role=\\"navigation\\" aria-labelledby=\\"sidebar-toc-header\\"> "<nav id=\\"mw-panel-toc\\" class=\\"sidebar-toc\\" role=\\"navigation\\" aria-labelledby=\\"sidebar-toc-header\\" data-event-name=\\"ui.sidebar-toc\\">
<div class=\\"sidebar-toc-header\\"> <div class=\\"sidebar-toc-header\\">
<h2 class=\\"sidebar-toc-title\\" aria-hidden=\\"true\\">Contents</h2> <h2 class=\\"sidebar-toc-title\\" aria-hidden=\\"true\\">Contents</h2>
</div> </div>
@ -53,7 +53,7 @@ exports[`Table of contents when \`vector-is-collapse-sections-enabled\` is false
`; `;
exports[`Table of contents when \`vector-is-collapse-sections-enabled\` is true renders 1`] = ` exports[`Table of contents when \`vector-is-collapse-sections-enabled\` is true renders 1`] = `
"<nav id=\\"mw-panel-toc\\" class=\\"sidebar-toc\\" role=\\"navigation\\" aria-labelledby=\\"sidebar-toc-header\\"> "<nav id=\\"mw-panel-toc\\" class=\\"sidebar-toc\\" role=\\"navigation\\" aria-labelledby=\\"sidebar-toc-header\\" data-event-name=\\"ui.sidebar-toc\\">
<div class=\\"sidebar-toc-header\\"> <div class=\\"sidebar-toc-header\\">
<h2 class=\\"sidebar-toc-title\\" aria-hidden=\\"true\\">Contents</h2> <h2 class=\\"sidebar-toc-title\\" aria-hidden=\\"true\\">Contents</h2>
</div> </div>