W3C home > Mailing lists > Public > public-html@w3.org > November 2008

Re: document.write from event handlers

From: Henri Sivonen <hsivonen@iki.fi>
Date: Thu, 27 Nov 2008 21:36:10 +0200
Message-Id: <E54DF113-AE59-4E05-B357-556D7779BFB7@iki.fi>
To: HTML WG <public-html@w3.org>

On Nov 27, 2008, at 19:06, Henri Sivonen wrote:

> On Nov 27, 2008, at 18:59, Henri Sivonen wrote:
>> More generally, if document.write() occurs for any reason other  
>> than the parser kicking off the evaluation of a script element, it  
>> would be simpler if document.write() returned without tokenizing.
> Hmm. I didn't mean to take a stance on timeouts here. Only on cases  
> where the control is in the parser and document.write would be a re- 
> entrant call to the parser.

Argh. Still wrong. I was thinking of one thing and testing another.

Trying again.

One thing:

For efficient buffering, it's important for the parser to know when it  
needs to drive buffers into a safe point so that document.write() can  
insert into the stream. So far, at least my assumption has been that  
scripts can only execute as a side effect of a parser action when a  
<script> element (either HTML or SVG) is popped off the stack. Now it  
has turned out that scripts can execute as a side effect of a parser  
action also when an <svg> element is popped off the stack.

I think the document.write()-safe points need to be enumerated. In the  
other cases (which hopefully form an empty set), document.write()  
should be a no-op. That is, I think the spec should either  
specifically make the load event for <svg> a safe point for  
document.write() or it should make document.write() a no-op if  
executed at that point. The fewer these document.write()-safe points  
are, the better.

(In theory, discovering all the cases where a script may execute as a  
side effect of a parser action could be left as an exercise to the  
implementor, but that might not lead to the best interop. :-)

Other thing:

document.write() from mutation even handler is not completely  
interoperable. This may not even be a document.write issue but  
something more general related to mutation events.

Henri Sivonen
Received on Thursday, 27 November 2008 19:36:51 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:40 UTC