W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2011

[whatwg] When a script element's child nodes are changed

From: David Flanagan <dflanagan@mozilla.com>
Date: Thu, 27 Oct 2011 16:03:20 -0700
Message-ID: <4EA9E338.2000503@mozilla.com>
?4.3.1 The Script Element says:
>
> When a |script 
> <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>| 
> element that is not marked as being "parser-inserted" 
> <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#parser-inserted> 
> experiences one of the events listed in the following list, the user 
> agent must synchronously prepare 
> <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#prepare-a-script> 
> the |script 
> <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>| 
> element:
>
>   * The |script
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>|
>     element gets inserted into a document
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#insert-an-element-into-a-document>.
>   * The |script
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>|
>     element is in a |Document|
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#in-a-document>
>     and its child nodes are changed.
>   * The |script
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element>|
>     element is in a |Document|
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#in-a-document>
>     and has a |src
>     <http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-src>|
>     attribute set where previously the element had no such attribute.
>
Bullet point 2 seems ambiguous to me.  Does it mean only that the list 
of children changes, or does it mean that any change to any child node 
also causes the script to be prepared?  In particular, if a script with 
no src attribute whose only child is an empty text node is inserted into 
the document, the prepare() algorithm will abort before the 
already_started flag is set.  Later, if I do 
script.firstChild.insertData(jscode) does that trigger script execution?

I haven't tried it out yet to see what browsers do, but I think that the 
spec should be clarified to make it explicit.

     David
Received on Thursday, 27 October 2011 16:03:20 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:37 UTC