Bug #45511
open
Tidying up of code produced by inline JavaScript
Added by Ian Devlin almost 12 years ago.
Updated 5 months ago.
Sprint Focus:
On Location Sprint
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.
- Target version set to 7.2 (Frontend)
- Is Regression set to No
- Target version changed from 7.2 (Frontend) to 7.4 (Backend)
It does not happen when config.removeDefaultJS = external
- Target version changed from 7.4 (Backend) to 7.5
- Target version changed from 7.5 to 8 LTS
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?
- Target version changed from 8 LTS to Candidate for Major Version
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 :(
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
- 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"
Also available in: Atom
PDF