Bug #100954
closedAdditional attributes for page.include** partially broken
100%
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 over 1 year ago
- Related to Feature #91499: Additional attributes for includeJS, includeCSS and all others include** added
Updated by Oliver Hader over 1 year 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 about 1 year 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 about 1 year 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 12 months ago
Run into this issue when updating an instance from v11.4 to v12.4.8.
Updated by Fronzes Philippe 10 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'], );
Updated by Gerrit Code Review 7 months ago
- Status changed from Accepted to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84182
Updated by Gerrit Code Review 7 months ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84182
Updated by Gerrit Code Review 7 months ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84182
Updated by Gerrit Code Review 6 months ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84182
Updated by Gerrit Code Review 6 months ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84206
Updated by Gerrit Code Review 6 months ago
Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84206
Updated by Garvin Hicking 6 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset d6bb232f7878d79e1ea51e9c830db627d5148218.
Updated by Garvin Hicking 6 months ago
(Note: Will work on seeing if we can unify the behaviour so that data.data-XXX and data-XXX is both possible, then deprecate one variant, and have a BC in v14 to no longer have duplication. Or we decide, duplication is fine. I'll probably create a new issue for this and link this)
Updated by Markus Volkmer 6 months ago
- Related to Task #103882: unify additionalAttributes with includeCSS / includeJS added