From 93a4b76b00cbd83f12bee27bc7da7479f02bf71b Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Tue, 8 Aug 2023 16:05:14 -0700 Subject: [PATCH] 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 --- resources/skins.vector.js/features.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/skins.vector.js/features.js b/resources/skins.vector.js/features.js index 1a49056b7..bacd880ab 100644 --- a/resources/skins.vector.js/features.js +++ b/resources/skins.vector.js/features.js @@ -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}` ); }