Self-closing Script tag qwirk

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Self-closing Script tag qwirk

Jamie
Hi,

This isn't necessarily a bug in Thymeleaf, but its something that has come up because of the way
Thymeleaf parses xml and then serializes it again slightly differently and I thought others might be
interested.

The problem is if you have a <script> tag that looks like this in a template: <script type="text/javascript" src="http://foo.com/myscript.js"></script>
once Thymeleaf generates a page from it, the tag looks like:
< script type="text/javascript" src="http://foo.com/myscript.js" / >

And with html5 at least (and html 4.01?) Firefox and Chrome don't render the rest of the page.
See: http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1 specifically the bit that says
"Start tag: required, End tag: required", and http://www.w3.org/TR/xhtml1/#C_3.

The workaround for this is to do:
< script type="text/javascript" src="http://foo.com/myscript.js" >< !-- -- >< /script >
that way Thymeleaf preserves the correct element structure.

jamie

would you believe that the self-closing script tag messes up the formatting of this forum post?!  Hence the spaces within the script elements.
Reply | Threaded
Open this post in threaded view
|

Re: Self-closing Script tag qwirk

danielfernandez
Administrator
You are absolutely right.

This is a bug introduced in 1.1.0, as non-minimizable nodes were working perfectly in 1.0.1.

I'm already working on it, and will urgently release 1.1.1 in a matter of hours to fix it (I consider this a major bug, because other tags like "textarea" are also affected and could render some pages unusable).

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Self-closing Script tag qwirk

danielfernandez
Administrator
In reply to this post by Jamie
Hi again,

I've just published Thymeleaf 1.1.1 fixing this bug, and updated all example applications in order to use it. Please allow one-two hours for the Maven repositories to sync (you can already download it from Sourceforge if you wish).

Thymeleaf 1.1.1 is a drop-in replacement for 1.1.0, as it is meant only to fix this minimizable-tag bug.

Thanks,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Self-closing Script tag qwirk

Jamie
Daniel,

Thats an impressive turnaround on that bug!  I've tried v1.1.1 and can confirm that it is indeed fixed.
Your receptiveness and responsiveness to bug reports is really appreciated.

Regards,

Jamie
Reply | Threaded
Open this post in threaded view
|

Re: Self-closing Script tag qwirk

danielfernandez
Administrator
Thank you very much. I'm glad it works for you now.

Regards,
Daniel.