[whatwg] [html5] html:style parsing

On Saturday 2006-03-11 00:22 +0000, Ian Hickson wrote:
> On Fri, 4 Nov 2005, L. David Baron wrote:
> >
> > On Monday 2005-10-31 10:53 +1100, Lachlan Hunt wrote:
> > > The current web-apps draft:
> > > 
> > > | For styling languages that consist of pure text, user agents must use
> > > | a concatenation of the contents of all the text nodes and CDATA nodes
> > > | that are direct children of the style  element (ignoring any other
> > > | nodes such as comments or elements), in tree order.
> > 
> > The specification should be clearer that for SGML-based documents (as 
> > opposed to XML-based documents), the parsing rules may mean that things 
> > that look like child nodes aren't actually child nodes (since STYLE has 
> > CDATA parsing according to the HTML4 DTD, and is generally implemented 
> > far closer to that than to normal parsing).  If you specify anything 
> > precisely regarding this, please write testcases to make sure it matches 
> > what's actually implemented, which is probably what's required by the 
> > Web.
> 
> Could you expand on this? I don't really follow.

STYLE and SCRIPT elements have similar parsing rules in tag-soup HTML,
where everything is treated as text until </style> or </script>.  This
is why you see an alert with stuff that looks like tags in:

data:text/html,<style><b><i></style><script>alert(document.getElementsByTagName('style')[0].firstChild.data)</script>

or that script like:

<script>
document.write("<b>foo</b>");
</script>

actually works.

SGML says something slightly different (IIRC, that the element ends at
the first "</", and if the thing that follows isn't the tag name then
the document is wrong), but it is based on an underlying SGML concept (a
content model of "CDATA" in the HTML4 DTD for both elements (different
as an element content model than as an attribute value type), rather
than "#PCDATA").

If the spec is already clear on this, then perhaps nothing needs
changing; I was just responding to the quoted text.

-David

-- 
L. David Baron                                <URL: http://dbaron.org/ >
           Technical Lead, Layout & CSS, Mozilla Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20060313/a400136e/attachment.pgp>

Received on Monday, 13 March 2006 22:54:14 UTC