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

RE: Running "Zombie" Script Elements

From: Travis Leithead <Travis.Leithead@microsoft.com>
Date: Fri, 10 Jul 2009 05:22:30 +0000
To: Ian Hickson <ian@hixie.ch>, Jonas Sicking <jonas@sicking.cc>
CC: "public-html@w3.org" <public-html@w3.org>, Harley Rosnow <Harley.Rosnow@microsoft.com>, Kirk Sykora <ksykora@microsoft.com>
Message-ID: <49142F02149340458FDD20841AD0AD560498F4@TK5EX14MBXW653.wingroup.windeploy.ntdev.microsoft.com>
We've been checking into this from an implementation point-of-view, and when we release the parser to handle these cases, it also does run the script regardless (by default). We'd have to add special code to change the natural behavior, and so prefer the spec to stay as-is as well. :)

-----Original Message-----
From: Ian Hickson [mailto:ian@hixie.ch]
Sent: Thursday, July 09, 2009 10:13 PM
To: Jonas Sicking
Cc: Travis Leithead; public-html@w3.org; Harley Rosnow; Kirk Sykora
Subject: Re: Running "Zombie" Script Elements

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:23:14 UTC

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