diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php
index cf43f32ea0448..377f761230b21 100644
--- a/libraries/src/HTML/HTMLHelper.php
+++ b/libraries/src/HTML/HTMLHelper.php
@@ -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)
{
@@ -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)
{
@@ -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);
@@ -787,11 +784,14 @@ 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
{
@@ -799,10 +799,11 @@ public static function webcomponent(string $file, array $options = [])
}
}
+ $components = $document->getScriptOptions('webcomponents');
+
foreach ($includes as $include)
{
$potential = $include . ((strpos($include, '?') === false) ? $version : '');
- $components = Factory::getDocument()->getScriptOptions('webcomponents');
if (in_array($potential, $components))
{
@@ -810,8 +811,9 @@ public static function webcomponent(string $file, array $options = [])
}
$components[] = $potential;
- Factory::getDocument()->addScriptOptions('webcomponents', $components);
}
+
+ $document->addScriptOptions('webcomponents', $components);
}
/**
@@ -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';