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

[whatwg] Behavior when <script> is removed from DOM

From: Edward O'Connor <eoconnor@apple.com>
Date: Fri, 02 Dec 2011 14:59:10 -0800
Message-ID: <m2obvqoa0x.fsf@eoconnor.apple.com>
Jonas wrote:

> Currently HTML5 defines that a <script src="..."> element that is
> inserted into the DOM should always execute if the load succeeds. Even
> the the element is removed from the Document before it is executed.
> See
> http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#script-processing-src-prepare
> This makes a lot of sense to me since otherwise we'll introduce a race
> condition where if the load happens quickly enough the script will
> execute despite being later removed. In other words, a piece of DOM
> which is removed may or may not cancel any <script>s inside it.
> In webkit things are even worse. It appears that if you insert a
> <script> in the DOM and *immediately* remove it, before returning to
> the event loop, it still sometimes executes. I.e. webkit appears to
> always be exhibiting racy behavior.

Yeah, gross. I've filed https://bugs.webkit.org/show_bug.cgi?id=73707 to
track this in WebKit.

Received on Friday, 2 December 2011 14:59:10 UTC

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