Skip to content

Commit

Permalink
fix(core): 馃悰 stricter selector for collasible headers in formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Sep 11, 2023
1 parent 2fc6970 commit 45a726d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion includes/Partials/BodyContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,21 @@ private function getTopHeadings( DOMDocument $doc ): array {
if ( !( $parent instanceof DOMElement ) ) {
continue;
}

$parentClasses = DOMCompat::getClassList( $parent );

// Only target page headings, but not other heading tags
// TODO: Drop this when T13555 is deployed on LTS
if ( !$parentClasses->contains( 'mw-parser-output') ) {
continue;
}

// Use the `<div class="mw-heading">` wrapper if it is present. When they are required
// (T13555), the querySelectorAll() above can use the class and this can be removed.
if ( DOMCompat::getClassList( $parent )->contains( 'mw-heading' ) ) {
if ( $parentClasses->contains( 'mw-heading' ) ) {
$el = $parent;
}

// This check can be removed too when we require the wrappers.
if ( $parent->getAttribute( 'class' ) !== 'toctitle' ) {
$headings[] = $el;
Expand Down

0 comments on commit 45a726d

Please sign in to comment.