- From: Michel Fortin <michel.fortin@michelf.com>
- Date: Sat, 9 Dec 2006 08:54:31 -0500
Le 9 d?c. 2006 ? 7:50, Lachlan Hunt a ?crit :
> 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.
I added this example on the wiki page about the common subset:
<script type="text/javascript">
/* <![CDATA[ */
if (a < 0 && a > 10) alert("A not in range (0 < a < 10).")
/* ]]> */
</script>
I used /* */ for comments instead of // so that the trick can work
with <style> too, and I think the extra spaces make clearer the
relationship between the CDATA block and the script.
<http://wiki.whatwg.org/wiki/Common_Subset>
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
Received on Saturday, 9 December 2006 05:54:31 UTC