Project

General

Profile

Actions

Bug #45511

open

Tidying up of code produced by inline JavaScript

Added by Ian Devlin almost 12 years ago. Updated 5 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
TypoScript
Start date:
2013-02-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.0
PHP Version:
Tags:
Complexity:
easy
Is Regression:
No
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.

Actions #1

Updated by Patrick Broens almost 12 years ago

  • Complexity set to easy
Actions #2

Updated by Mathias Schreiber almost 10 years ago

  • Target version set to 7.2 (Frontend)
  • Is Regression set to No
Actions #3

Updated by Benni Mack over 9 years ago

  • Target version changed from 7.2 (Frontend) to 7.4 (Backend)
Actions #4

Updated by Riccardo De Contardi over 9 years ago

It does not happen when config.removeDefaultJS = external

Actions #5

Updated by Susanne Moog over 9 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #6

Updated by Benni Mack about 9 years ago

  • Target version changed from 7.5 to 8 LTS
Actions #7

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?

Actions #8

Updated by Benni Mack over 7 years ago

  • Target version changed from 8 LTS to Candidate for Major Version
Actions #9

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 :(

Actions #10

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

Actions #11

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"

Actions

Also available in: Atom PDF