mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-13 17:57:06 +00:00
Fixes the pinning functionality
Pinning functionality was broken in I120f8f7114b33d2cfbd1c3c57ebf41f8b2d7fec4 as it breaks the check against "legacy" feature classes. We should resort to using the legacy mode when neither of the new classes can be found. Bug: T341641 Change-Id: If97a393140175fd41551c3db14b19becb8d9f460
This commit is contained in:
parent
e4e762eb32
commit
93a4b76b00
|
@ -55,9 +55,16 @@ function toggleDocClasses( name, override, isLegacy ) {
|
|||
const suffixDisabled = isLegacy ? 'disabled' : 'clientpref-0';
|
||||
const featureClassEnabled = `vector-feature-${name}-${suffixEnabled}`,
|
||||
classList = document.documentElement.classList,
|
||||
featureClassDisabled = `vector-feature-${name}-${suffixDisabled}`;
|
||||
featureClassDisabled = `vector-feature-${name}-${suffixDisabled}`,
|
||||
// If neither of the classes can be found it is a legacy feature
|
||||
isLegacyFeature = !classList.contains( featureClassDisabled ) &&
|
||||
!classList.contains( featureClassEnabled );
|
||||
|
||||
if ( classList.contains( featureClassDisabled ) || override === true ) {
|
||||
// Check in legacy mode.
|
||||
if ( isLegacyFeature && !isLegacy ) {
|
||||
// try again using the legacy classes
|
||||
return toggleDocClasses( name, override, true );
|
||||
} else if ( classList.contains( featureClassDisabled ) || override === true ) {
|
||||
classList.remove( featureClassDisabled );
|
||||
classList.add( featureClassEnabled );
|
||||
return true;
|
||||
|
@ -65,9 +72,6 @@ function toggleDocClasses( name, override, isLegacy ) {
|
|||
classList.add( featureClassDisabled );
|
||||
classList.remove( featureClassEnabled );
|
||||
return false;
|
||||
} else if ( !isLegacy ) {
|
||||
// try again using the legacy classes
|
||||
return toggleDocClasses( name, override, true );
|
||||
} else {
|
||||
throw new Error( `Attempt to toggle unknown feature: ${name}` );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue