W3C home > Mailing lists > Public > public-html@w3.org > January 2009

Re: cloneNode() and script execution

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Tue, 20 Jan 2009 10:54:09 +0900
To: "Jonas Sicking" <jonas@sicking.cc>, "Boris Zbarsky" <bzbarsky@mit.edu>
Cc: public-html@w3.org
Message-ID: <op.un071e14a3v5gv@hr-opera.oslo.opera.com>

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


> 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
Opera - simply the best Internet experience
Received on Tuesday, 20 January 2009 01:54:31 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:41 UTC