Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions libraries/joomla/document/renderer/html/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@ public function fetchHead($document)
$buffer .= ' />' . $lnEnd;
}

$defaultCssMimes = array('text/css');

// Generate stylesheet links
foreach ($document->_styleSheets as $strSrc => $strAttr)
{
$buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '"';

if (!is_null($strAttr['mime']) && (!$document->isHtml5() || $strAttr['mime'] != 'text/css'))
if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultCssMimes)))
{
$buffer .= ' type="' . $strAttr['mime'] . '"';
}
Expand All @@ -156,7 +158,14 @@ public function fetchHead($document)
// Generate stylesheet declarations
foreach ($document->_style as $type => $content)
{
$buffer .= $tab . '<style type="' . $type . '">' . $lnEnd;
$buffer .= $tab . '<style';

if (!is_null($type) && (!$document->isHtml5() || !in_array($type, $defaultCssMimes)))
{
$buffer .= ' type="' . $type . '"';
}

$buffer .= '>' . $lnEnd;

// This is for full XHTML support.
if ($document->_mime != 'text/html')
Expand All @@ -175,15 +184,14 @@ public function fetchHead($document)
$buffer .= $tab . '</style>' . $lnEnd;
}

$defaultJsMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript');

// Generate script file links
foreach ($document->_scripts as $strSrc => $strAttr)
{
$buffer .= $tab . '<script src="' . $strSrc . '"';
$defaultMimes = array(
'text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript'
);

if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultMimes)))
if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultJsMimes)))
{
$buffer .= ' type="' . $strAttr['mime'] . '"';
}
Expand All @@ -204,7 +212,14 @@ public function fetchHead($document)
// Generate script declarations
foreach ($document->_script as $type => $content)
{
$buffer .= $tab . '<script type="' . $type . '">' . $lnEnd;
$buffer .= $tab . '<script';

if (!is_null($type) && (!$document->isHtml5() || !in_array($type, $defaultJsMimes)))
{
$buffer .= ' type="' . $type . '"';
}

$buffer .= '>' . $lnEnd;

// This is for full XHTML support.
if ($document->_mime != 'text/html')
Expand All @@ -226,7 +241,14 @@ public function fetchHead($document)
// Generate script language declarations.
if (count(JText::script()))
{
$buffer .= $tab . '<script type="text/javascript">' . $lnEnd;
$buffer .= $tab . '<script';

if (!$document->isHtml5())
{
$buffer .= ' type="text/javascript"';
}

$buffer .= '>' . $lnEnd;

if ($document->_mime != 'text/html')
{
Expand Down