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?

> 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?  Is 
the first load aborted and a new one started?  The specification does not say.

> 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.

> 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.

> 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.

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, 17 July 2006 05:18:21 UTC