Some modules, for whatever reason, may set a link as class="active" (in the $attributes argument). But function l() may append ' active' if the url path is equal to current. Here's the code from function l():

  if ($path == $_GET['q']) {
    if (isset($attributes['class'])) {
      $attributes['class'] .= ' active';
    }
    else {
      $attributes['class'] = 'active';
    }
  }

Here's a possible solution to illustrate what I mean:

  if ($path == $_GET['q']) {
    if (isset($attributes['class']) && $attributes['class'] != 'active') {
      $attributes['class'] .= ' active';
    }
    else {
      $attributes['class'] = 'active';
    }
  }

Comments

Zen’s picture

Priority: Normal » Minor

Won't it be better to fix the offending modules instead ?

Cheers :)
-K

varunvnair’s picture

Does it really matter? I don't think giving a particular element the same class twice makes any difference. The relevant style will be applied just once.

Stefan Nagtegaal’s picture

Well, IMO it does make a difference.. We try to keep the code as clean as possible, and applying two of the same classes makes no sense..

markus_petrux’s picture

Zen: In fact, I've seen this problem when testing the taxonomy context module (already branched for 4.7) and reported the issue here: http://drupal.org/node/45941

Still, I think Drupal core should always try to generate clean HTML. So I opened this issue here as well.

chx’s picture

Status: Active » Closed (won't fix)

This is not the first time asking for cluttering Drupal with fix up code for broken contrib. No.