From 6267ac8bb8ba1279230805efe7c92ebd162a73e7 Mon Sep 17 00:00:00 2001
From: Brian Canini <canini.16@osu.edu>
Date: Mon, 6 Jul 2020 15:48:28 -0400
Subject: [PATCH] Updating drupal/superfish (1.2.0 => 1.4.0)

---
 composer.json                                 |   2 +-
 composer.lock                                 |  23 ++--
 vendor/composer/installed.json                |  23 ++--
 web/modules/superfish/README.txt              | 123 +++++++++---------
 web/modules/superfish/composer.json           |   2 +-
 .../src/Plugin/Block/SuperfishBlock.php       |  25 +++-
 web/modules/superfish/superfish.info.yml      |  10 +-
 web/modules/superfish/superfish.install       |  42 ++++--
 web/modules/superfish/superfish.module        |  52 ++++++--
 web/modules/superfish/superfish.theme.inc     |  56 ++++++--
 .../templates/superfish-menu-items.html.twig  |  31 +++--
 11 files changed, 237 insertions(+), 152 deletions(-)

diff --git a/composer.json b/composer.json
index b49efeed06..2ceafac768 100644
--- a/composer.json
+++ b/composer.json
@@ -166,7 +166,7 @@
         "drupal/smtp": "1.x-dev#84f789cbba894290cf82ed2558c8a4e7e24f3c89",
         "drupal/social_media": "1.8",
         "drupal/social_media_links": "2.6",
-        "drupal/superfish": "1.2",
+        "drupal/superfish": "1.4",
         "drupal/svg_image": "1.14",
         "drupal/token": "1.7",
         "drupal/twig_tweak": "2.6",
