diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index a85ce5e..78a4af1 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -125,8 +125,9 @@ public function generate($text, Url $url, $collect_cacheability_metadata = FALSE // Allow other modules to modify the structure of the link. $this->moduleHandler->alter('link', $variables); - // Move attributes out of options. generateFromRoute(() doesn't need them. - $attributes = new Attribute($variables['options']['attributes']); + // Move attributes out of options. generateFromRoute(() doesn't need them, + // including a placeholder for the href. + $attributes = array('href' => '') + $variables['options']['attributes']; unset($variables['options']['attributes']); $url->setOptions($variables['options']); @@ -142,7 +143,7 @@ public function generate($text, Url $url, $collect_cacheability_metadata = FALSE } $attributes['href'] = $url_string; - $result = SafeMarkup::format('@text', array('@attributes' => $attributes, '@text' => $variables['text'])); + $result = SafeMarkup::format('@text', array('@attributes' => new Attribute($attributes), '@text' => $variables['text'])); return $collect_cacheability_metadata ? $generated_link->setGeneratedLink($result) : $result; }