Skip to content

Commit

Permalink
corrections/improvements (#12429)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepereiradasilva authored and zero-24 committed Oct 16, 2016
1 parent e2a5d1b commit 012e227
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
31 changes: 14 additions & 17 deletions libraries/cms/html/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,34 +707,31 @@ public static function script($file, $options = array(), $attribs = array())
// If only path is required
if ($options['pathOnly'])
{
if (count($includes) == 0)
if (count($includes) === 0)
{
return;
}
elseif (count($includes) == 1)

if (count($includes) === 1)
{
return $includes[0];
}
else
{
return $includes;
}

return $includes;
}

// If inclusion is required
else
{
$document = JFactory::getDocument();
$document = JFactory::getDocument();

foreach ($includes as $include)
foreach ($includes as $include)
{
// If there is already a version hash in the script reference (by using deprecated MD5SUM).
if ($pos = strpos($include, '?') !== false)
{
// If there is already a version hash in the script reference (by using deprecated MD5SUM).
if ($pos = strpos($include, '?') !== false)
{
$options['version'] = substr($include, $pos + 1);
}

$document->addScript($include, $options, $attribs);
$options['version'] = substr($include, $pos + 1);
}

$document->addScript($include, $options, $attribs);
}
}

Expand Down
6 changes: 6 additions & 0 deletions libraries/joomla/document/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ public function addScript($url, $options = array(), $attribs = array())
}
}

// Default value for type.
if (!isset($attribs['type']) && !isset($attribs['mime']))
{
$attribs['type'] = 'text/javascript';
}

$this->_scripts[$url] = isset($this->_scripts[$url]) ? array_replace($this->_scripts[$url], $attribs) : $attribs;
$this->_scripts[$url]['options'] = isset($this->_scripts[$url]['options']) ? array_replace($this->_scripts[$url]['options'], $options) : $options;

Expand Down

0 comments on commit 012e227

Please sign in to comment.