RE: <script> elements running only once

Cameron,

Well what should happen in those cases:

- The text / cdata content within an existing script element is changed?
According to what I've said / HTML5 behaviour, this would be ignored as the parent script element has been flagged to be ignored.

- Another text / cdata section is append to the script element. should that new content be eval'd or be ignored as the parent script element is flagged?

mfG / Regards,
Alexander Adam
--
CEO / Geschäftsführer

examotion GmbH
Karl-Grillenberger-Str. 1/1a
90402 Nuernberg

Phone:  +49 911 - 59650-68
Fax:    +49 911 - 59650-69
E-Mail: alexander.adam@examotion.com
Web:    http://www.examotion.com

Geschäftsführer: Alexander Adam
Amtsgericht Nürnberg HRB Nr.: 23803 
Gerichtsstandort: Nürnberg

--------------------------------------------------
LEGAL DISCLAIMER: The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
--------------------------------------------------


> -----Original Message-----
> From: Cameron McCormack [mailto:cam@mcc.id.au]
> Sent: Montag, 9. Juni 2008 10:41
> To: Alexander Adam
> Subject: Re: <script> elements running only once
> 
> Alexander Adam:
> > But re-inserting a script element and thus re-evaluating it would cause
> the script context to be completely polluted. I.e. what happens if re-
> evaluating this script:
> >
> > <script>
> > function testMe() ...
> > </script>
> >
> > The testMe() function would be there twice now causing script errors to
> be thrown.
> 
> It wouldn’t be a script error, but there could indeed be two testMe
> functions existing, if a reference to the first one were stored away:
> 
>   <rect width='100' height='100' onclick='f()'/>
>   <circle cx='200' cy='200' r='50' onclick='g()'/>
>   <script id='s'>function testMe() { alert("abc") }</script>
>   <script>
>     var theFunction = testMe;
> 
>     function f() {
>       theFunction();
>     }
> 
>     function g() {
>       testMe();
>     }
>   </script>
>   <script>
>     var s = document.getElementById('s');
>     s.parentNode.removeChild(s);
>     s.textContent = 'alert("def")';
>     document.documentElement.appendChild(s);
>   </script>
> 
> If re-executing a <script> element upon reinsertion happens, then
> clicking the <rect> should alert "def", while clicking the <circle>
> should alert "abc".
> 
> > Yes keeping a flag on the DOM Object is certainly a good idea. I'd
> > vote for the following behaviour:
> >
> > As soon as a script element has been pushed into the script context
> > (either when loading or inserting it) it becomes a flag. From now
> > on, no matter what is happening, this element will be ignored from
> > inserting and evaluating again..
> 
> That would be consistent with what HTML 5 says, and I’d be happy with
> that, if only for consistency.
> 
> --
> Cameron McCormack ≝ http://mcc.id.au/

Received on Monday, 9 June 2008 08:46:14 UTC