From: Bartosz DziewoƄski Date: Fri, 15 Sep 2017 20:35:46 +0000 (+0200) Subject: mediawiki.special.preferences: Allow linking to subsections X-Git-Tag: 1.31.0-rc.0~1982^2~2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=5fe2e19ac33335458b658388a34f48bde63c1787 mediawiki.special.preferences: Allow linking to subsections The fix for T54469 allowed linking to individual fields, but not to subsections. The subsections have an id prefixed with 'mw-prefsection', like the main sections, so the 'else' case was never triggered and they were never handled. Fix the 'if' case condition to not match them. Also, do not rely on the 'prefsection' class, which is (according to the comment at the top of this file) only "for backwards compatibility with older skins". Change-Id: Ie7b4e3afbbe723a4e3b01aac95476b073a7213cd --- diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index 6291f3f5ba..b86f21838c 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -105,12 +105,12 @@ function detectHash() { var hash = location.hash, matchedElement, parentSection; - if ( hash.match( /^#mw-prefsection-[\w-]+/ ) ) { + if ( hash.match( /^#mw-prefsection-[\w]+$/ ) ) { mw.storage.session.remove( 'mwpreferences-prevTab' ); switchPrefTab( hash.replace( '#mw-prefsection-', '' ) ); - } else if ( hash.match( /^#mw-[\w-]+/ ) ) { + } else if ( hash.match( /^#mw-[\w-]+$/ ) ) { matchedElement = document.getElementById( hash.slice( 1 ) ); - parentSection = $( matchedElement ).closest( '.prefsection' ); + parentSection = $( matchedElement ).parent().closest( '[id^="mw-prefsection-"]' ); if ( parentSection.length ) { mw.storage.session.remove( 'mwpreferences-prevTab' ); // Switch to proper tab and scroll to selected item.