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
20 changes: 11 additions & 9 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public static function stylesheet($file, $options = array(), $attribs = array())
}

// If inclusion is required
$document = Factory::getDocument();
$document = Factory::getApplication()->getDocument();

foreach ($includes as $include)
{
Expand Down Expand Up @@ -730,7 +730,7 @@ public static function script($file, $options = array(), $attribs = array())
}

// If inclusion is required
$document = Factory::getDocument();
$document = Factory::getApplication()->getDocument();

foreach ($includes as $include)
{
Expand Down Expand Up @@ -768,9 +768,6 @@ public static function webcomponent(string $file, array $options = [])
// Script core.js is responsible for the polyfills and the async loading of the web components
static::_('behavior.core');

$version = '';
$mediaVersion = Factory::getDocument()->getMediaVersion();

// Add the css if exists
self::_('stylesheet', str_replace('.js', '.css', $file), $options);

Expand All @@ -787,31 +784,36 @@ public static function webcomponent(string $file, array $options = [])
return;
}

$document = Factory::getApplication()->getDocument();
$version = '';

if (isset($options['version']))
{
if ($options['version'] === 'auto')
{
$version = '?' . $mediaVersion;
$version = '?' . $document->getMediaVersion();
}
else
{
$version = '?' . $options['version'];
}
}

$components = $document->getScriptOptions('webcomponents');

foreach ($includes as $include)
{
$potential = $include . ((strpos($include, '?') === false) ? $version : '');
$components = Factory::getDocument()->getScriptOptions('webcomponents');

if (in_array($potential, $components))
{
continue;
}

$components[] = $potential;
Factory::getDocument()->addScriptOptions('webcomponents', $components);
}

$document->addScriptOptions('webcomponents', $components);
}

/**
Expand Down Expand Up @@ -1067,7 +1069,7 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
{
$tag = Factory::getLanguage()->getTag();
$calendar = Factory::getLanguage()->getCalendar();
$direction = strtolower(Factory::getDocument()->getDirection());
$direction = strtolower(Factory::getApplication()->getDocument()->getDirection());

// Get the appropriate file for the current language date helper
$helperPath = 'system/fields/calendar-locales/date/gregorian/date-helper.min.js';
Expand Down