Don't try to highlight elements not in a code block

The 'hll' CSS only targets the .linenos selector, but it doesn't
hurt to avoid unnecessary DOM changes.

Change-Id: Ic7134619606c6e4abc2480ddc9650d0352fc33da
This commit is contained in:
Ed Sanders 2021-01-13 20:47:41 +00:00
parent 8f09ace86b
commit 63c5943a9f

View file

@ -5,7 +5,11 @@ $( function () {
function onHashChange() {
// Don't assume location.hash will be parseable as an ID (T271572)
var $line = $( document.getElementById( location.hash.slice( 1 ) ) || [] );
// TODO: Check the element is in fact a line marker
if ( !$line.closest( '.mw-highlight' ).length ) {
// Matched ID wasn't in a highlight block
$line = $( [] );
}
if ( $lastLine ) {
$lastLine.removeClass( 'hll' );