Re: [XBL] The script Element

On Thu, 7 Dec 2006, Cameron McCormack wrote:
> 
> 2.15 The script Element
> 
>   script blocks must be evaluated when their end-tag is parsed, or, for
>   dynamically created elements, when they are first inserted into a
>   document. This is the case whether or not the elements are in error.
>   Once evaluated, a script block is dead and changes to its contents or
>   attributes have no effect.
> 
> Does this mean an implementation must keep a track of whether a script
> node has been inserted into a document before?

Yes.


> For example would this cause only one alert to be shown:
> 
>   <svg xmlns="http://www.w3.org/2000/svg">
>     <xbl id="x" xmlns="http://www.w3.org/ns/xbl"/>
>     <script>
>       var x = document.getElementById("x");
>       var e = document.createElementNS("http://www.w3.org/ns/xbl",
>                                        "script");
>       e.textContent = "alert('hi')";
>       x.appendChild(e);
>       x.removeChild(e);
>       x.appendChild(e);
>     </script>
>   </svg>

Yes.


> If so, what’s the reasoning behind this decision?

Compatibility with HTML <script> implementations to allow code re-use.


> I think it would be easier for implementations to just react to 
> DOMNode{InsertedInto,RemovedFrom}Document events.

Mutation events are completely inadequate for implementing this behaviour, 
in general (since they don't guarentee the tree is stable while they fire, 
and thus the DOM might change dramatically before they are handled).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 9 January 2007 00:03:13 UTC