mediawiki-extensions-Syntax.../modules/pygments.linenumbers.js
Ed Sanders f2613d589c Line number highlight: Use getTargetFromFragment
Bug: T315872
Depends-On: I605a24c708e60ccffde9dce524485f61fd5c7b06
Change-Id: I48c1aaf56ccea232dca7cb52f24a29a421b94d86
2022-08-31 13:10:18 +00:00

29 lines
567 B
JavaScript

$( function () {
var lastLine;
function onHashChange() {
var line = mw.util.getTargetFromFragment();
if ( lastLine ) {
lastLine.classList.remove( 'hll' );
}
// Support IE 11, Edge 14, Safari 7: Can't use unprefixed Element.matches('… *') yet.
if ( !line || !$( line ).closest( '.mw-highlight' ).length ) {
// Matched ID wasn't in a highlight block
lastLine = null;
return;
}
line.classList.add( 'hll' );
lastLine = line;
}
window.addEventListener( 'hashchange', onHashChange );
// Check hash on load
onHashChange();
}() );