W3C home > Mailing lists > Public > www-svg@w3.org > July 2006

RE: [SVGMobile12] Question on details of when <script> elements execute

From: Andrew Sledd <Andrew.Sledd@ikivo.com>
Date: Mon, 24 Jul 2006 12:38:46 +0200
Message-ID: <234EB4699C751A4A95DF4FD8D041BBFD26646C@SESTHSRV10.zoomon.local>
To: "Boris Zbarsky" <bzbarsky@mit.edu>
Cc: <www-svg@w3.org>


Below are answers to your questions posed in 
I have not pruned the discussion. So I have prefixed my replies 
with [Andy] to make them easier to search for.

I believe this also answers all the issues to which you refer
in http://lists.w3.org/Archives/Public/www-svg/2006Jul/0107.html.

Please review this email and the updated WD and let us know
if they address your concerns as soon as possible.


PS. Incidentally the comment was previously closed as I had 
thought I sent this Wednesday, but it got caught in my system. 

> -----Original Message-----
> From: Boris Zbarsky [mailto:bzbarsky@mit.edu] 
> Sent: den 17 juli 2006 07:18
> To: Andrew Sledd
> Cc: www-svg@w3.org
> Subject: Re: [SVGMobile12] Question on details of when 
> <script> elements execute
> Andrew Sledd wrote:
> > Some factors that are involved:
> I understand the issues, yes.  Having reread the reply to my 
> load event question, my remaining concerns are as follows 
> (the numbered items):
> 1)  The load event definition says, "In the case the element 
> references a script, the event will be raised only after an 
> attempt to interpret the script has been made."  At the same 
> time, the script element definition says, "Script execution 
> happens just after the load event occurs for the given script 
> element."  These are contradictory.  Which one is correct?
[Andy]  The load event description is correct. The script execution
description has also been updated to reflect this.

> > b) The load event associated with an element that references an 
> > external asset via xlink:href does not occur until the 
> asset is fully 
> > pulled down and available
> 2)  What happens if the xlink:href is changed before the load 
> event fires? 
[Andy] only the original scripts content is executed as per the
spec. The change to xlink:href will raise an additional load
event when the external resource is loaded.

> Is the first load aborted and a new one 
> started?
[Andy] No. Both load events occur. Note however that only the 
original script content is executed. 

> > therefore, if scripting logic changes the <script> element, in some 
> > cases these changes will happen before the original 
> scripting logic is 
> > executed (in which case, the UA must only execute the newer 
> scripting 
> > logic based on the changed DOM)
> 3)  This is what was not obvious to me from the 
> specification.  I believe the specification would benefit 
> from an explicit statement to this effect.
[Andy] The key specification text is that a <script> element is
 "executed at most once"!

> > As a result, the advice to content creators: don't do that.
> For what it's worth, that's an authoring guideline, whereas I 
> was looking for normative text from an implementor's perspective....
> > Scripts should not change <script> tags because this might 
> result in 
> > unpredictable results.
> 4) Only due to unpredictable interleaving with async events.  
> Given an event sequence, I feel that there should be a 
> predictable outcome and that the specification should specify it.
[Andy] Most, and in the case the content is carefully constructed,
I believe nearly all, unpredictability is removed if 
externalResourcesRequired is set to true. In which case the content 
provider receives feedback thru the load event that the 
script-content has executed.

> > 2)  Do scripts created via createElementNS() ever execute?  If so,
> >      when?  Note that it's not clear to me whether the load event
> >      fires on nodes created via DOM methods.
> > 
> > Nodes do not become part of the SVG document until they have been 
> > inserted into the DOM tree.
> Not really important, since I can go ahead and insert them, 
> but I think your reply about load events addresses the 
> concern here, modulo my remaining concern #1.
> > 3)  Do scripts that are clones (via cloneNode()) of other scripts
> >      execute?  If so, when?  Does it matter whether the script that
> >      was cloned had already executed at the time of cloning?
> > 
> > Same answer as above.
> 5)  Again, assume that the <script> is then inserted in the 
> document and let's reask the original question.  Note that 
> this is not a trivial question, since for HTML the de-facto 
> standard behavior is actually different for <script> nodes 
> created via cloneNode() vs those created via createElement().
>  I'm not sure whether the SVG WG wants to specify something 
> like that, but it may be worth thinking about, at least.
> > The new wording is:
> > "Removing or altering script elements after script 
> execution has taken 
> > place has no effect. Inserting a script element into the 
> DOM tree will 
> > cause it to execute."
> 6)  Still subject to the "at most once" constraint, right?  
> Perhaps worth saying this as:
>    "... will cause it to execute if it has never executed before."
> or something.

[Andy] This is meant to answer both 5 and 6; and I hope you agree.
A script element can be cloned or created and inserted.
Each time it is inserted it is executed. The clause "Inserting a 
script element into the DOM tree will cause it to execute." is not 
limited to new or unexecuted script-content. 

> Looking forward to changes to resolve contradiction 1, 
> clarification wording for 2, 3, 4, a decision on 5, and maybe 
> clarification wording on 6.  ;)
> Thanks,
> -Boris
Received on Monday, 24 July 2006 10:33:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:29:32 UTC