MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 337: Line 337:
       var link = li.querySelector( '.vector-toc-link' ) || li.querySelector( 'a' );
       var link = li.querySelector( '.vector-toc-link' ) || li.querySelector( 'a' );
       if ( !link ) return;
       if ( !link ) return;
       if ( on ) {
       /* Only highlight as "active" if this is the LEAF active item —
      * i.e. no child list-item is also active. Vector marks both the
      * parent section AND the current sub-item as active. We only want
      * the innermost active item coloured orange. */
      var hasActiveChild = !!li.querySelector(
        '.vector-toc-list-item .vector-toc-list-item-active'
      );
      var shouldHighlight = on && !hasActiveChild;
      if ( shouldHighlight ) {
         link.style.setProperty( 'color',      ACTIVE_COLOR, 'important' );
         link.style.setProperty( 'color',      ACTIVE_COLOR, 'important' );
         link.style.setProperty( 'font-weight', '700',        'important' );
         link.style.setProperty( 'font-weight', '700',        'important' );