Javascript inline breaks in 3.0.4
See original GitHub issueI just updated the libraries to v3.0.4 and javascript inlining stopped working properly.
The following code
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
Hello
<script type="text/javascript" th:inline="javascript">
function startCheckSessionTimer() {
return setInterval(function() {
console.log([[@{'/someUrl'}]]);
}, [[60*1000]]);
}
</script>
</body>
</html>
produces the following wrong output:
<!DOCTYPE html>
<html>
<body>
Hello
<script type="text/javascript">
function startCheckSessionTimer() {
return setInterval(function() {
console.log([[@{'/someUrl'}]]);
}, 60000);
}
</script>
</body>
</html>
where the console.log line has not been inlined correctly.
My dependency tree:
| +--- org.thymeleaf:thymeleaf-spring4:3.+ -> 3.0.4.RELEASE
| | +--- org.thymeleaf:thymeleaf:3.0.4.RELEASE
| | | +--- ognl:ognl:3.1.12
| | | | \--- org.javassist:javassist:3.20.0-GA
| | | +--- org.attoparser:attoparser:2.0.3.RELEASE
| | | +--- org.unbescape:unbescape:1.1.4.RELEASE
| | | \--- org.slf4j:slf4j-api:1.6.6 -> 1.7.25
| | \--- org.slf4j:slf4j-api:1.6.6 -> 1.7.25
| +--- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.+ -> 3.0.2.RELEASE
| | \--- org.slf4j:slf4j-api:1.6.6 -> 1.7.25
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to break line in JavaScript? - html - Stack Overflow
If you want a linebreak in actual javascript, use the \n escape sequence. onClick="parent.location='mailto:er.saurav123@gmail.com?subject=Thanks ...
Read more >How to add a Line Break in HTML? - Codedamn
This article list down various ways you can add a line break in ... new line thus creating a line break whereas span...
Read more >How to create a line break with JavaScript? - Tutorialspoint
To create a line break in JavaScript, use “<br>”. With this, we can add more than one line break also. Example.
Read more >remove_linebreaks - TinyMCE
remove_linebreaks. This option controls whether line break characters should be removed from output HTML. This option is enabled by default because there are ......
Read more >How to prevent line breaks in the list of items using CSS?
Use height and width property to set an inline element. The display property is used to prevent a line break of a list...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is confirmed. This happens in 3.0.4 when the inlined expression contains a literal, like is your case. Changes in 3.0.4 make the
TextParser
return literals in separatetext
events. In this case, this means an event is generated for all text until"...log([[@{"
, another one for"'/someUrl'"
, and finally a third one for"}]]);..."
This prevents the inliner, which kicks in afterwards, to correctly identify the whole as an inlineable expression, so the expression keeps unchanged.
Sadly we didn’t have a test case for this precise scenario, which is really unfortunate given this use of inlining is quite common in order to apply URL rewriting to URLs used in JavaScript fragments, which would now be impossible (or require all URLs to be first set into variables, which would be an important inconvenience).
I’m afraid we will have to scrap
3.0.4.RELEASE
and go straight for3.0.5.RELEASE
, as this is a quite bad regression 😞#589