diff --git a/composer.lock b/composer.lock
index 564c3cb598..69c862bccd 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "c2365ed43ba16f074102a0f462effe00",
+    "content-hash": "597c6cd5ac3c855cec844297a1d044c0",
     "packages": [
         {
             "name": "alchemy/zippy",
@@ -7536,30 +7536,27 @@
         },
         {
             "name": "drupal/superfish",
-            "version": "1.2.0",
+            "version": "1.4.0",
             "source": {
                 "type": "git",
                 "url": "https://git.drupalcode.org/project/superfish.git",
-                "reference": "8.x-1.2"
+                "reference": "8.x-1.4"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/superfish-8.x-1.2.zip",
-                "reference": "8.x-1.2",
-                "shasum": "e6f11be2bb2b95957d144bb0155c29c7aad40a62"
+                "url": "https://ftp.drupal.org/files/projects/superfish-8.x-1.4.zip",
+                "reference": "8.x-1.4",
+                "shasum": "d84b900e81c412ef783094a8ef51a79038d24a59"
             },
             "require": {
-                "drupal/core": "~8.0",
+                "drupal/core": "^8 || ^9",
                 "mehrpadin/superfish": "~2.0"
             },
             "type": "drupal-module",
             "extra": {
-                "branch-alias": {
-                    "dev-1.x": "1.x-dev"
-                },
                 "drupal": {
-                    "version": "8.x-1.2",
-                    "datestamp": "1517739480",
+                    "version": "8.x-1.4",
+                    "datestamp": "1590438116",
                     "security-coverage": {
                         "status": "covered",
                         "message": "Covered by Drupal's security advisory policy"
@@ -7568,7 +7565,7 @@
             },
             "notification-url": "https://packages.drupal.org/8/downloads",
             "license": [
-                "GPL-2.0+"
+                "GPL-2.0-or-later"
             ],
             "authors": [
                 {
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index a54bfe8f5b..4a82ed90fe 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -7768,31 +7768,28 @@
     },
     {
         "name": "drupal/superfish",
-        "version": "1.2.0",
-        "version_normalized": "1.2.0.0",
+        "version": "1.4.0",
+        "version_normalized": "1.4.0.0",
         "source": {
             "type": "git",
             "url": "https://git.drupalcode.org/project/superfish.git",
-            "reference": "8.x-1.2"
+            "reference": "8.x-1.4"
         },
         "dist": {
             "type": "zip",
-            "url": "https://ftp.drupal.org/files/projects/superfish-8.x-1.2.zip",
-            "reference": "8.x-1.2",
-            "shasum": "e6f11be2bb2b95957d144bb0155c29c7aad40a62"
+            "url": "https://ftp.drupal.org/files/projects/superfish-8.x-1.4.zip",
+            "reference": "8.x-1.4",
+            "shasum": "d84b900e81c412ef783094a8ef51a79038d24a59"
         },
         "require": {
-            "drupal/core": "~8.0",
+            "drupal/core": "^8 || ^9",
             "mehrpadin/superfish": "~2.0"
         },
         "type": "drupal-module",
         "extra": {
-            "branch-alias": {
-                "dev-1.x": "1.x-dev"
-            },
             "drupal": {
-                "version": "8.x-1.2",
-                "datestamp": "1517739480",
+                "version": "8.x-1.4",
+                "datestamp": "1590438116",
                 "security-coverage": {
                     "status": "covered",
                     "message": "Covered by Drupal's security advisory policy"
@@ -7802,7 +7799,7 @@
         "installation-source": "dist",
         "notification-url": "https://packages.drupal.org/8/downloads",
         "license": [
-            "GPL-2.0+"
+            "GPL-2.0-or-later"
         ],
         "authors": [
             {
diff --git a/web/modules/superfish/README.txt b/web/modules/superfish/README.txt
index 2860216861..9d682131ef 100644
--- a/web/modules/superfish/README.txt
+++ b/web/modules/superfish/README.txt
@@ -1,80 +1,79 @@
-Superfish module
+CONTENTS OF THIS FILE
+---------------------
 
-About
------
-This module allows for integration of jQuery Superfish plug-in with Drupal CMS.
-
-
-Requirement
------------
-- Superfish library.
-  Link: https://github.com/mehrpadin/Superfish-for-Drupal/
+ * Introduction
+ * Requirements
+ * Recommended Modules
+ * Installation
+ * Configuration
+ * Maintainers
 
 
-Installation instructions (composer)
-------------------------------------
-0. You can skip this step if you use the popular
-   https://github.com/drupal-composer/drupal-project.
-   Otherwise check that your composer.json file has directives to install
-   libraries in the libraries directory like this:
-
-    "require": {
-      "composer/installers": "^1.0",
-    },
-    "extra": {
-        "installer-paths": {
-            "web/libraries/{$name}": ["type:drupal-library"]
-        }
-    }
-
-    This assumes that your drupal root resides in the "web" direectory.
-    If it is in another directory (e.g. "docroot"), change accordingly.
+INTRODUCTION
+------------
 
-1. Require the module
+This module allows for integration of jQuery Superfish plug-in with Drupal CMS.
 
-    $ composer require drupal/superfish
+ * For a full description of the module, visit the project page:
+   https://www.drupal.org/project/superfish
 
-   Composer will then put the module *and* its library into the right places.
+ * To submit bug reports and feature suggestions, or to track changes:
+   https://www.drupal.org/project/issues/superfish
 
-2. Go to "Administer" -> "Modules" and enable the module.
 
-3. Go to "Administer" -> "Structure" -> "Block layout" -> click a "Place block"
-   button to add a Superfish block to a region.
+REQUIREMENTS
+------------
 
+This module requires the following outside of Drupal core:
 
-Installation instructions (manual)
-----------------------------------
-1. Download and extract the Superfish library into the libraries directory
-   (usually "DRUPAL_ROOT/libraries").
-   Link: https://github.com/mehrpadin/Superfish-for-Drupal/zipball/2.x
+ * Superfish library - https://github.com/mehrpadin/Superfish-for-Drupal/
 
-2. Download and extract the Superfish module into the modules directory
-   (usually "DRUPAL_ROOT/modules").
-   Link: http://drupal.org/project/superfish
 
-3. Go to "Administer" -> "Modules" and enable the module.
+RECOMMENDED MODULES
+-------------------
 
-4. Go to "Administer" -> "Structure" -> "Block layout" -> click a "Place block"
-   button to add a Superfish block to a region.
+ * Libraries API - https://www.drupal.org/project/libraries
+ * jQuery Easing plugin - https://www.drupal.org/project/jqeasing
 
 
-How to style
+INSTALLATION
 ------------
 
-Here are some tips and tricks:
-
-A) Utilise the "Default" style as reference.
-
-B) Always use a DOM inspector utility (such as Firebug).
-
-C) Set the "Menu delay" option in the block configuration to a very high number
-   such as 99999999 while creating your own CSS. This will give you enough time
-   to work with sub-menus.
-
-C) If your theme supports the Superfish module, set the "Style" option in the
-   block configuration to "None".
-
+ * Install the Superfish module as you would normally install a contributed
+   Drupal module. Visit
+   https://www.drupal.org/node/1897420 for further information.
+
+
+CONFIGURATION
+-------------
+
+    1. Navigate to Administration > Extend and enable the module.
+    2. Go to Administation > Structure > Block layout > select a Place block
+       button to add a Superfish block to a region.
+    3. Use the "Configure" link of the block to configure it accordingly to your
+       needs.
+
+How to style:
+    1. In the block configuration page, set the Style to None
+    2. Copy one of the Superfish sample styles, for example default.css from
+       sites/all/libraries/superfish/style to your theme; either as a separate
+       CSS file or part of the main CSS file of your theme.
+    3. Rename the selectors .sf-style-default to .sf-style-none or remove
+       them altogether.
+    4. You are now ready to unleash your CSS artistry :)
+
+Some design tips:
+ * Utilize a DOM inspector (such as Firefox Developer Tools) for temporarily
+   modifying live code in real time.
+ * Set the Mouse delay of the block settings to 99999999 so the sub-menus will
+   stay open for a longer time giving you more time to work with them in the
+   DOM inspector etc.
+   Useful links:
+	 https://docs.acquia.com/resource/browser-tool/
+	 https://www.drupal.org/node/147789#web-browser-tools
+
+
+MAINTAINERS
+-----------
 
-Support requests
-----------------
-You can request support here: http://drupal.org/project/issues/superfish
+ * mehrpadin - https://www.drupal.org/u/mehrpadin
diff --git a/web/modules/superfish/composer.json b/web/modules/superfish/composer.json
index 3f2f7ab1ca..96d058a897 100644
--- a/web/modules/superfish/composer.json
+++ b/web/modules/superfish/composer.json
@@ -14,7 +14,7 @@
     "issues": "https://www.drupal.org/project/superfish",
     "source": "https://cgit.drupalcode.org/superfish"
   },
-  "license": "GPL-2.0+",
+  "license": "GPL-2.0-or-later",
   "require": {
     "mehrpadin/superfish": "~2.0"
   }
diff --git a/web/modules/superfish/src/Plugin/Block/SuperfishBlock.php b/web/modules/superfish/src/Plugin/Block/SuperfishBlock.php
index da21cfaf3d..15b3ad2382 100644
--- a/web/modules/superfish/src/Plugin/Block/SuperfishBlock.php
+++ b/web/modules/superfish/src/Plugin/Block/SuperfishBlock.php
@@ -44,7 +44,7 @@ class SuperfishBlock extends SystemMenuBlock {
    * @param \Drupal\Core\Menu\MenuActiveTrailInterface $menu_active_trail
    *   The active menu trail service.
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail) {
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail) {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $menu_tree, $menu_active_trail);
     $this->menuActiveTrail = $menu_active_trail;
   }
@@ -1219,7 +1219,7 @@ public function build() {
     else {
       $sfoptions['disableHI'] = TRUE;
     }
-    $sfoptions = sf_array_filter($sfoptions);
+    $sfoptions = superfish_array_filter($sfoptions);
 
     // Options for Superfish sub-plugins.
     $sfplugins = [];
@@ -1475,7 +1475,7 @@ public function build() {
       }
       $sfplugins['smallscreen']['title'] = $title ? $title : $this->label();
     }
-    $sfplugins = sf_array_filter($sfplugins);
+    $sfplugins = superfish_array_filter($sfplugins);
 
     // Menu block ID.
     $menu_name = $this->getDerivativeId();
@@ -1504,6 +1504,25 @@ public function build() {
       ->setActiveTrail($this->menuActiveTrail->getActiveTrailIds($menu_name))
       ->onlyEnabledLinks();
 
+    // For menu blocks with start level greater than 1, only show menu items
+    // from the current active trail. Adjust the root according to the current
+    // position in the menu in order to determine if we can show the subtree.
+    if ($level > 1) {
+      if (count($parameters->activeTrail) >= $level) {
+        // Active trail array is child-first. Reverse it, and pull the new menu
+        // root based on the parent of the configured start level.
+        $menu_trail_ids = array_reverse(array_values($parameters->activeTrail));
+        $menu_root = $menu_trail_ids[$level - 1];
+        $parameters->setRoot($menu_root)->setMinDepth(1);
+        if ($depth > 0) {
+          $parameters->setMaxDepth(min($level - 1 + $depth - 1, $this->menuTree->maxDepth()));
+        }
+      }
+      else {
+        return [];
+      }
+    }
+
     $tree = $this->menuTree->load($menu_name, $parameters);
     $manipulators = [
       ['callable' => 'menu.default_tree_manipulators:checkAccess'],
diff --git a/web/modules/superfish/superfish.info.yml b/web/modules/superfish/superfish.info.yml
index ef14b96ee2..d8b107eb52 100644
--- a/web/modules/superfish/superfish.info.yml
+++ b/web/modules/superfish/superfish.info.yml
@@ -2,10 +2,10 @@ name: 'Superfish'
 type: module
 description: 'Adds jQuery Superfish plugin to menu blocks.'
 package: User interface
-# core: 8.x
+core: 8.x
+core_version_requirement: ^8 || ^9
 
-# Information added by Drupal.org packaging script on 2018-02-04
-version: '8.x-1.2'
-core: '8.x'
+# Information added by Drupal.org packaging script on 2020-05-25
+version: '8.x-1.4'
 project: 'superfish'
-datestamp: 1517739484
+datestamp: 1590438118
diff --git a/web/modules/superfish/superfish.install b/web/modules/superfish/superfish.install
index 4e85260f31..87594b0692 100644
--- a/web/modules/superfish/superfish.install
+++ b/web/modules/superfish/superfish.install
@@ -9,13 +9,14 @@
  * Implements hook_enable().
  */
 function superfish_install() {
+  $messenger = \Drupal::messenger();
   if (superfish_library_check()) {
-    drupal_set_message(t('In order to use Superfish, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@block' => 'structure/block']));
+    $messenger->addMessage(t('In order to use Superfish, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@block' => 'structure/block']));
   }
   else {
-    drupal_set_message(t('Superfish library is missing. Please refer to the <a href="@documentation">plugin documentation</a> for how you can fix this issue; Once done, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@documentation' => 'http://drupal.org/node/1125896', '@block' => 'structure/block']), 'warning');
+    $messenger->addWarning(t('Superfish library is missing. Please refer to the <a href="@documentation">plugin documentation</a> for how you can fix this issue; Once done, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@documentation' => 'https://www.drupal.org/node/1125896', '@block' => 'structure/block']));
   }
-	drupal_set_message(t('If there was no Superfish block in the "Place block" form, go to the <a href="@performance">Performance</a> page and clear the cache once.', ['@performance' => 'admin/config/development/performance']));
+  $messenger->addMessage(t('If there was no Superfish block in the "Place block" form, go to the <a href="@performance">Performance</a> page and clear the cache once.', ['@performance' => 'config/development/performance']));
 }
 
 /**
@@ -27,20 +28,35 @@ function superfish_requirements($phase) {
     $requirements['superfish']['title'] = t('Superfish library');
 
     if (superfish_library_check()) {
-      $requirements['superfish']['value'] = t('Installed; at @location', ['@location' => superfish_library_path()]);
-      $requirements['superfish']['severity'] = REQUIREMENT_OK;
+      // Check the uploaded Superfish library version.
+      $version = superfish_library_version();
+      if (is_null($version)) {
+        $requirements['superfish']['value'] = t('Inaccessible');
+        $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
+        $requirements['superfish']['description'] = t('Cannot access the Superfish library directory; perhaps because its permissions and/or ownership are not set up correctly.');
+      }
+      else {
+        $version = (integer) $version;
+        if (!$version || !is_numeric($version)) {
+          $requirements['superfish']['value'] = t('Unknown version');
+          $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
+          $requirements['superfish']['description'] = t('Cannot determine the version of your Superfish library.');
+        }
+        elseif (version_compare($version, 2, '<')) {
+          $requirements['superfish']['value'] = t('Not supported');
+          $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
+          $requirements['superfish']['description'] = t('The Superfish library requires an update. You can find the update instructions on :url.', [':url' => 'https://www.drupal.org/project/superfish']);
+        }
+        else {
+          $requirements['superfish']['value'] = t('Installed; at @location', ['@location' => superfish_library_path()]);
+          $requirements['superfish']['severity'] = REQUIREMENT_OK;
+        }
+      }
     }
     else {
       $requirements['superfish']['value'] = t('Not installed');
       $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
-      $requirements['superfish']['description'] = t('Please download the Superfish library from :url.', [':url' => 'http://drupal.org/project/superfish']);
-    }
-
-    // Check the uploaded Superfish library version.
-    if (($version = superfish_library_version()) && $version != '2.0') {
-      $requirements['superfish']['value'] = t('Not supported');
-      $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
-      $requirements['superfish']['description'] = t('The Superfish library requires an update. You can find the update instructions on :url.', [':url' => 'http://drupal.org/project/superfish']);
+      $requirements['superfish']['description'] = t('Please download the Superfish library from :url.', [':url' => 'https://www.drupal.org/project/superfish']);
     }
   }
   return $requirements;
diff --git a/web/modules/superfish/superfish.module b/web/modules/superfish/superfish.module
index 4151c053ef..b49ef31360 100644
--- a/web/modules/superfish/superfish.module
+++ b/web/modules/superfish/superfish.module
@@ -24,7 +24,7 @@ function superfish_block_view_superfish_alter(array &$build, BlockPluginInterfac
 function superfish_libraries_info() {
   $libraries['superfish'] = [
     'name' => 'superfish',
-    'vendor url' => 'http://github.com/mehrpadin/Superfish-for-Drupal',
+    'vendor url' => 'https://github.com/mehrpadin/Superfish-for-Drupal',
     'download url' => 'https://github.com/mehrpadin/Superfish-for-Drupal/zipball/2.x',
     'version callback' => 'superfish_library_version',
     'files' => [
@@ -58,7 +58,7 @@ function superfish_library_info_build() {
     $superfish_library_path = '/' . $superfish_library_path;
     $libraries = [
       'superfish' => [
-        'remote' => 'http://github.com/mehrpadin/Superfish-for-Drupal',
+        'remote' => 'https://github.com/mehrpadin/Superfish-for-Drupal',
         'version' => '2.0',
         'license' => [
           'name' => 'MIT',
@@ -197,12 +197,33 @@ function superfish_library_info_build() {
 function superfish_library_path($library = 'superfish') {
   $directory = FALSE;
   // Ensure the Libraries API module is installed and working.
-  if (function_exists('libraries_get_path') && ($directory = libraries_get_path($library))) {
-    return $directory;
+  if (function_exists('libraries_get_path')) {
+    $directory = libraries_get_path($library);
+    if ($directory) {
+      return $directory;
+    }
+    elseif (ucfirst($library) !== $library) {
+      $directory = libraries_get_path(ucfirst($library));
+      if ($directory) {
+        return $directory;
+      }
+    }
   }
   // Otherwise use the default directory.
-  if (file_exists('profiles/' . drupal_get_profile() . '/libraries/' . $library)) {
-    $directory = 'profiles/' . drupal_get_profile() . '/libraries/' . $library;
+  if (\Drupal::hasContainer()) {
+    $profile = \Drupal::installProfile();
+  }
+  else {
+    $profile = BootstrapConfigStorageFactory::getDatabaseStorage()->read('core.extension')['profile'];
+  }
+  if (file_exists('profiles/' . $profile . '/libraries/' . $library)) {
+    $directory = 'profiles/' . $profile . '/libraries/' . $library;
+  }
+  elseif (file_exists('profiles/contrib/' . $profile . '/libraries/' . $library)) {
+    $directory = 'profiles/contrib/' . $profile . '/libraries/' . $library;
+  }
+  elseif (file_exists('profiles/custom/' . $profile . '/libraries/' . $library)) {
+    $directory = 'profiles/custom/' . $profile . '/libraries/' . $library;
   }
   elseif (file_exists('libraries/' . $library)) {
     $directory = 'libraries/' . $library;
@@ -213,6 +234,9 @@ function superfish_library_path($library = 'superfish') {
   elseif (file_exists('sites/default/libraries/' . $library)) {
     $directory = 'sites/default/libraries/' . $library;
   }
+  if (!$directory && ucfirst($library) !== $library) {
+    $directory = superfish_library_path(ucfirst($library));
+  }
   return $directory;
 }
 
@@ -222,12 +246,15 @@ function superfish_library_path($library = 'superfish') {
 function superfish_library_check() {
   if (function_exists('libraries_get_libraries')) {
     $library = libraries_get_libraries();
-    if (isset($library['superfish'])) {
+    if (isset($library['superfish']) || isset($library['Superfish'])) {
       return TRUE;
     }
   }
-  elseif (($directory = superfish_library_path()) && file_exists($directory . '/superfish.js')) {
-    return TRUE;
+  else {
+    $directory = superfish_library_path();
+    if ($directory && file_exists($directory . '/superfish.js')) {
+      return TRUE;
+    }
   }
   return FALSE;
 }
@@ -239,6 +266,9 @@ function superfish_library_version() {
   // Get the library version.
   if (($directory = superfish_library_path()) && file_exists($directory . '/VERSION')) {
     $version = file_get_contents($directory . '/VERSION');
+    if ($version === FALSE) {
+      return NULL;
+    }
     // Removing blank lines and white spaces.
     $version = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", trim($version));
     if (!empty($version)) {
@@ -301,10 +331,10 @@ function superfish_effects() {
 /**
  * Helper function to clean up arrays.
  */
-function sf_array_filter($haystack) {
+function superfish_array_filter($haystack) {
   foreach ($haystack as $key => $value) {
     if (is_array($value)) {
-      $haystack[$key] = sf_array_filter($haystack[$key]);
+      $haystack[$key] = superfish_array_filter($haystack[$key]);
     }
     elseif (empty($value) && is_bool($value) !== TRUE) {
       if ($haystack[$key] != '0') {
diff --git a/web/modules/superfish/superfish.theme.inc b/web/modules/superfish/superfish.theme.inc
index 8bc6cb8041..079b3d1a42 100644
--- a/web/modules/superfish/superfish.theme.inc
+++ b/web/modules/superfish/superfish.theme.inc
@@ -9,7 +9,8 @@
 use Drupal\Core\Menu\InaccessibleMenuLink;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Component\Utility\Html;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\Core\Template\Attribute;
 
 /**
  * Prepares variables for the Superfish menu template.
@@ -54,7 +55,7 @@ function template_preprocess_superfish(array &$variables) {
   else {
     $menu_classes[] = Html::cleanCssIdentifier($element['#settings']['ulclass']);
   }
-  $menu_classes = implode(' ', sf_array_filter($menu_classes));
+  $menu_classes = implode(' ', superfish_array_filter($menu_classes));
 
   $variables['id'] = $element['#html_id'];
   $variables['menu_classes'] = $menu_classes;
@@ -100,13 +101,13 @@ function template_preprocess_superfish_menu_items(array &$variables) {
   $active_trails = \Drupal::service('menu.active_trail')
     ->getActiveTrailIds($element['#menu_name']);
 
-  foreach ($menu as $key => $menu_item) {
+  foreach ($menu as $menu_item) {
 
     if (NULL !== $menu_item->link &&
         !($menu_item->link instanceof InaccessibleMenuLink)) {
 
       $item_class = $link_class = [];
-      $multicolumn_wrapper = $multicolumn_column = $multicolumn_content = FALSE;
+      $multicolumn_wrapper = $multicolumn_column = $multicolumn_content = $nolink = FALSE;
 
       // Menu link properties.
       $link = $menu_item->link->getPluginDefinition();
@@ -125,17 +126,24 @@ function template_preprocess_superfish_menu_items(array &$variables) {
         'inActiveTrail' => $menu_item->inActiveTrail,
       ];
 
-      if ($menu_item->link->getUrlObject()->isRouted()) {
+      if ($item['url']->isRouted()) {
         // Adding the "is-active" class.
         $host = \Drupal::request()->getHttpHost();
         $request_uri = \Drupal::request()->getRequestUri();
         $current_url = Url::fromRoute('<current>');
         $current_path = $current_url->toString();
         $link_url = $item['url']->toString();
+        // Anchor links.
+        if (strpos($link_url, '#') !== FALSE) {
+          $link_url = explode('#', $link_url);
+          $link_url = $link_url[0];
+        }
+
         if ($link_url == $current_path || $link_url == $request_uri ||
             $link_url == $host . $request_uri) {
           $link_class[] = 'is-active';
         }
+        $nolink = $item['url']->getRouteName() === '<nolink>' ? TRUE : FALSE;
       }
 
       // Adding the necessary "active-trail" class.
@@ -228,7 +236,7 @@ function template_preprocess_superfish_menu_items(array &$variables) {
 
         // sfTouchscreen.
         // Preparing the cloned parent links to be added to the sub-menus.
-        if ($settings['clone_parent'] && $item['subtree']) {
+        if ($settings['clone_parent'] && $item['subtree'] && !$nolink) {
           $cloned_parent = $menu_item;
           $cloned_parent->subtree = [];
         }
@@ -257,7 +265,7 @@ function template_preprocess_superfish_menu_items(array &$variables) {
       }
 
       // Preparing <li> classes for the theme.
-      $item_class = implode(' ', sf_array_filter($item_class));
+      $item_class = implode(' ', superfish_array_filter($item_class));
 
       // Merging link classes.
       if (isset($item['options']['attributes']['class'])) {
@@ -267,31 +275,51 @@ function template_preprocess_superfish_menu_items(array &$variables) {
         }
         $link_class = array_merge(
           $link_class_current,
-          sf_array_filter($link_class)
+          superfish_array_filter($link_class)
         );
       }
-      $item['options']['attributes']['class'] = sf_array_filter($link_class);
+      $item['options']['attributes']['class'] = superfish_array_filter($link_class);
 
       // Dirty fix! to only add a "menuparent" class.
       $item['options_menuparent'] = $item['options'];
       $item['options_menuparent']['attributes']['class'][] = 'menuparent';
+      if ($nolink) {
+        $item['options_menuparent']['attributes']['class'][] = 'nolink';
+      }
       $link_element = [
         '#type' => 'link',
-        '#title' => SafeMarkup::format($link_text, $link_text_replace),
+        '#title' => new FormattableMarkup($link_text, $link_text_replace),
         '#url' => $item['url'],
         '#options' => $item['options'],
       ];
       $link_element_menuparent = [
         '#type' => 'link',
-        '#title' => SafeMarkup::format($link_text, $link_text_replace),
+        '#title' => new FormattableMarkup($link_text, $link_text_replace),
         '#url' => $item['url'],
         '#options' => $item['options_menuparent'],
       ];
 
-      $id = $element['#menu_name'] . '-' . $item['id'];
+      $item_attributes = new Attribute();
+      if (isset($item['options']['item_attributes'])) {
+        foreach ($item['options']['item_attributes'] as $name => $value) {
+          $value = trim($value);
+          if ($value) {
+            $item_attributes->offsetSet($name, $value);
+          }
+        }
+      }
+
+      $id = Html::getUniqueId($element['#menu_name'] . '-' . $item['id']);
+      if (!$item_attributes->offsetGet('id')) {
+        $item_attributes->offsetSet('id', $id);
+      }
+
+      if ($item_class) {
+        $item_attributes->offsetSet('class', trim($item_attributes->offsetGet('class') . ' ' . $item_class));
+      }
+
       $variables['menu_items'][] = [
-        'id'                  => Html::getUniqueId($id),
-        'item_class'          => $item_class,
+        'attributes'          => $item_attributes,
         'link'                => $link_element,
         'link_menuparent'     => $link_element_menuparent,
         'children'            => $children,
diff --git a/web/modules/superfish/templates/superfish-menu-items.html.twig b/web/modules/superfish/templates/superfish-menu-items.html.twig
index 88eb32f05b..f396137f95 100644
--- a/web/modules/superfish/templates/superfish-menu-items.html.twig
+++ b/web/modules/superfish/templates/superfish-menu-items.html.twig
@@ -23,33 +23,32 @@
 {% spaceless %}
 {% for item in menu_items %}
 
-  {% if item['children'] is not empty %}
+  {% if item.children is not empty %}
     {% set item_class = item.item_class ~ ' menuparent' %}
-    {% if item['multicolumn_column'] %}
+    {% if item.multicolumn_column %}
       {% set item_class = item_class ~ ' sf-multicolumn-column' %}
     {% endif %}
   {% endif %}
 
-  <li id="{{ item.id }}"
-    {% if item['item_class'] %} class="{{ item['item_class'] }}"{% endif %}>
-    {% if item['multicolumn_column'] %}
+  <li{{ item.attributes }}>
+    {% if item.multicolumn_column %}
     <div class="sf-multicolumn-column">
     {% endif %}
-    {% if item['children'] is not empty %}
-      {{ item['link_menuparent'] }}
+    {% if item.children is not empty %}
+      {{ item.link_menuparent }}
     {% else %}
-      {{ item['link'] }}
+      {{ item.link }}
     {% endif %}
-    {% if item['multicolumn_wrapper'] %}<ul class="sf-multicolumn">
-    <li class="sf-multicolumn-wrapper {{ item['item_class'] }}">
+    {% if item.multicolumn_wrapper %}<ul class="sf-multicolumn">
+    <li class="sf-multicolumn-wrapper {{ item.item_class }}">
     {% endif %}
-    {% if item['children'] is not empty %}
-      {% if item['multicolumn_content'] %}<ol>{% else %}<ul>{% endif %}
-      {{ item['children'] }}
-      {% if item['multicolumn_content'] %}</ol>{% else %}</ul>{% endif %}
+    {% if item.children is not empty %}
+      {% if item.multicolumn_content %}<ol>{% else %}<ul>{% endif %}
+      {{ item.children }}
+      {% if item.multicolumn_content %}</ol>{% else %}</ul>{% endif %}
     {% endif %}
-    {% if item['multicolumn_wrapper'] %}</li></ul>{% endif %}
-    {% if item['multicolumn_column'] %}</div>{% endif %}
+    {% if item.multicolumn_wrapper %}</li></ul>{% endif %}
+    {% if item.multicolumn_column %}</div>{% endif %}
   </li>
 
 {% endfor %}
-- 
GitLab