Bug #100954
openAdditional attributes for page.include** partially broken
0%
Description
TYPO3 v12.1 has introduced the possibility to add additional additional tag attributes for CSS and JavaScript files.
The feature seems to be broken for these include types:
page { includeJSLibs { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } includeJS { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } includeJSFooter { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } }
These are working:
page { includeCSSLibs { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } includeCSS { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } includeJSFooterlibs { someIncludeFile = EXT:sitepackage/... someIncludeFile.data-foo = bar } }
For includeJSFooterlibs
however, it is also mapping reserved attributes like the forceOnTop
in the output source code to <script src="/_assets/dca94d8cd3b58fdfd24fde44814e41a3/…" forceontop="1" data-foo="bar"></script>
Updated by Oliver Hader 11 months ago
- Related to Feature #91499: Additional attributes for includeJS, includeCSS and all others include** added
Updated by Oliver Hader 11 months ago
- Status changed from New to Accepted
\TYPO3\CMS\Frontend\Http\RequestHandler
should filter out these properties (in the first place, tag attributes and TypoScript instructions should not have been mixed, but that started years ago already).
Updated by Ernesto Baschny 8 months ago
For the includeJS properties, the implementation in 12.1 (https://review.typo3.org/c/Packages/TYPO3.CMS/+/65008) introduced a new array key `data.` where these additional attributes are to be added. A nice idea, but:
- wrong name (as Oli already mentioned in the post-review)
- inconsistent (in the includeCSS* properties it doesn't work like that
- wrongly documented (there is no mention of this `data.` neither in the commit message, so it ended up being wrongly documented here: https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#includejs-array
This indeed works:
page {
includeJSLibs {
someIncludeFile = EXT:sitepackage/...
someIncludeFile.data.data-foo = bar
}
includeJS {
someIncludeFile = EXT:sitepackage/...
someIncludeFile.data.data-foo = bar
}
includeJSFooter {
someIncludeFile = EXT:sitepackage/...
someIncludeFile.data.data-foo = bar
}
}
So a solution to keep it compatible with this wrong setup but streamline it would be:
- Introduce a `additionalAttributes.` to both includeCSS and * includeJS properties, to clearly separate them from "internal and documented" attributes (i.e. we saw "if" breaking and other side effects.
- keep the current handling for 12.x? Then it should at least be correctly documented, and the documentation should then also mention that it "will change in 13.x" if it is decided.
Updated by Ernesto Baschny 8 months ago
Since we stumbled over this via the documentation and after it not working digging into the code, I opened an issue to fix the documentation meanwhile: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-Typoscript/issues/788
Updated by Felix Nagel 5 months ago
Run into this issue when updating an instance from v11.4 to v12.4.8.
Updated by Fronzes Philippe 3 months ago · Edited
'forceOnTop' should be unset in the RequestHandler.php in the same way as others TS properties, lines 500 and following, and also 557 and following
unset( $additionalAttributes['if.'], $additionalAttributes['type'], $additionalAttributes['crossorigin'], $additionalAttributes['integrity'], $additionalAttributes['external'], $additionalAttributes['allWrap'], $additionalAttributes['allWrap.'], $additionalAttributes['disableCompression'], $additionalAttributes['excludeFromConcatenation'], $additionalAttributes['integrity'], $additionalAttributes['defer'], $additionalAttributes['nomodule'], );