Re: HTML parsing, <script>, and document.write() test/issue details?

On Thu, 2007-03-15 at 14:26 +1100, Lachlan Hunt wrote:
> Dan Connolly wrote:
> > I'd like to know more about the details. I'd particularly appreciate
> > it if somebody would put together a few test cases that show
> > how parsing rules are integrated with <script> and document.write().
> 
> The spec has a diagram that illustrates how document.write() is 
> integrated with the parsing by injecting markup back into the input 
> stream [1].
> 
> This test case illustrates how document.write() can change the parsing:
> 
> <!DOCTYPE html>
> <title>document.write()</title>
> <body>
> <div>
>    <script>
>      document.write("<\/div>");
>    </script>
>    <p>Is this paragraph within the div or not?
> </div>

Thanks for the clear test case; I'm attaching it here so we can
point various tools at it...

> When script is enabled, the p is a sibling of the div and the </div> at 
> the end will generate a parsing error.  When script is disabled, the p 
> is a child of the div and there is no parsing error.

If the impact of this issue really only went as far as whether
there's an error or not, the benefits of modularity would suggest
breaking the interdependency by coin flip or something.

But I suspect the issue goes further; I suspect that
various authors depend on the connection between document.write()
and the parsing model. I'm interested to learn more about
the reasons why they rely on the interdependency.

I gather google ads uses document.write(); I haven't studied
it closely, yet. I gather that the actual mechanism google uses
is the result of working around all sorts of browser bugs.
I'm interested in test cases that show why more modular
approaches don't work.

I feel a little awkward asking others to do my homework for me;
only people who think this is an important issue for this WG to
address should feel any obligation to help.


> 
> [1] http://www.whatwg.org/specs/web-apps/current-work/#overview
> 
-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E

Received on Friday, 16 March 2007 17:51:33 UTC