question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Javascript inline breaks in 3.0.4

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielfernandezcommented, Mar 29, 2017

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 separate text 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 for 3.0.5.RELEASE, as this is a quite bad regression 😞

0reactions
xtianuscommented, Mar 30, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found