No Code Attached Yet bug
avatar hans2103
hans2103
13 Jun 2022

A link element must not appear as a descendant of a body element unless the link element has an itemprop attribute or has a rel attribute whose value contains dns-prefetch, modulepreload, pingback, preconnect, prefetch, preload, prerender, or stylesheet.

This message appears when you use https://validator.w3.org/nu/ to validate a multilingual Joomla 4.x installation and adjusted the template by moving the <jdoc:include type="scripts" /> from the head element to just above </body>.

The error (which what it is according to the HTML validation) is caused by the following piece of code:

// Add x-default language tag
if ($this->params->get('xdefault', 1))
{
$xdefault_language = $this->params->get('xdefault_language', $this->default_lang);
$xdefault_language = ($xdefault_language === 'default') ? $this->default_lang : $xdefault_language;
if (isset($languages[$xdefault_language]))
{
// Use a custom tag because addHeadLink is limited to one URI per tag
$doc->addCustomTag('<link href="' . $server . $languages[$xdefault_language]->link . '" rel="alternate" hreflang="x-default">');
}
}

Do you all agree this needs to be fixed?

avatar hans2103 hans2103 - open - 13 Jun 2022
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jun 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Jun 2022
avatar hans2103 hans2103 - change - 13 Jun 2022
The description was changed
avatar hans2103 hans2103 - edited - 13 Jun 2022
avatar brianteeman
brianteeman - comment - 14 Jun 2022

I can confirm your findings. At least according to the docs this is a bug

/**
* Adds a custom HTML string to the head block
*
* @param string $html The HTML to add to the head
*
* @return HtmlDocument instance of $this to allow chaining
*
* @since 1.7.0
*/
public function addCustomTag($html)
{
$this->_custom[] = trim($html);
return $this;
}

avatar chmst chmst - change - 17 Feb 2023
Labels Added: bug
avatar chmst chmst - labeled - 17 Feb 2023

Add a Comment

Login with GitHub to post a comment