mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-27 15:50:37 +00:00
Avoid console warning when hash is empty
Bug: T272844 Change-Id: I82ed4ade24ed9e61e654cc7ea1ce19c7607086e1
This commit is contained in:
parent
e793626d52
commit
42c97fa448
|
@ -3,8 +3,10 @@ $( function () {
|
||||||
var $lastLine;
|
var $lastLine;
|
||||||
|
|
||||||
function onHashChange() {
|
function onHashChange() {
|
||||||
// Don't assume location.hash will be parseable as an ID (T271572)
|
var id = location.hash.slice( 1 ),
|
||||||
var $line = $( document.getElementById( location.hash.slice( 1 ) ) || [] );
|
// Don't assume location.hash will be parseable as an ID (T271572)
|
||||||
|
// and avoid warning when id is empty (T272844)
|
||||||
|
$line = id ? $( document.getElementById( id ) || [] ) : $( [] );
|
||||||
|
|
||||||
if ( !$line.closest( '.mw-highlight' ).length ) {
|
if ( !$line.closest( '.mw-highlight' ).length ) {
|
||||||
// Matched ID wasn't in a highlight block
|
// Matched ID wasn't in a highlight block
|
||||||
|
|
Loading…
Reference in a new issue