Re: document.write from event handlers

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
hsivonen@iki.fi
http://hsivonen.iki.fi/

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