W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2006

[whatwg] Common Subset

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sat, 09 Dec 2006 23:50:58 +1100
Message-ID: <457AB132.7060808@lachy.id.au>
Alexey Feldgendler wrote:
> The HTML5 spec could somehow officially bless CDATA only when used like 
> this:
> 
> <script>//<![CDATA[
> ...
> //]]></script>
> 
> It would not harm because it is already interoperable.

It's technically already allowed because script and style elements are 
defined to contain CDATA.  So basically any string of text that doesn't 
include '</' before the end tag is valid.

It's already interoperable because that whole string is passed to the 
javascript engine, and since the '<![CDATA[' and ']]>' are commented out 
with javascript comments, they're ignored.

For more information, see
http://lachy.id.au/log/2005/05/script-comments


> But it seems somehow stupid to define that <![CDATA[ and ]]> are only 
> allowed inside <script> after "//".

There is nothing to define beyond what is already in the spec.  Just 
like <!-- and --> isn't a real comment inside an HTML script element, 
that isn't a real CDATA section.

Only Opera (AFAIK) even implemented support for CDATA sections in HTML. 
  So although that may suggest that they can be supported by browsers 
without breaking anything, their use wouldn't be backwards compatible 
with other legacy browsers, so they have to be forbidden.

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Saturday, 9 December 2006 04:50:58 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:31 UTC