diff --git a/source b/source index 234caa8a2f8..79148642b9a 100644 --- a/source +++ b/source @@ -91374,14 +91374,12 @@ document.querySelector("button").addEventListener("click", bound); we only asked for "type" assertions in HostGetSupportedImportAssertions.

-
  • If moduleRequest.[[Assertions]] has a Record entry - such that entry.[[Key]] is "type", then let module - type be entry.[[Value]]. Otherwise let module type be "javascript".

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

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

  • +
  • 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.

  • Fetch a single module script given url, settings object, "script", options, settings object, @@ -91393,7 +91391,7 @@ document.querySelector("button").addEventListener("click", bound);

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

  • -
  • Let visited set be « (url, module type) ».

  • +
  • Let visited set be « (url, moduleType) ».

  • Fetch the descendants of and link result given settings object, @@ -91741,20 +91739,18 @@ document.querySelector("button").addEventListener("click", bound); href="#validate-requested-module-specifiers">previously successful with these same two arguments.

  • -
  • If requested.[[Assertions]] has a Record entry such - that entry.[[Key]] is "type", then let module type - be entry.[[Value]]. Otherwise let module type be "javascript".

  • +
  • Let moduleType be the result of running the module type from module + request steps given requested.

  • If visited set does not contain - (url, module type), then:

    + (url, moduleType), then:

    1. Append requested to moduleRequests.

    2. -
    3. Append (url, module type) to +

    4. Append (url, moduleType) to visited set.

  • @@ -91807,13 +91803,11 @@ document.querySelector("button").addEventListener("click", bound); href="#validate-requested-module-specifiers">previously successful with these same two arguments.

    -
  • If moduleRequest.[[Assertions]] has a Record entry - such that entry.[[Key]] is "type", then let module - type be entry.[[Value]]. Otherwise let module type be "javascript".

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

  • Assert: visited set contains - (url, module type).

  • + (url, moduleType).

  • Fetch a single module script given url, fetch client settings object, destination, options, module map settings object, @@ -91844,23 +91838,15 @@ document.querySelector("button").addEventListener("click", bound); complete with either null (on failure) or a module script (on success).

      -
    1. Let module type be "javascript".

    2. +
    3. Let moduleType be "javascript".

    4. -
    5. -

      If moduleRequest was given and moduleRequest.[[Assertions]] has a - Record entry such that entry.[[Key]] is "type", then:

      - -
        -
      1. Assert: No more than one such Record exists.

      2. +
      3. If moduleRequest was given, then set moduleType to the result of + running the module type from module request steps given + moduleRequest.

      4. -
      5. Set module type to entry.[[Value]].

      6. -
      -
    6. - -
    7. Assert: the result of running the module type allowed steps given module - type and module map settings object is true. Otherwise we would not have reached - this point because a failure would have been raised when inspecting +

    8. Assert: the result of running the module type allowed steps given + moduleType and module map settings object is true. Otherwise we would not + 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.

    9. @@ -91868,17 +91854,17 @@ document.querySelector("button").addEventListener("click", bound);
    10. Let moduleMap be module map settings object's module map.

    11. -
    12. If moduleMap[(url, module type)] is +

    13. If moduleMap[(url, moduleType)] is "fetching", wait in parallel until that entry's value changes, then queue a task on the networking task source to proceed with running the following steps.

    14. -
    15. If moduleMap[(url, module type)]

      If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with - moduleMap[url / module type], and return.

    16. + moduleMap[url / moduleType], and return.

      -
    17. Set moduleMap[(url, module - type)] to "fetching".

    18. +
    19. Set moduleMap[(url, + moduleType)] to "fetching".

    20. Let request be a new request whose URL is url, ok status.

    21. -

      then set moduleMap[(url, module - type)] to null, asynchronously complete this algorithm with null, and return.

      +

      then set moduleMap[(url, + moduleType)] to null, asynchronously complete this algorithm with null, and + return.

    22. Let source text be the result of UTF-8 @@ -91941,26 +91928,26 @@ document.querySelector("button").addEventListener("click", bound);

    23. Let module script be null.

    24. -
    25. If MIME type is a JavaScript MIME type and module type +

    26. If MIME type is a JavaScript MIME type and moduleType is "javascript", then set module script to the result of creating a JavaScript module script given source text, module map settings object, response's url, and options.

    27. If the MIME type essence of MIME type is "text/css" - and module type is "css", then set module script to + and moduleType is "css", then set module script to the result of creating a CSS module script given source text and module map settings object.

    28. -
    29. If MIME type essence is a JSON MIME type and module - type is "json", then set module script to the result of +

    30. If MIME type essence is a JSON MIME type and moduleType + is "json", then set module script to the result of creating a JSON module script given source text and module map settings object.

    31. -

      Set moduleMap[(url, module - type)] to module script, and asynchronously complete this algorithm with - module script.

      +

      Set moduleMap[(url, + moduleType)] to module script, and asynchronously complete this algorithm + with module script.

      It is intentional that the module map is keyed by the request URL, whereas the marked as itself having a parse error.)

    32. -
    33. If moduleRequest.[[Assertions]] has a Record entry - such that entry.[[Key]] is "type", then let module - type be entry.[[Value]]. Otherwise let module type be "javascript".

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

    36. -
    37. Let childModule be moduleMap[(childURL, module - type)].

    38. +
    39. Let childModule be moduleMap[(childURL, + moduleType)].

    40. Assert: childModule is a module script (i.e., it is not "fetching" or null); by now all module @@ -92153,14 +92138,12 @@ document.querySelector("button").addEventListener("click", bound); a module specifier given script's base URL and requested.[[Specifier]].

    41. -
    42. If requested.[[Assertions]] has a Record entry such - that entry.[[Key]] is "type", then let module type - be entry.[[Value]]. Otherwise let module type be "javascript".

    43. +
    44. Let moduleType be the result of running the module type from module + request steps given requested.

    45. If url is failure, or if the result of running the module type - allowed steps given module type and settings is false, then:

      + allowed steps given moduleType and settings is false, then:

      1. Let error be a new TypeError exception.

      2. @@ -92252,16 +92235,45 @@ document.querySelector("button").addEventListener("click", bound);
      3. Return script.

      -

      The module type allowed steps, given a string module type +

      The module type from module request steps, given a ModuleRequest + Record moduleRequest, are as follows:

      + +
        +
      1. Let moduleType be "javascript".

      2. + +
      3. +

        If moduleRequest.[[Assertions]] has a Record entry such + that entry.[[Key]] is "type", then:

        + +
          +
        1. +

          If entry.[[Value]] is "javascript", then set + moduleType to null.

          + +

          This specification uses the "javascript" module type + internally for JavaScript module scripts, so + this step is needed to prevent modules from being imported using a "javascript" type assertion (a null moduleType will cause the + module type allowed check to fail).

          +
        2. + +
        3. Otherwise, set moduleType to entry.[[Value]].

        4. +
        +
      4. + +
      5. Return moduleType.

      6. +
      + +

      The module type allowed steps, given a string moduleType and an environment settings object settings, are as follows:

        -
      1. If module type is not "javascript", "

        If moduleType is not "javascript", "css", or "json", then return false.

      2. -
      3. If module type is "css" and the +

      4. If moduleType is "css" and the CSSStyleSheet interface is not exposed in - setting's Realm, then + settings's Realm, then return false.

      5. Return true.

      6. @@ -93164,6 +93176,25 @@ import "https://example.com/foo/../module2.mjs";
        the correct type from succeeding.

        +
        +

        JavaScript module scripts are the default import type when importing from another JavaScript + module; that is, when an import statement lacks a type import assertion the imported module script's type will be JavaScript. + Attempting to import a JavaScript resource using an import statement with + a type import assertion will fail:

        + +
        <script type="module">
        +    // All of the following will fail, assuming that the imported .mjs files are served with a
        +    // JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with
        +    // any import type assertion.
        +    import foo from "./foo.mjs" assert { type: "javascript" };
        +    import foo2 from "./foo2.mjs" assert { type: "js" };
        +    import foo3 from "./foo3.mjs" assert { type: "" };
        +    await import("./foo4.mjs", { assert: { type: null } });
        +    await import("./foo5.mjs", { assert: { type: undefined } });
        +</script>
        +
        +

        To resolve a module specifier given a URL base URL and a @@ -93401,14 +93432,12 @@ import "https://example.com/foo/../module2.mjs"; same two arguments (either while creating the corresponding module script, or in fetch an import() module script graph).

        -
      7. If moduleRequest.[[Assertions]] has a Record entry such - that entry.[[Key]] is "type", then let module type - be entry.[[Value]]. Otherwise let module type be "javascript".

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

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

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

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