diff --git a/source b/source index c41ce67f18a..311afcd86c5 100644 --- a/source +++ b/source @@ -2745,6 +2745,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • exposed
  • a promise rejected with
  • upon rejection
  • +
  • upon fulfillment
  • [LegacyFactoryFunction]
  • [LegacyLenientThis]
  • [LegacyNullToEmptyString]
  • @@ -2876,8 +2877,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The Script Record specification type
  • The Cyclic Module Record specification type
  • The Source Text Module Record specification type and its - Evaluate and - Link methods
  • + Evaluate, + Link and + LoadRequestedModules methods
  • The ArrayCreate abstract operation
  • The Call abstract operation
  • @@ -2891,6 +2893,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The DetachArrayBuffer abstract operation
  • The EnumerableOwnPropertyNames abstract operation
  • The FinishDynamicImport abstract operation
  • +
  • The FinishLoadImportedModule abstract operation
  • The OrdinaryFunctionCreate abstract operation
  • The Get abstract operation
  • The GetActiveScriptOrModule abstract operation
  • @@ -2901,10 +2904,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The HostEnqueuePromiseJob abstract operation
  • The HostEnsureCanAddPrivateElement abstract operation
  • The HostEnsureCanCompileStrings abstract operation
  • -
  • The HostImportModuleDynamically abstract operation
  • +
  • The HostLoadImportedModule abstract operation
  • The HostMakeJobCallback abstract operation
  • The HostPromiseRejectionTracker abstract operation
  • -
  • The HostResolveImportedModule abstract operation
  • The InitializeHostDefinedRealm abstract operation
  • The IsAccessorDescriptor abstract operation
  • The IsCallable abstract operation
  • @@ -92827,9 +92829,8 @@ document.querySelector("button").addEventListener("click", bound); top-level flag will be set for all classic script fetches, and for the initial fetch when fetching an external module script graph, or fetching a module worker script - graph, but not for the fetches resulting from import - statements encountered throughout the graph or from fetching an import() module script graph.

    + graph, but not for the fetches resulting from import statements + encountered throughout the graph or from import() expressions.

    By default, not supplying the perform the @@ -93100,57 +93101,10 @@ document.querySelector("button").addEventListener("click", bound);

  • If result is null, asynchronously complete this algorithm with null, and return.

  • -
  • Let visited set be « (url, "javascript") - ».

  • -
  • Fetch the descendants of - and link result given settings object, "script", and visited set. When this asynchronously completes with - final result, asynchronously complete this algorithm with final - result.

  • - - -

    To fetch an import() module script graph given a moduleRequest, a - base URL, a settings object, and some options, run these steps. - The algorithm will asynchronously complete with either null (on failure) or a module - script (on success).

    - -
      -
    1. Let url be the result of resolving a - module specifier given base URL and moduleRequest.[[Specifier]].

    2. - -
    3. If url is failure, then asynchronously complete this algorithm with null, and - return.

    4. - -
    5. Assert: moduleRequest.[[Assertions]] does not contain any Record - entry such that entry.[[Key]] is not "type", because - we only asked for "type" assertions in - HostGetSupportedImportAssertions.

    6. - -
    7. Let moduleType be the result of running the module type from module - request steps given moduleRequest.

    8. - -
    9. If the result of running the module type allowed steps given - moduleType and settings object is false, then asynchronously complete this - algorithm with null, and return.

    10. - -
    11. Fetch a single module script given url, settings - object, "script", options, settings object, - "client", moduleRequest, and with the - top-level module fetch flag unset. If the caller of this algorithm specified custom - perform the fetch steps, pass those along as - well. Wait until the algorithm asynchronously completes with result.

    12. - -
    13. If result is null, asynchronously complete this algorithm with null, and - return.

    14. - -
    15. Let visited set be « (url, moduleType) ».

    16. - -
    17. Fetch the - descendants of and link result given settings object, - destination, and visited set. When this asynchronously completes with - final result, asynchronously complete this algorithm with final - result.

    18. + and link result given settings object and "script". When this asynchronously completes with final result, + asynchronously complete this algorithm with final result.

    To fetch a modulepreload module script graph given a url, a @@ -93171,12 +93125,9 @@ document.querySelector("button").addEventListener("click", bound);

    If result is not null, optionally perform the following steps:

      -
    1. Let visited set be « (url, "javascript") - ».

    2. -
    3. Fetch the - descendants of and link result given settings object, - destination, and visited set.

    4. + descendants of and link result given settings object and + destination.

    Generally, performing these steps will be beneficial for performance, as it @@ -93200,13 +93151,10 @@ document.querySelector("button").addEventListener("click", bound);

  • If script is null, asynchronously complete this algorithm with null, and return.

  • -
  • Let visited set be an empty set.

  • -
  • Fetch the - descendants of and link script, given settings object, the - destination "script", and visited set. When this asynchronously - completes with final result, asynchronously complete this algorithm with final - result.

  • + descendants of and link script, given settings object and the + destination "script". When this asynchronously completes with final + result, asynchronously complete this algorithm with final result.

    To fetch a module worker script graph @@ -93267,7 +93215,7 @@ document.querySelector("button").addEventListener("click", bound);

    This diagram illustrates how these algorithms relate to the ones above, as well as to each other:

    - +

    To fetch a worklet/module worker script graph given a url, a fetch @@ -93401,188 +93324,76 @@ document.querySelector("button").addEventListener("click", bound);

  • If result is null, asynchronously complete this algorithm with null, and return.

  • -
  • Let visited set be « (url, "javascript") - ».

  • -
  • Fetch the descendants of and link result given fetch client settings - object, destination, and visited set. When this asynchronously - completes with final result, asynchronously complete this algorithm with final - result.

  • + object and destination. When this asynchronously completes with final + result, asynchronously complete this algorithm with final result.

    To fetch the descendants of and link a module script module - script, given a fetch client settings object, a destination, and a - visited set, run these steps. The algorithm will asynchronously complete with either - null (on failure) or with module script (on success).

    + script, given a fetch client settings object and a destination, run + these steps. The algorithm will asynchronously complete with either null (on failure) or with + module script (on success).

      -
    1. Fetch the descendants of - module script, given fetch client settings object, destination, - and visited set.

    2. - -
    3. Return from this algorithm, and run the following steps when fetching the descendants of a module script asynchronously - completes with result.

    4. +
    5. Let record be result's record.

    6. -

      If result is null, then asynchronously complete this algorithm with - result.

      - -

      In this case, there was an error fetching one or more of the descendants. We - will not attempt to link.

      -
    7. - -
    8. Let parse error be the result of finding the first parse error - given result.

    9. - -
    10. If parse error is null, then:

      +

      If record is null, then:

        -
      1. Let record be result's record.

      2. +
      3. Set result's error to + rethrow to result's parse error.

      4. -
      5. -

        Perform record.Link().

        - -

        This step will recursively call Link on all of the module's unlinked dependencies.

        - -

        If this throws an exception, set result's error to rethrow to that exception.

        -
      6. +
      7. Asynchronously complete this algorithm with result.

    11. -
    12. Otherwise, set result's error to - rethrow to parse error.

    13. - -
    14. Asynchronously complete this algorithm with result.

    15. -
    - -

    To fetch the descendants of a module script module script, given a - fetch client settings object, a destination, and a visited set, - run these steps. The algorithm will asynchronously complete with either null (on failure) or - with module script (on success).

    - -
      -
    1. If module script's record is null, - then asynchronously complete this algorithm with module script and return.

    2. - -
    3. Let record be module script's record.

    4. +
    5. +

      Let state be Record { [[ParseError]]: null, [[Destination]]: + destination }.

      +
    6. -
    7. If record is not a Cyclic Module Record, or if - record.[[RequestedModules]] is empty, - asynchronously complete this algorithm with module script.

    8. +
    9. +

      Let loading promise be record.LoadRequestedModules(state).

      -
    10. Let moduleRequests be a new empty list.

    11. +

      This step will recursively load all the module transitive dependencies.

      +
    12. -

      For each ModuleRequest Record - requested of record.[[RequestedModules]],

      +

      Upon rejection of loading promise, run the + following steps:

        -
      1. Let url be the result of resolving - a module specifier given module script's base URL and - requested.[[Specifier]].

      2. - -
      3. Assert: url is never failure, because resolving a module specifier must have been previously successful with these same two - arguments.

      4. - -
      5. Let moduleType be the result of running the module type from module - request steps given requested.

      6. +
      7. If state.[[ParseError]] is not null, set result's error to rethrow to + state.[[ParseError]] and asynchronously complete this algorithm with + result.

      8. -
      9. -

        If visited set does not contain - (url, moduleType), then:

        - -
          -
        1. Append requested to - moduleRequests.

        2. - -
        3. Append (url, moduleType) to - visited set.

        4. -
        -
      10. + +
      11. Otherwise, asynchronously complete this algorithm with null.

    13. -
    14. Let options be the descendant script fetch options for module - script's fetch options.

    15. - -
    16. Assert: options is not null, as module script is a JavaScript - module script.

    17. -
    18. -

      For each moduleRequest in - moduleRequests, perform the internal module script graph fetching - procedure given moduleRequest, fetch client settings object, - destination, options, module script's settings - object, visited set, and module script's base URL. If the caller of this - algorithm specified custom perform the - fetch steps, pass those along while performing the internal module script graph - fetching procedure.

      - -

      These invocations of the internal module script graph fetching procedure should - be performed in parallel to each other.

      - -

      If any of the invocations of the internal module script graph fetching procedure - asynchronously complete with null, asynchronously complete this algorithm with null, and - return.

      - -

      Otherwise, wait until all of the internal module script graph fetching procedure - invocations have asynchronously completed. Asynchronously complete this algorithm with - module script.

      -
    19. -
    - -

    To perform the internal module script graph fetching procedure given a - moduleRequest, a fetch client settings object, a destination, - some options, a module map settings object, a visited set, and a - referrer, perform these steps. The algorithm will asynchronously complete with either - null (on failure) or a module script (on success).

    - -
      -
    1. Let url be the result of resolving - a module specifier given referrer and - moduleRequest.[[Specifier]].

    2. - -
    3. Assert: url is never failure, because resolving a module specifier must have been previously successful with these same two - arguments.

    4. - -
    5. Let moduleType be the result of running the module type from module - request steps given moduleRequest.

    6. - -
    7. Assert: visited set contains - (url, moduleType).

    8. +

      Upon fulfillment of loading promise, run the following steps:

      -
    9. Fetch a single module script given url, fetch client settings - object, destination, options, module map settings object, - referrer, moduleRequest, and with the - top-level module fetch flag unset. If the caller of this algorithm specified custom - perform the fetch steps, pass those along - while fetching a single module script.

      - -
    10. Return from this algorithm, and run the following steps when fetching a single module script asynchronously completes with - result:

    11. +
        +
      1. +

        Perform record.Link().

        -
      2. If result is null, asynchronously complete this algorithm with null, and - return.

      3. +

        This step will recursively call Link on all of the module's unlinked dependencies.

        -
      4. Fetch the descendants of - result given fetch client settings object, destination, and - visited set.

      5. +

        If this throws an exception, set result's error to rethrow to that exception.

        + -
      6. When the appropriate algorithm asynchronously completes with final result, - asynchronously complete this algorithm with final result.

      7. +
      8. Asynchronously complete this algorithm with result.

      9. +
      +

    To fetch a single module script, given a url, a fetch client @@ -93603,7 +93414,7 @@ document.querySelector("button").addEventListener("click", bound); have reached this point because a failure would have been raised when inspecting moduleRequest.[[Assertions]] in create a JavaScript module script or - fetch an import() module script graph.

    + fetch a single imported module script.

  • Let moduleMap be module map settings object's module map.

  • @@ -93716,62 +93527,34 @@ document.querySelector("button").addEventListener("click", bound); -

    To find the first parse error given a root - moduleScript and an optional discoveredSet:

    +

    To fetch a single imported module script, given a settings object, a + base URL, a destination, some options, and a + moduleRequest, run these steps. The algorithm will asynchronously complete with either + null (on failure) or a module script (on success).

      -
    1. Let moduleMap be moduleScript's settings object's - module map.

    2. - -
    3. If discoveredSet was not given, let it be an empty set.

    4. - -
    5. Append moduleScript to - discoveredSet.

    6. - -
    7. If moduleScript's record is null, - then return moduleScript's parse - error.

    8. - -
    9. If moduleScript's record is not a - Cyclic Module Record, then return null.

    10. - -
    11. Let moduleRequests be the value of moduleScript's record's [[RequestedModules]] internal slot.

    12. - -
    13. -

      For each moduleRequest of - moduleRequests:

      - -
        -
      1. Let childURL be the result of resolving a module specifier given moduleScript's base URL and moduleRequest.[[Specifier]]. - (This will never fail, as otherwise moduleScript would have been marked as itself having a parse - error.)

      2. - -
      3. Let moduleType be the result of running the module type from module - request steps given moduleRequest.

      4. - -
      5. Let childModule be moduleMap[(childURL, - moduleType)].

      6. +
      7. Let url be the result of resolving a + module specifier given base URL and + moduleRequest.[[Specifier]].

      8. -
      9. Assert: childModule is a module script (i.e., it is not "fetching" or null); by now all module - scripts in the graph rooted at moduleScript will have successfully been - fetched.

      10. +
      11. If url is failure, then return null.

      12. -
      13. If discoveredSet already contains - childModule, continue.

      14. +
      15. Assert: moduleRequest.[[Assertions]] does not contain any Record + entry such that entry.[[Key]] is not "type", because + we only asked for "type" assertions in + HostGetSupportedImportAssertions.

      16. -
      17. Let childParseError be the result of finding the first parse - error given childModule and discoveredSet.

      18. +
      19. Let moduleType be the result of running the module type from module + request steps given moduleRequest.

      20. -
      21. If childParseError is not null, return childParseError.

      22. -
      -
    14. +
    15. If the result of running the module type allowed steps given + moduleType and settings object is false, then return null.

    16. -
    17. Return null.

    18. +
    19. Fetch a single module script given url, settings + object, destination, options, settings object, + "client", moduleRequest, and with the top-level module + fetch flag unset. When this asynchronously completes with result, asynchronously + complete this algorithm with result.

    Creating scripts
    @@ -94834,9 +94617,8 @@ dictionary PromiseRejectionEventInit : EventInitAs a consequence, this means that when the import() expression is evaluated, there will still be no active script. Fortunately that is handled by our - implementations of HostResolveImportedModule and - HostImportModuleDynamically, by falling back to using the current settings - object's API base URL.

    + implementation of HostLoadImportedModule by falling back to using the + current settings object's API base URL.

    @@ -94870,8 +94652,8 @@ dictionary PromiseRejectionEventInit : EventInit's base URL.

    The returned promise will be rejected if an invalid specifier is given, or if a failure is - encountered while fetching or evaluating the resulting module graph.

    + encountered while fetching or evaluating the + resulting module graph.

    This syntax can be used inside both classic and module scripts. It thus provides a bridge into the module-script @@ -94956,8 +94738,8 @@ import "https://example.com/foo/../module2.mjs";

    This can result in two separate fetches and two separate module evaluations being performed. This is a willful violation of a constraint recommended (but not required) by the - import assertions specification stating that each call to HostResolveImportedModule - with the same (referencingScriptOrModule, moduleRequest.[[Specifier]]) pair + import assertions specification stating that each call to HostLoadImportedModule + with the same (referrer, moduleRequest.[[Specifier]]) pair must return the same Module Record.

    @@ -95118,27 +94900,32 @@ import "https://example.com/foo/../module2.mjs"; ».

    -
    HostImportModuleDynamically(referencingScriptOrModule, - moduleRequest, promiseCapability)
    +
    HostLoadImportedModule(referrer, moduleRequest, + loadState, payload)

    JavaScript contains an implementation-defined HostImportModuleDynamically abstract operation. - User agents must use the following implementation:

    + data-x="js-HostLoadImportedModule">HostLoadImportedModule
    abstract operation. User agents + must use the following implementation:

    1. Let settings object be the current settings object.

    2. If settings object's global - object implements WorkletGlobalScope or - ServiceWorkerGlobalScope, then:

      + object implements WorkletGlobalScope or ServiceWorkerGlobalScope + and loadState is undefined, then:

      + +

      + loadState is undefined when the current fetching process has been initiated by a + dynamic import() call. +

      1. Let completion be Completion { [[Type]]: throw, [[Value]]: a new TypeError, [[Target]]: empty }.

      2. -
      3. Perform FinishDynamicImport(referencingScriptOrModule, - moduleRequest, promiseCapability, completion).

      4. +
      5. Perform FinishLoadImportedModule(referrer, + moduleRequest, payload, completion).

      6. Return.

      @@ -95151,11 +94938,12 @@ import "https://example.com/foo/../module2.mjs"; options.

    3. -

      If referencingScriptOrModule is not null, then:

      +

      If referrer is a Script Record or a Module Record, then:

      1. Let referencing script be - referencingScriptOrModule.[[HostDefined]].

        + referrer.[[HostDefined]].

      2. Set settings object to referencing script's settings object.

      3. @@ -95172,100 +94960,56 @@ import "https://example.com/foo/../module2.mjs"; script.

      -

      As explained above for HostResolveImportedModule, in the common - case, referencingScriptOrModule is non-null.

      -
    4. - -
    5. Fetch an import() module script graph given moduleRequest, - base URL, settings object, and fetch options. Wait until the - algorithm asynchronously completes with result.

    6. - -
    7. Let promise be null. - -

    8. If result is null, then set promise to a promise rejected - with a new TypeError.

    9. - -
    10. Otherwise, set promise to the result of running a module script given result and true.

    11. - -
    12. Perform FinishDynamicImport(referencingScriptOrModule, - moduleRequest, promiseCapability, promise).

    13. - -
    14. Return undefined.

    15. -
    - -
    HostResolveImportedModule(referencingScriptOrModule, - moduleRequest)
    - -

    JavaScript contains an implementation-defined HostResolveImportedModule abstract operation. User - agents must use the following implementation:

    - -
      -
    1. Let settings object be the current settings object.

    2. - -
    3. Let base URL be settings object's API base - URL.

    4. - -
    5. -

      If referencingScriptOrModule is not null, then:

      - -
        -
      1. Let referencing script be - referencingScriptOrModule.[[HostDefined]].

      2. - -
      3. Set settings object to referencing script's settings - object.

      4. - -
      5. Set base URL to referencing script's base URL.

      6. - -
      7. Assert: base URL is not null, as referencing script is a - classic script or a JavaScript module script.

      8. -
      -
      -

      referencingScriptOrModule is not usually null, but will be so for event handlers - per the get the current value of - the event handler algorithm. For example, given:

      +

      referrer is usually a Script Record or a Module Record, but it will not be so for event handlers per the get the current value of the event + handler algorithm. For example, given:

      <button onclick="import('./foo.mjs')">Click me</button>

      If a click event occurs, then at the time the import() expression runs, GetActiveScriptOrModule will - return null, which will be passed to this abstract operation when HostResolveImportedModule is called by - FinishDynamicImport.

      + return null, and this operation will receive the current Realm Record as a + fallback referrer.

    6. -
    7. Let moduleMap be settings object's module map.

    8. +
    9. Let destination be "script".

    10. -
    11. Let url be the result of resolving a - module specifier given base URL and - moduleRequest.[[Specifier]].

    12. +
    13. If loadState is not undefined, set destination to + loadState.[[Destination]].

    14. -
    15. Assert: url is never failure, because resolving a module specifier must have been previously successful with these - same two arguments (either while creating the - corresponding module script, or in fetch an import() module script graph).

    16. +
    17. Fetch a single imported module script given settings object, + base URL, destination, fetch options, and + moduleRequest. Wait until the algorithm asynchronously completes with module + script.

    18. -
    19. Let moduleType be the result of running the module type from module - request steps given moduleRequest.

    20. +
    21. If module script is null, then let completion be Completion { + [[Type]]: throw, [[Value]]: a new TypeError, [[Target]]: empty }.

    22. + +
    23. +

      Otherwise, if module script's parse + error is not null, then:

      -
    24. Let resolved module script be moduleMap[(url, - moduleType)]. (This entry must exist for us to have - gotten to this point.)

    25. +
        +
      1. Let parse error be module script's parse error.

      2. + +
      3. Let completion be Completion { [[Type]]: throw, [[Value]]: parse + error, [[Target]]: empty }.

      4. -
      5. Assert: resolved module script is a module script (i.e., is not - null or "fetching").

      6. +
      7. If loadState is not undefined and loadState.[[ParseError]] is + null, set loadState.[[ParseError]] to parse error.

      8. +
      + -
    26. Assert: resolved module script's record is not null.

      +
    27. Otherwise, let completion be Completion { [[Type]]: normal, [[Value]]: + result's record, [[Target]]: empty + }.

    28. -
    29. Return resolved module script's record.

    30. +
    31. Perform FinishLoadImportedModule(referrer, + moduleRequest, payload, completion).

    HostGetSupportedImportAssertions()
    @@ -97199,9 +96943,8 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl

    In practice, this only affects the resolution of relative URLs via import(), which consult the base URL of the associated - script. Nulling out [[ScriptOrModule]] means that HostResolveImportedModule and - HostImportModuleDynamically will fall back to the current settings - object's API base URL.

    + script. Nulling out [[ScriptOrModule]] means that HostLoadImportedModule will + fall back to the current settings object's API base URL.