Issue Bug Closed

#90539TypeError in new AssetCollection related ViewHelpers

Oliver Bartsch 02/26/20, 09:42 updated 04/01/20, 21:14

Description

The ViewHelpers TYPO3\CMS\Fluid\ViewHelpers\Asset\CssViewHelper and TYPO3\CMS\Fluid\ViewHelpers\Asset\ScriptViewHelper are throwing a TypeError if they have an empty body and not provide a source file (href / src).

Argument 2 passed to TYPO3\CMS\Core\Page\AssetCollector::addInlineStyleSheet() must be of the type string, null given, called in /var/www/html/typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php on line 97

respectively

Argument 2 passed to TYPO3\CMS\Core\Page\AssetCollector::addInlineJavaScript() must be of the type string, null given, called in /var/www/html/typo3/sysext/fluid/Classes/ViewHelpers/Asset/ScriptViewHelper.php on line 93

Surely this is a mistake made in the template but this leads to an unnecessary error which could easily be prevented.

Either by using null coalescing to set an empty string in case of null or better just add a condition to check for $this->renderChildren() and not call the addInline*() function at all in this case.

Reviews 1