Bug #45511
openTidying up of code produced by inline JavaScript
0%
Description
In TypoScript, when using jsInline
or jsFooterInline
, the code that you enter is always enclosed in CDATA
tags and contains a comment indicating that it is inline JS.
It should be possible to indicate that you don't want CDATA
tags (which are XHTML anyway) and definitely no comments should be inserted by the system.
Basically it should be possible to assign some inline JS code and for that code and that code ONLY to appear and nothing extra.
Updated by Mathias Schreiber almost 10 years ago
- Target version set to 7.2 (Frontend)
- Is Regression set to No
Updated by Benni Mack over 9 years ago
- Target version changed from 7.2 (Frontend) to 7.4 (Backend)
Updated by Riccardo De Contardi over 9 years ago
It does not happen when config.removeDefaultJS = external
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Benni Mack about 9 years ago
- Target version changed from 7.5 to 8 LTS
Updated by Marc Horst over 8 years ago
I just looked up the correct handling of the behavior with CDATA.
And I am not sure if the current behavior is false.
The output is
<script type="text/javascript"> /*<![CDATA[*/ /*TS_inlineJS*/ var pageId = 2; /*]]>*/ </script>
The CDATA tag in a comment is the best compatible version.
But it is not really needed since we have HTML5 and modern browsers.
Removing the comment is something else.
Maybe the comment is only usefull in debug mode?
Updated by Benni Mack over 7 years ago
- Target version changed from 8 LTS to Candidate for Major Version
Updated by Riccardo De Contardi almost 6 years ago
That still happens in 9.5.2
Maybe there is still someone that uses an xhtml doctype and wants an xml-alike behavior ; I guess that there are 3 scenarios here
1) Completely remove the /*<![CDATA[*/
and let people use page.headerData
instead if they really need it. (*)
2) add it only if an xhtml doctype is used
3) transform this into a property of page.jsInline
(a boolean)
(*) Note: I tried also for the scenario 1 to write something like:
page.jsInline { 10 = COA 10.10=TEXT 10.10.stdWrap.dataWrap = var pageId = {TSFE:id}; 10.wrap = /*<![CDATA[*/ | /*]]>*/ }
The only problem here is that the /*<![CDATA[*/
wrap does not go away when config.removeDefaultJS = external
is used :(
Updated by Riccardo De Contardi over 1 year ago
The issue is still present on TYPO3 12 and 13; but to see it in action you must set:
config.removeDefaultJS = 1
otherwise, the inline js code will be put in an external file, like when you set
config.removeDefaultJS = external
I cannot say if this behavior is intended
Updated by Benni Mack 5 months ago
- Sprint Focus set to On Location Sprint
We can fix this by making the CDATA part removed when having HTML5.
This is actually easy to implement in TYPO3 v13 - just have a look at "wrapInlineScript" and "wrapInlineStyle" and "createInlineCssTagFromFile"