Re: Restrictions for contents of script elements

On Tue, 13 Apr 2010, Julien Royer wrote:
> 
> I don't understand the restrictions defined for the content of script 
> elements: 
> http://dev.w3.org/html5/spec/semantics.html#restrictions-for-contents-of-script-elements
> 
> script being a raw-text element, it can't contain the "script-end" 
> production 
> (http://www.w3.org/TR/html5/syntax.html#cdata-rcdata-restrictions).
> 
> Why do we need such a complex ABNF for the content of script elements?

Unfortunately for historical reasons the parsing rules for <script> blocks 
are really obscure and can lead to some really strange results. For 
example:

 "<script><script></script>" closes at the </script>
 "<script><!--</script>" closes at the </script>
 "<script><!--<script></script></script>" closes at the _second_ </script>

Since we're basically stuck living with these silly rules (they're needed 
to parse legacy documents), we have the complex ABNF you refer to to 
prevent authors from trying to write stuff that doesn't work right.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 13 April 2010 20:04:11 UTC