Re: cloneNode() and script execution

Hallvord R. M. Steen wrote:
> 
> Here is another issue for Ian to ponder while working on the script 
> execution stuff:
> 
> If you clone a script node and append the to the document, does it run?
> 
> Browsers differ:
> 
> cloneNode(true) - Opera no, Firefox no, Safari yes, IE fails
> cloneNode(false) - Opera yes, Firefox no, Safari yes, IE fails
> 
>  From my naturally biased point of view I think Opera makes more sense - 
> a "deep" clone remembers that the script was already executed, a shallow 
> doesn't because it doesn't clone the script code. I think any use cases 
> one might think of for re-executing script clones are already much 
> better handled by putting the code inside a function and doing a simple 
> function call.
> 

It is not so wise idea to run scripts while cloning nodes.
Consider this:

<div id="self">
   ...something...
   <script>
     var s = document.getDocumentById("self").cloneNode();
     document.body.appendNode(s);
   </script>
</div>

It is quite easy to get into this trap.

-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Sunday, 18 January 2009 05:02:35 UTC