Re: cloneNode() and script execution

On Tue, 20 Jan 2009 03:29:05 +0900, Jonas Sicking <jonas@sicking.cc> wrote:

>> So the proposal is that if the <script> has no @src and a shallow clone  
>> is
>> done the clone should be allowed to execute if someone subsequently adds
>> kids or an @src to it, right?

Yes, basically. The reasoning being that when you don't in fact copy the  
script that has run, a "was executed" flag on the new empty node sort of  
makes no sense.

>>  I could live with that, though it seems to
>> complicate the mental model a bit over "clones of scripts that have  
>> executed don't execute, no matter what you do with them".

Indeed, and I'm not sure it's worth it. I'll leave that to Ian when he  
gets to it..

Jonas:

> In other words, cloning a script node would not clone the 'has
> executed' flag? Independent of if the clone is deep or not?

No, Boris suggests exactly the opposite - always clone the 'has executed'  
flag. I suggest cloning it only for deep clones but don't have a strong  
preference here, just an "I thought it made sense that way" statement.

> I could live with that too, though I'd be somewhat worried about
> people cloning a subtree that happens to contain a <script> node and
> then inserting that subtree somewhere else, thus causing the script to
> evaluate.

Yes, we can not re-evaluate cloned scripts with contents - I think that  
won't be web compatible even though Safari does it.

-- 
Hallvord R. M. Steen
Core JavaScript tester, Opera Software
http://www.opera.com/
Opera - simply the best Internet experience

Received on Tuesday, 20 January 2009 01:54:31 UTC