[whatwg] When a script element's child nodes are changed
David Flanagan
dflanagan at mozilla.com
Thu Oct 27 16:03:20 PDT 2011
§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
More information about the whatwg
mailing list