Re: The SCRIPT element

On 16 Jul 2008, at 16:58, Anne van Kesteren wrote:
> On Wed, 16 Jul 2008 17:55:12 +0200, Francois Remy <fremycompany_pub@yahoo.fr 
> > wrote:
>>
>> If we have <script><!-- --></script> display, we should
>> see no content in the script (because this is a comment
>> that's in the script). But in Firefox and Safari, we see
>> the <!-- --> as plain text. In Opera, after the "fit" button
>> was pressed, we can see the "<!-- -->".
>
> That sounds correct for HTML, since <script> is not parsed like any  
> other element.


In HTML, <script> and <style> are defined as containing CDATA, so <!--  
is a string of characters and not the start of a comment (and magic  
happens to stop them being interpreted as CSS or JS). There is  
something to render here.

In XHTML, <script> and <style> are not defined as containing CDATA, so  
a comment is a comment and stops the script from being executed  
(assuming the document is not served as text/html). There isn't  
something to render here.

-- 
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/

Received on Wednesday, 16 July 2008 16:34:22 UTC