Project

General

Profile

Actions

Bug #100954

open

Additional attributes for page.include** partially broken

Added by Peter Neumann 11 months ago. Updated 3 months ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2023-06-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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>


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #91499: Additional attributes for includeJS, includeCSS and all others include**Closed2020-05-26

Actions
Actions #1

Updated by Oliver Hader 11 months ago

  • Related to Feature #91499: Additional attributes for includeJS, includeCSS and all others include** added
Actions #2

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).

Actions #3

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:

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.
Actions #4

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

Actions #5

Updated by Felix Nagel 5 months ago

Run into this issue when updating an instance from v11.4 to v12.4.8.

Actions #6

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'],
);

Actions

Also available in: Atom PDF