Make use of CDATA wrapping optional?

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

Make use of CDATA wrapping optional?

Johan Brichau-2
Hi there,

The contents of script tags generated in Seaside are by-default wrapped with CDATA tags.
This used to be required to generate valid xhtml [1].

In html5, they can be used but they can also be safely omitted [2] (which is generally the preferred way in html5).

When using a framework like React.js with JSX templates [3], it is even required to omit the CDATA tag.
The comments inside the script are interpreted by the framework and it does not seem to handle it well when there is the CDATA tag.

As I'm experimenting with a React wrapper for Seaside and I am wondering what the best strategy can be:
- omit CDATA for all script tags being generated on an html5 document
- allow to specifically omit the CDATA tag on a script tag
- inversely: allow to enforce the CDATA tag on a script tag

My preference would be that Seaside automatically omits the CDATA tag when it's in html5 mode (which is the default mode since 3.1), with an option to turn it on for a specific script.
Any thoughts?

Johan

[1] http://javascript.about.com/library/blxhtml.htm
[2] http://stackoverflow.com/questions/3302648/should-i-use-cdata-in-html5
[3] http://facebook.github.io/react/_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Make use of CDATA wrapping optional?

Sven Van Caekenberghe-2

On 13 Apr 2014, at 18:06, Johan Brichau <[hidden email]> wrote:

> My preference would be that Seaside automatically omits the CDATA tag when it's in html5 mode (which is the default mode since 3.1), with an option to turn it on for a specific script.

+1

Furthermore, it looks ugly ;-)

_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Make use of CDATA wrapping optional?

Philippe Marschall
In reply to this post by Johan Brichau-2
On Sun, Apr 13, 2014 at 6:06 PM, Johan Brichau <[hidden email]> wrote:
> Hi there,
>
> The contents of script tags generated in Seaside are by-default wrapped with CDATA tags.
> This used to be required to generate valid xhtml [1].

It's a clever hack from the time when "in the future everybody  is
going to use XHTML". The problem is that in HTML and XHTML the
semantics of the content of <script> tags are different. The comment &
CDATA trick gives us the same semantics in HTML and XHTML (as long as
you don't have ]]> in your scripts).

> In html5, they can be used but they can also be safely omitted [2] (which is generally the preferred way in html5).
>
> When using a framework like React.js with JSX templates [3], it is even required to omit the CDATA tag.
> The comments inside the script are interpreted by the framework and it does not seem to handle it well when there is the CDATA tag.

That sounds like a bug in react.

> As I'm experimenting with a React wrapper for Seaside and I am wondering what the best strategy can be:
> - omit CDATA for all script tags being generated on an html5 document
> - allow to specifically omit the CDATA tag on a script tag
> - inversely: allow to enforce the CDATA tag on a script tag
>
> My preference would be that Seaside automatically omits the CDATA tag when it's in html5 mode (which is the default mode since 3.1), with an option to turn it on for a specific script.
> Any thoughts?

I don't know if anybody ever used XHTML and served it in a way to be
parsed as XML. I don't think anybody will in the future. So it may be
best to just get rid of this clever hack..

Cheers
Philippe
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Make use of CDATA wrapping optional?

Johan Brichau-2

On 14 Apr 2014, at 10:08, Philippe Marschall <[hidden email]> wrote:

>> When using a framework like React.js with JSX templates [3], it is even required to omit the CDATA tag.
>> The comments inside the script are interpreted by the framework and it does not seem to handle it well when there is the CDATA tag.
>
> That sounds like a bug in react.

That's true, but while digging I noticed it was not something that is going to be used anymore in html5 _and_ Seaside does it by default without possibility to alter it.

>> As I'm experimenting with a React wrapper for Seaside and I am wondering what the best strategy can be:
>> - omit CDATA for all script tags being generated on an html5 document
>> - allow to specifically omit the CDATA tag on a script tag
>> - inversely: allow to enforce the CDATA tag on a script tag
>>
>> My preference would be that Seaside automatically omits the CDATA tag when it's in html5 mode (which is the default mode since 3.1), with an option to turn it on for a specific script.
>> Any thoughts?
>
> I don't know if anybody ever used XHTML and served it in a way to be
> parsed as XML. I don't think anybody will in the future. So it may be
> best to just get rid of this clever hack..

So, I guess you agree with making it default when rendering html5?

I think it's still good to have it around. I can remember we used to render in xhtml mode before there was proper support to embed svg in html5. I still remember the horrible bugs we encountered rendering certain characters on the page in things like a title attribute... So, yes, we probably did use it ;-)

I don't know yet if my suggestion can be easily implemented, but I will take a look at it.

Johan_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Make use of CDATA wrapping optional?

Philippe Marschall
On Mon, Apr 14, 2014 at 10:25 AM, Johan Brichau <[hidden email]> wrote:

>
> On 14 Apr 2014, at 10:08, Philippe Marschall <[hidden email]> wrote:
>
>>> When using a framework like React.js with JSX templates [3], it is even required to omit the CDATA tag.
>>> The comments inside the script are interpreted by the framework and it does not seem to handle it well when there is the CDATA tag.
>>
>> That sounds like a bug in react.
>
> That's true, but while digging I noticed it was not something that is going to be used anymore in html5 _and_ Seaside does it by default without possibility to alter it.
>
>>> As I'm experimenting with a React wrapper for Seaside and I am wondering what the best strategy can be:
>>> - omit CDATA for all script tags being generated on an html5 document
>>> - allow to specifically omit the CDATA tag on a script tag
>>> - inversely: allow to enforce the CDATA tag on a script tag
>>>
>>> My preference would be that Seaside automatically omits the CDATA tag when it's in html5 mode (which is the default mode since 3.1), with an option to turn it on for a specific script.
>>> Any thoughts?
>>
>> I don't know if anybody ever used XHTML and served it in a way to be
>> parsed as XML. I don't think anybody will in the future. So it may be
>> best to just get rid of this clever hack..
>
> So, I guess you agree with making it default when rendering html5?

Yes.

> I think it's still good to have it around. I can remember we used to render in xhtml mode before there was proper support to embed svg in html5. I still remember the horrible bugs we encountered rendering certain characters on the page in things like a title attribute... So, yes, we probably did use it ;-)

Ah yes, wasn't MathML the other one?

> I don't know yet if my suggestion can be easily implemented, but I will take a look at it.

It may turn out to be tricky.

Cheers
Philippe
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev