W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2014

[whatwg] <script> content restrictions vis-a-vis HTML template data blocks

From: Jesse McCarthy <whatwg-2010-04@jessemccarthy.net>
Date: Wed, 5 Nov 2014 14:46:47 -0500
Message-ID: <8C0C63940E0B44C1A43BB9082EB61131@Computer>
To: <whatwg@whatwg.org>
Re: the "Restrictions for contents of script elements" (4.12.1.2):

Consider <script> elements containing data blocks. It's useful to embed 
templates in these; HTML templates for example. When embedding HTML 
templates, it would be onerous to have to either omit comments or implement 
an escaping / unescaping regimen. The specification suggests 'to always 
escape "<!--" as "<\!--"', which isn't too bad for JavaScript, but would be 
a hassle for HTML templates.

The following examples illustrate my interpretation of the requirements for 
<script> content. Is this correct?

Non-conforming (does not match the "outer" production before "comment-open" 
/ after "comment-close" / or both):

<script type="text/plain"><!-- a --></script>

<script type="text/plain">
<!-- a --></script>

<script type="text/plain"><!-- a -->
</script>


Conforming (newline characters satisfy the "outer" production in both 
positions):

<script type="text/plain">
<!-- a -->
</script>


Conforming (space characters satisfy the "outer" production in both 
positions):

<script type="text/plain"> <!-- a --> </script> 
Received on Wednesday, 5 November 2014 19:48:21 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:32 UTC