Skip to content
Snippets Groups Projects

Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS

Closed Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS
Closed Harumi Jang requested to merge issue/drupal-3238915:3238915-refactor-if-feasible into 9.3.x
2 files
+ 13
8
Compare changes
  • Side-by-side
  • Inline
Files
2
  • 5f092913
    Issue #3276618 by catch, mherchel, eojthebrave, Gábor Hojtsy: Olivero sets... · 5f092913
    Gábor Hojtsy authored
    Issue #3276618 by catch, mherchel, eojthebrave, Gábor Hojtsy: Olivero sets inconsistent classes for active trail between menu and book
@@ -29,9 +29,14 @@ protected function assertMenuActiveTrail($tree, $last_active) {
$i = 0;
foreach ($tree as $link_path => $link_title) {
$part_xpath = (!$i ? '//' : '/following-sibling::ul/descendant::');
$part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]';
$part_xpath .= 'li[contains(@class, :classy-class-trail) or contains(@class, :olivero-class-trail)]/a[contains(@href, :href) and contains(text(), :title)]';
// These active trail classes are added by classy/olivero. This should
// be refactored to work with stark and not depend on any specific
// theme.
// https://www.drupal.org/project/drupal/issues/3276652
$part_args = [
':class' => 'menu-item--active-trail',
':classy-class-trail' => 'menu-item--active-trail',
':olivero-class-trail' => 'menu__item--active-trail',
':href' => Url::fromUri('base:' . $link_path)->toString(),
':title' => $link_title,
];
@@ -48,9 +53,10 @@ protected function assertMenuActiveTrail($tree, $last_active) {
$xpath .= '//';
}
$xpath_last_active = ($last_active ? 'and contains(@class, :class-active)' : '');
$xpath .= 'li[contains(@class, :class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
$xpath .= 'li[contains(@class, :classy-class-trail) or contains(@class, :olivero-class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
$args = [
':class-trail' => 'menu-item--active-trail',
':classy-class-trail' => 'menu-item--active-trail',
':olivero-class-trail' => 'menu__item--active-trail',
':class-active' => 'is-active',
':href' => Url::fromUri('base:' . $active_link_path)->toString(),
':title' => $active_link_title,
Loading