W3C home > Mailing lists > Public > public-html@w3.org > July 2009

Re: Running "Zombie" Script Elements

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 10 Jul 2009 05:13:22 +0000 (UTC)
To: Jonas Sicking <jonas@sicking.cc>
Cc: Travis Leithead <Travis.Leithead@microsoft.com>, "public-html@w3.org" <public-html@w3.org>, Harley Rosnow <Harley.Rosnow@microsoft.com>, Kirk Sykora <ksykora@microsoft.com>
Message-ID: <Pine.LNX.4.62.0907100510100.23663@hixie.dreamhostps.com>
On Thu, 11 Jun 2009, Jonas Sicking wrote:
> 
> So implementation wise the implementation will have to set some special 
> flag on the script element to tell it not to execute when it otherwise 
> normally would.

Implementations already have at least one flag for <script> that's similar 
to this ("has already executed"), so that seems likely to be pretty 
lightweight, as I understand it.


> The implementation works something like this:
> 
> scriptElement::onTextContentChange()
> {
>   maybeEvalScript();
> }
> 
> scriptElement::onDocumentChange()
> {
>   maybeEvalScript();
> }
> 
> scriptElement::onAttrChange()
> {
>   maybeEvalScript();
> }
> 
> scriptElement::maybeEvalScript()
> {
>   if (!didEvaluate && !wasCreatedByParser && isInDocument() &&
>       (getTextContent() != "" || hasSrcAttribute)) {
>     didEvaluate = true;
>     <evaluate script>;
>   }
> }
> 
> Once the parser is done creating the script, it'll call some function
> on the script to tell it to go. If this function simply unsets the
> wasCreatedByParser flag and calls maybeEvalScript, or if that function
> evaluates the script directly, doesn't really make a difference from
> an implementation complexity view.
> 
> So we'd never need to not insert the script into the DOM (that would
> be more complex all around I'd think).
> 
> The difference implementation wise is very small, simply choosing
> which one of two functions to call.
> 
> As stated before, I don't have a strong preference either way. It seems 
> like good consistency arguments can be made either way, and 
> implementation wise both solutions are equally simple to implement.

I'm not sure I understand exactly what the two proposals you're referring 
to are, but if the spec as is is ok, then let's stick with that. :-)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 10 July 2009 05:14:02 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC