From 33ea3aea8a83418ee8a321fd9366d52427ab06cc Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 5 Apr 2016 17:43:55 -0400 Subject: [PATCH] Make module scripts modify less global script state They no longer set document.currentScript, or fire beforescriptexecute and afterscriptexecute events. Closes #997. See #1013 for a future alternative to document.currentScript, and #943 for more discussion of the events. --- source | 71 ++++++++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/source b/source index 8d25ff4bf7c..91d475af433 100644 --- a/source +++ b/source @@ -9037,12 +9037,14 @@ partial /*sealed*/ interface Document {

Returns the script element, or the SVG script element, - that is currently executing. In the case of reentrant script execution, returns the one that - most recently started executing amongst those that have not yet finished executing.

+ that is currently executing, as long as the element represents a classic script. + In the case of reentrant script execution, returns the one that most recently started executing + amongst those that have not yet finished executing.

Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event - handler, or a timeout).

+ handler, or a timeout), or if the currently executing script or SVG + script element represents a module script.

@@ -9051,9 +9053,9 @@ partial /*sealed*/ interface Document {

The currentScript attribute, on - getting, must return the value to which it was most recently initialised. When the - Document is created, the currentScript must be initialised to null.

+ getting, must return the value to which it was most recently set. When the Document + is created, the currentScript must be + initialised to null.

@@ -58882,7 +58884,8 @@ o............A....e
  • -

    Fire a simple event named If the script's type is "classic", fire a simple event named beforescriptexecute that bubbles and is cancelable at the script element.

    @@ -58900,30 +58903,6 @@ o............A....e
  • -
  • - -

    Let old script element be the value to which the script - element's node document's currentScript object was most recently - initialised.

    - -
  • - -
  • - -

    Initialise the script element's node document's currentScript object to the script - element.

    - -
  • - -
  • - -

    Let settings object be the environment settings object of the - script element's node document's Window object.

    - -
  • -
  • Switch on the script's type:

    @@ -58931,8 +58910,23 @@ o............A....e
    "classic"
    -

    Run the classic script given by the script's script.

    +
      +
    1. Let old script element be the value to which the script + element's node document's currentScript object was most recently + set.

    2. + +
    3. Set the script element's node document's currentScript attribute to the + script element.

    4. + +
    5. Run the classic script given by the script's script.

    6. + +
    7. Set the script element's node document's currentScript attribute to old script + element.

    8. +
    "module"
    @@ -58944,14 +58938,6 @@ o............A....e
  • -
  • - -

    Initialise the script element's node document's currentScript object to old script - element.

    - -
  • -
  • Decrement the ignore-destructive-writes counter of neutralised doc, if it was incremented in the earlier step.

    @@ -58960,7 +58946,8 @@ o............A....e
  • -

    Fire a simple event named If the script's type is "classic", fire a simple event named afterscriptexecute that bubbles (but is not cancelable) at the script element.