From 15cd69b169f6364f481e6c3ea6b5bfd284b1af44 Mon Sep 17 00:00:00 2001 From: bwang Date: Mon, 30 Jan 2023 13:31:36 -0600 Subject: [PATCH] Add check for activeTopSection in activateSection Bug: T328089 Change-Id: Ibe3b407e15b9b9c0ccc475f5632b4b7db7261d24 --- resources/skins.vector.es6/tableOfContents.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/skins.vector.es6/tableOfContents.js b/resources/skins.vector.es6/tableOfContents.js index d0fc65ec7..eee96f75f 100644 --- a/resources/skins.vector.es6/tableOfContents.js +++ b/resources/skins.vector.es6/tableOfContents.js @@ -132,9 +132,12 @@ module.exports = function tableOfContents( props ) { } // Assign the active top and sub sections, apply classes - activeTopSection = /** @type {HTMLElement} */ ( selectedTocSection.closest( `.${TOP_SECTION_CLASS}` ) ); + activeTopSection = /** @type {HTMLElement|undefined} */ ( selectedTocSection.closest( `.${TOP_SECTION_CLASS}` ) ); + if ( activeTopSection ) { + // T328089 Sometimes activeTopSection is null + activeTopSection.classList.add( ACTIVE_TOP_SECTION_CLASS ); + } activeSubSection = selectedTocSection; - activeTopSection.classList.add( ACTIVE_TOP_SECTION_CLASS ); activeSubSection.classList.add( ACTIVE_SECTION_CLASS ); }