Don't pass an empty string to getElementById to avoid Firefox warning

Bug: T315614
Change-Id: I6d4eedd75a23f6ada26aedca54da80c5e33ea4f0
This commit is contained in:
Ed Sanders 2022-08-22 16:36:09 +01:00
parent e8068f2bf6
commit 837591f12e

View file

@ -401,6 +401,11 @@ function clearHighlightTargetComment( threadItemSet ) {
* @return {Element|null} Element, if found
*/
function getTargetFromFragment( hash ) {
if ( !hash ) {
// Firefox emits a console warning if you pass an empty string
// to getElementById (T272844).
return null;
}
// Per https://html.spec.whatwg.org/multipage/browsing-the-web.html#target-element
// we try the raw fragment first, then the percent-decoded fragment.
return document.getElementById( hash ) ||