On Wed, 11 Jan 2012 15:51:47 +0100, Boris Zbarsky <bzbar...@mit.edu> wrote:
On 1/11/12 6:59 AM, Simon Pieters wrote:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1297
Might not be cross-browser yet (e.g. Opera seems to run the image's
onload handler), but should work per spec I think. Well, the load can't
be prevented if it's speculatively loaded it before the script has
executed, but maybe that's fine for the use case.
This also doesn't prevent rendering (which can easily start before
DOMContentLoaded), doesn't prevent execution of script in the document
that's being loaded, etc.
Sure it does (or at least should, and does in Firefox). Note that it
removes the root element when the script element is executed, not at
DOMContentLoaded. It does the transformation and puts the root element
*back* at DOMContentLoaded. Scripts don't run when parsed into the other
document since it is a different document than the one the HTML parser
runs on. They don't run when the root element is put back, either, since
they are marked as already-executed, I think.
The only way something could be rendered with the above script before it
runs is in Opera with DSE enabled.
Again, the hard part of doing a transformation on HTML is not doing the
transformation; it's preventing the transformation source document from
being treated "as usual".
--
Simon Pieters
Opera Software