diff --git a/source b/source index 89ddfe8a001..178a8af53b6 100644 --- a/source +++ b/source @@ -2207,6 +2207,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • byte sequence
  • string, code unit, + code unit prefix, + code unit less than, + starts with, + ends with, length, and code point length
  • The string equality operations is and @@ -2250,6 +2254,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute clear, getting the keys, getting the values, + sorting in descending order, size, and iterate
  • The list data structure and the associated definitions for @@ -2277,6 +2282,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute item
  • The forgiving-base64 encode and forgiving-base64 decode algorithms
  • +
  • parse a JSON string to an Infra value
  • HTML namespace
  • MathML namespace
  • SVG namespace
  • @@ -2433,6 +2439,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • set the password
  • The application/x-www-form-urlencoded format
  • The application/x-www-form-urlencoded serializer
  • +
  • is special
  • A number of schemes and protocols are referenced by this specification also:

    @@ -4354,6 +4361,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • navigator.credentials.get()
  • + +
    Console
    + +
    +

    The following terms are defined in Console:

    + + +

    @@ -59571,14 +59588,21 @@ interface HTMLScriptElement : HTMLElement { Authors should omit the type attribute instead of redundantly setting it.

    -
  • Setting the attribute to an ASCII case-insensitive match for the string - "module" means that the script is a JavaScript module - script, to be interpreted according to the JavaScript Module top-level production. Module scripts are not affected by the - defer attribute, but are affected by the

    Setting the attribute to an ASCII case-insensitive match for "module" means that the script is a JavaScript module script, to + be interpreted according to the JavaScript Module top-level + production. Module scripts are not affected by the defer attribute, but are affected by the async attribute (regardless of the state of the src attribute).

  • +
  • Setting the attribute to an ASCII case-insensitive match for "importmap" means that the script is an import map, containing + JSON that will be used to control the behavior of module specifier resolution. Import maps can only be inline, i.e., the src attribute and most other attributes are meaningless and not + to be used with them.

  • +
  • Setting the attribute to any other value means that the script is a data block, which is not processed. None of the script attributes (except type itself) have any effect on data blocks. Authors must use @@ -59614,6 +59638,18 @@ interface HTMLScriptElement : HTMLElement {

    The contents of the external script resource for JSON module scripts must conform to the requirements of the JSON specification .

    +

    The contents of inline script elements for import + maps must conform with the import map authoring requirements.

    + +

    For import map script elements, the src, async, nomodule, defer, + crossorigin, integrity, and referrerpolicy attributes must not be specified.

    + +

    A document must not have more than one import map script element.

    +

    When used to include data blocks, the data must be embedded inline, the format of the data must be given using the type attribute, and the contents of the script element must conform to the requirements @@ -59677,6 +59713,12 @@ interface HTMLScriptElement : HTMLElement { data-x="dom-document-write">document.write() method, the handling of scripting, etc.

    +

    When inserted using the document.write() + method, script elements usually + execute (typically blocking further script execution or HTML parsing). When inserted using the + innerHTML and outerHTML + attributes, they do not execute at all.

    +

    The defer attribute may be specified even if the async attribute is specified, to cause legacy web browsers that only support defer (and not HTMLScriptElement : HTMLElement {

    HTMLScriptElement.supports(type)
    -

    Returns true if the given type is a script type supported by the user agent. - The possible script types in this specification are "classic" and - "module", but others might be added in the future. +

    Returns true if the given type is a script type supported by the user agent. The + possible script types in this specification are "classic", "module", and "importmap", but others might be added in + the future.

    @@ -59811,11 +59854,7 @@ interface HTMLScriptElement : HTMLElement { -

    When inserted using the document.write() - method, script elements usually - execute (typically blocking further script execution or HTML parsing). When inserted using the - innerHTML and outerHTML - attributes, they do not execute at all.

    +

    The supports(type) method steps are:

    @@ -59827,9 +59866,14 @@ interface HTMLScriptElement : HTMLElement {
  • If type is "module", then return true.

  • +
  • If type is "importmap", then return + true.

  • +
  • Return false.

  • + +

    The type argument has to exactly match these values; we do not perform an ASCII case-insensitive match. This is different from how type content attribute values are treated, and how @@ -60043,20 +60087,22 @@ o............A....e load event boolean, initially false.

    A script element has a type, which is - either null, "classic", or "module", initially - null. It is determined when the element is prepared, based on the type attribute of - the element at that time.

    + either null, "classic", "module", or "importmap", initially null. It is determined when the element is prepared, based on the type attribute of the element at that time.

    A script element has a result, which is either "uninitialized", null (representing an error), or a script. It is initially "uninitialized".

    + data-x="">uninitialized
    ", null (representing an error), a script, or an import map parse result. It is + initially "uninitialized".

    A script element has steps to run when the result is ready, which are a series of steps or null, initially null. To mark as ready a script element el given a script-or-null result:

    + data-x="concept-script">script, import map parse result, or null + result:

    1. Set el's result to @@ -60191,6 +60237,11 @@ o............A....e el's type to "module".

    2. +
    3. Otherwise, if the script block's type string is an ASCII + case-insensitive match for the string "importmap", then set + el's type to "importmap".

    4. +
    5. Otherwise, return. (No script is executed, and el's type is left as null.)

    6. @@ -60314,6 +60365,18 @@ o............A....e

      If el has a src content attribute, then:

        +
      1. +

        If el's type is "importmap", then queue an element task on the DOM + manipulation task source given el to fire + an event named error at el, and + return.

        + +

        External import map scripts are not currently supported. See WICG/import-maps issue #235 for + discussions on adding support.

        +
      2. +
      3. Let src be the value of el's src attribute.

      4. @@ -60414,6 +60477,26 @@ o............A....e given result.

      + +
      "importmap"
      +
      +
        +
      1. If el's relevant global object's import maps + allowed is false, then queue an element task on the DOM + manipulation task source given el to fire an event named error at el, and return.

      2. + +
      3. Set el's relevant global object's import maps + allowed to false.

      4. + +
      5. Let result be the result of creating an import map parse result given source text and + base URL.

      6. + +
      7. Mark as ready el given result.

      8. +
      +
    @@ -60529,10 +60612,23 @@ o............A....e not "uninitialized".

  • -

    If el is parser-inserted, and either the parser that created - el is an XML parser or it's an HTML parser whose - script nesting level is not greater than one, and el's parser - document has a style sheet that is blocking scripts:

    +

    If all of the following are true:

    + + + +

    then:

    1. Set el's parser document's pending parsing-blocking @@ -60639,6 +60735,15 @@ o............A....e el's result.

    + +
    "importmap"
    +
    +
      +
    1. Register an import map given el's relevant global + object and el's result.

    2. +
    +
  • @@ -93324,6 +93429,8 @@ document.querySelector("button").addEventListener("click", bound); script (on success).

      +
    1. Disallow further import maps given settings object.

    2. +
    3. Fetch a single module script given url, settings object, "script", options, settings object, "client", and with the top-level module fetch flag set. If the @@ -93345,16 +93452,19 @@ document.querySelector("button").addEventListener("click", bound);

    To fetch an import() module script graph given a moduleRequest, a - base URL, a settings object, and some options, run these steps. + script, 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. Disallow further import maps given settings object.

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

    4. + module specifier given script and moduleRequest.[[Specifier]], + catching any exceptions.

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

    6. +
    7. If the previous step threw an exception, then asynchronously complete this algorithm with + null, and return.

    8. Assert: moduleRequest.[[Assertions]] does not contain any Record entry such that entry.[[Key]] is not "type", because @@ -93393,6 +93503,8 @@ document.querySelector("button").addEventListener("click", bound); script (on success), although it will perform optional steps even after completing.

        +
      1. Disallow further import maps given settings object.

      2. +
      3. Fetch a single module script given url, settings object, destination, options, settings object, "client", and with the top-level module fetch flag set. Wait until @@ -93427,6 +93539,8 @@ document.querySelector("button").addEventListener("click", bound); success).

          +
        1. Disallow further import maps given settings object.

        2. +
        3. Let script be the result of creating a JavaScript module script using source text, settings object, base URL, and options.

        4. @@ -93718,12 +93832,11 @@ document.querySelector("button").addEventListener("click", bound);
          1. Let url be the result of resolving - a module specifier given module script's base URL and + a module specifier given module script and requested.[[Specifier]].

          2. -
          3. Assert: url is never failure, because resolving a module specifier must have been

            Assert: the previous step never throws an exception, because resolving a module specifier must have been previously successful with these same two arguments.

          4. @@ -93755,12 +93868,10 @@ document.querySelector("button").addEventListener("click", bound);

            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.

            + destination, options, module script, and visited + set. 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.

            @@ -93777,17 +93888,17 @@ document.querySelector("button").addEventListener("click", bound);

            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).

            + some options, a referringScript, and a visited set, 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 + a module specifier given refereringScript and moduleRequest.[[Specifier]].

            2. -
            3. Assert: url is never failure, because resolving a module specifier must have been

              Assert: the previous step never throws an exception, because resolving a module specifier must have been previously successful with these same two arguments.

            4. @@ -93797,9 +93908,10 @@ document.querySelector("button").addEventListener("click", bound);
            5. Assert: visited set contains (url, moduleType).

            6. -
            7. Fetch a single module script given url, fetch client settings - object, destination, options, module map settings object, - referrer, moduleRequest, and with the +

            8. Fetch a single module script given url, fetch client + settings object, destination, options, referringScript's + settings object, referringScript's base URL, 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.

              @@ -93978,11 +94090,10 @@ document.querySelector("button").addEventListener("click", bound);
              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. + specifier">resolving a module specifier given moduleScript and + moduleRequest.[[Specifier]]. (This will never throw an exception, as otherwise + moduleScript would have been marked + as itself having a parse error.)

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

              4. @@ -94126,15 +94237,27 @@ document.querySelector("button").addEventListener("click", bound);
                1. Let url be the result of resolving - a module specifier given script's base - URL and requested.[[Specifier]].

                2. + a module specifier given script and + requested.[[Specifier]], catching any exceptions.

                  + +
                3. +

                  If the previous step threw an exception, then:

                  + +
                    +
                  1. Set script's parse error + to that exception.

                  2. + +
                  3. Return script.

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

                5. -

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

                  +

                  If the result of running the module type allowed steps given + moduleType and settings is false, then:

                  +
                  1. Let error be a new TypeError exception.

                  2. @@ -94735,6 +94858,812 @@ dictionary PromiseRejectionEventInit : EventInitreason attribute must return the value it was initialized to. It represents the rejection reason for the promise.

                    + +
                    Import map parse results
                    + +

                    An import map parse result is a struct that is similar to a script, and also can be stored in a script element's + result, but is not counted as a script for other purposes. It has the following items:

                    + +
                    +
                    An import map
                    +
                    An import map or null.
                    + +
                    An error to rethrow
                    +
                    A JavaScript value representing an error that will prevent using this import map, when + non-null.
                    +
                    + +

                    To create an import map parse result given a string input + and a URL baseURL:

                    + +
                      +
                    1. Let result be an import map parse result whose import map is null and whose error to rethrow is null.

                    2. + +
                    3. Parse an import map string given input and baseURL, + catching any exceptions. If this threw an exception, then set result's error to rethrow to that exception. Otherwise, set + result's import map to the return + value.

                    4. + +
                    5. Return result.

                    6. +
                    + +

                    To register an import map given a Window global and an + import map parse result result:

                    + +
                      + +
                    1. If result's error to rethrow is + not null, then report the exception given by result's error to rethrow and return.

                    2. + +
                    3. Assert: global's import map is + an empty import map.

                    4. + +
                    5. Set global's import map to + result's import map.

                    6. +
                    + + + + +

                    Module specifier resolution

                    + +
                    The resolution algorithm
                    + +

                    The resolve a module specifier algorithm is the primary entry point for + converting module specifier strings into URLs. When no import maps are involved, it is relatively straightforward, and + reduces to resolving a URL-like module specifier.

                    + +

                    When there is a non-empty import map present, the behavior is more complex. It + checks candidate entries from all applicable module specifier + maps, from most-specific to least-specific scopes (falling back to the top-level unscoped imports), and from most-specific to least-specific + prefixes. For each candidate, the resolve + an imports match algorithm will give on the following results:

                    + +
                    • Successful resolution of the specifier to a URL. Then the + resolve a module specifier algorithm will return that URL.

                    • + +
                    • Throwing an exception. Then the resolve a module specifier algorithm will + rethrow that exception, without any further fallbacks.

                    • + +
                    • Failing to resolve, without an error. In this case the outer resolve a module + specifier algorithm will move on to the next candidate.

                    • +
                    + +

                    In the end, if no successful resolution is found via any of the candidate module specifier maps, resolve a module specifier will throw + an exception. Thus the result is always either a URL or a thrown exception.

                    + +
                    + +

                    To resolve a module specifier given a script-or-null + referringScript and a string specifier:

                    + +
                      +
                    1. Let settingsObject be the current settings object.

                    2. + +
                    3. Let baseURL be settingsObject's API base URL.

                    4. + +
                    5. +

                      If referringScript is not null, then:

                      + +
                        +
                      1. Set settingsObject to referringScript's settings + object.

                      2. + +
                      3. Set baseURL to referringScript's base URL.

                      4. +
                      +
                    6. + +
                    7. Let importMap be an empty import map.

                    8. + +
                    9. If settingsObject's global + object implements Window, then set importMap to + settingsObject's global object's + import map.

                    10. + +
                    11. Let baseURLString be baseURL, serialized.

                    12. + +
                    13. Let asURL be the result of resolving a URL-like module specifier + given specifier and baseURL.

                    14. + +
                    15. Let normalizedSpecifier be the serialization of asURL, if asURL is + non-null; otherwise, specifier.

                    16. + +
                    17. +

                      For each scopePrefixscopeImports + of importMap's scopes:

                      + +
                        +
                      1. +

                        If scopePrefix is baseURLString, or if scopePrefix ends + with U+002F (/) and scopePrefix is a code unit prefix of + baseURLString, then:

                        + +
                          +
                        1. Let scopeImportsMatch be the result of resolving an imports + match given normalizedSpecifier, asURL, and + scopeImports.

                        2. + +
                        3. If scopeImportsMatch is not null, then return + scopeImportsMatch.

                        4. +
                        +
                      2. +
                      +
                    18. + +
                    19. Let topLevelImportsMatch be the result of resolving an imports + match given normalizedSpecifier, asURL, and importMap's + imports.

                    20. + +
                    21. If topLevelImportsMatch is not null, then return + topLevelImportsMatch.

                    22. + +
                    23. +

                      At this point, specifier wasn't remapped to anything by + importMap, but it might have been able to be turned into a URL.

                      + +

                      If asURL is not null, then return asURL.

                      +
                    24. + +
                    25. Throw a TypeError indicating that specifier was a bare specifier, + but was not remapped to anything by importMap.

                    26. +
                    + +

                    To resolve an imports match, given a + string normalizedSpecifier, a URL-or-null asURL, + and a module specifier map specifierMap:

                    + +
                      +
                    1. +

                      For each specifierKey → + resolutionResult of specifierMap:

                      + +
                        +
                      1. +

                        If specifierKey is normalizedSpecifier, then:

                        + +
                          +
                        1. +

                          If resolutionResult is null, then throw a TypeError indicating + that resolution of specifierKey was blocked by a null entry.

                          + +

                          This will terminate the entire resolve a module specifier + algorithm, without any further fallbacks.

                          +
                        2. + +
                        3. Assert: resolutionResult is a URL.

                        4. + +
                        5. Return resolutionResult.

                        6. +
                        +
                      2. + +
                      3. +

                        If all of the following are true:

                        + +
                          +
                        • specifierKey ends with U+002F (/);
                        • + +
                        • specifierKey is a code unit prefix of + normalizedSpecifier; and
                        • + +
                        • either asURL is null, or asURL is special,
                        • +
                        + +

                        then:

                        + +
                          +
                        1. +

                          If resolutionResult is null, then throw a TypeError indicating + that the resolution of specifierKey was blocked by a null entry.

                          + +

                          This will terminate the entire resolve a module specifier + algorithm, without any further fallbacks.

                          +
                        2. + +
                        3. Assert: resolutionResult is a URL.

                        4. + +
                        5. Let afterPrefix be the portion of normalizedSpecifier after the + initial specifierKey prefix.

                        6. + +
                        7. Assert: resolutionResult, serialized, ends with U+002F (/), as enforced during + parsing.

                        8. + +
                        9. Let url be the result of URL parsing + afterPrefix with resolutionResult.

                        10. + +
                        11. +

                          If url is failure, then throw a TypeError indicating that + resolution of normalizedSpecifier was blocked since the afterPrefix + portion could not be URL-parsed relative to the resolutionResult mapped to by + the specifierKey prefix.

                          + +

                          This will terminate the entire resolve a module specifier + algorithm, without any further fallbacks.

                          +
                        12. + +
                        13. Assert: url is a URL.

                        14. + +
                        15. +

                          If the serialization of + resolutionResult is not a code unit prefix of the serialization of url, then throw a + TypeError indicating that the resolution of normalizedSpecifier was + blocked due to it backtracking above its prefix specifierKey.

                          + +

                          This will terminate the entire resolve a module specifier + algorithm, without any further fallbacks.

                          +
                        16. + +
                        17. Return url.

                        18. +
                        +
                      4. +
                      +
                    2. + +
                    3. +

                      Return null.

                      + +

                      The resolve a module specifier algorithm will fall back to a + less-specific scope, or to "imports", if possible.

                      +
                    4. +
                    + +

                    To resolve a URL-like module + specifier, given a string specifier and a URL + baseURL:

                    + +
                      +
                    1. +

                      If specifier starts with "/", "./", or "../", then:

                      + +
                        +
                      1. Let url be the result of URL parsing + specifier with baseURL.

                      2. + +
                      3. +

                        If url is failure, then return null.

                        + +

                        One way this could happen is if specifier is "../foo" and baseURL is a data: URL.

                        +
                      4. + +
                      5. Return url.

                      6. +
                      + +

                      This includes cases where specifier starts with "//", i.e., scheme-relative URLs. Thus, url might end up with a + different host than baseURL.

                      +
                    2. + +
                    3. Let url be the result of URL parsing + specifier (with no base URL).

                    4. + +
                    5. If url is failure, then return null.

                    6. + +
                    7. Return url.

                      +
                    + +
                    + + +
                    Import maps
                    + +

                    An import map allows control over module specifier resolution. Import maps + are delivered via inline script elements with their type attribute set to "importmap", and + with their child text content containing a JSON representation of the import + map.

                    + +

                    Only one import map is processed per Document. After the first import map is + seen, others will be ignored, with their corresponding script elements generating + error events. Similarly, once any modules have been imported, + e.g., via import() expressions or script elements with their type attribute set to "module", further + import maps will be ignored.

                    + +

                    These restrictions, as well as the lack of support for external import maps, are + in place to keep the initial version of the feature simple. They might be lifted over time as + implementer bandwidth allows.

                    + +
                    +

                    The simplest use of import maps is to globally remap a bare module specifier:

                    + +
                    {
                    +  "imports": {
                    +    "moment": "/node_modules/moment/src/moment.js"
                    +  }
                    +}
                    + +

                    This enables statements like import moment from "moment"; + to work, fetching and evaluating the JavaScript module at the /node_modules/moment/src/moment.js URL.

                    +
                    + +
                    +

                    An import map can remap a class of module specifiers into a class of URLs by using trailing + slashes, like so:

                    + +
                    {
                    +  "imports": {
                    +    "moment/": "/node_modules/moment/src/"
                    +  }
                    +}
                    + +

                    This enables statements like import localeData from + "moment/locale/zh-cn.js"; to work, fetching and evaluating the JavaScript module at the + /node_modules/moment/src/moment/locale/zh-cn.js URL. Such trailing-slash + mappings are often combined with bare-specifier mappings, e.g.

                    + +
                    {
                    +  "imports": {
                    +    "moment": "/node_modules/moment/src/moment.js"
                    +    "moment/": "/node_modules/moment/src/"
                    +  }
                    +}
                    + +

                    so that both the "main module" specified by "moment" and the + "submodules" specified by paths such as "moment/locale/zh-cn.js" are + available.

                    +
                    + +
                    +

                    Bare specifiers are not the only type of module specifiers which import maps can remap. + "URL-like" specifiers, i.e., those that are either parseable as absolute URLs or start with + "/", "./", or "../", can be + remapped as well:

                    + +
                    {
                    +  "imports": {
                    +    "https://cdn.example.com/vue/dist/vue.runtime.esm.js": "/node_modules/vue/dist/vue.runtime.esm.js"
                    +    "/js/app.mjs": "/js/app-8e0d62a03.mjs",
                    +    "../helpers/": "https://cdn.example/helpers/"
                    +  }
                    +}
                    + +

                    Note how the URL to be remapped, as well as the URL being mapped to, can be specified either + as absolute URLs, or as relative URLs starting with "/", "./", or "../". (They cannot be specified as relative + URLs without those starting sigils, as those help distinguish from bare module specifiers.) Also + note how the trailing slash mapping works in + this context as well.

                    + +

                    Such remappings operate on the post-canonicalization URL, and do not require a match between + the literal strings supplied in the import map key and the imported module specifier. So for + example, if this import map was included on https://example.com/app.html, + then not only would import "/js/app.mjs" be remapped, but so + would import "./js/app.mjs" and import "./foo/../js/app.mjs".

                    +
                    + +
                    +

                    All previous examples have globally remapped module specifiers, by using the top-level "imports" key in the import map. The top-level "scopes" + key can be used to provide localized remappings, which only apply when the referring module + matches a specific URL prefix. For example:

                    + +
                    {
                    +  "scopes": {
                    +    "/a/" : {
                    +      "moment": "/node_modules/moment/src/moment.js"
                    +    },
                    +    "/b/" : {
                    +      "moment": "https://cdn.example.com/moment/src/moment.js"
                    +    }
                    +  }
                    +}
                    + +

                    With this import map, the statement import "moment" will have + different meanings depending on which referrer script contains the statement:

                    + +
                      +
                    • Inside scripts located under /a/, this will import /node_modules/moment/src/moment.js.

                    • + +
                    • Inside scripts located under /b/, this will import https://cdn.example.com/moment/src/moment.js.

                    • + +
                    • Inside scripts located under /c/, this will fail to resolve and + thus throw an exception.

                    • +
                    + +

                    A typical usage of scopes is to allow multiple versions of the "same" module to exist in a + web application, with some parts of the module graph importing one version, and other parts + importing another version. +

                    + +
                    +

                    Scopes can overlap each other, and overlap the global "imports" + specifier map. At resolution time, scopes are consulted in order of most- to least-specific, + where specificity is measured by sorting the scopes using the code unit less than + operation. So, for example, "/scope2/scope3/" is treated as more specific + than "/scope2/", which is treated as more specific than the top-level + (unscoped) mappings.

                    + +

                    The following import map illustrates this:

                    + +
                    {
                    +  "imports": {
                    +    "a": "/a-1.mjs",
                    +    "b": "/b-1.mjs",
                    +    "c": "/c-1.mjs"
                    +  },
                    +  "scopes": {
                    +    "/scope2/": {
                    +      "a": "/a-2.mjs"
                    +    },
                    +    "/scope2/scope3/": {
                    +      "b": "/b-3.mjs"
                    +    }
                    +  }
                    +}
                    + +

                    This results in the following resolutions (using relative URLs for brevity):

                    + + + + + + + + + +
                    + Specifier +
                    "a" + "b" + "c" +
                    Referrer + /scope1/r.mjs + /a-1.mjs + /b-1.mjs + /c-1.mjs +
                    /scope2/r.mjs + /a-2.mjs + /b-1.mjs + /c-1.mjs +
                    /scope2/scope3/r.mjs + /a-2.mjs + /b-3.mjs + /c-1.mjs +
                    +
                    + +
                    + +

                    The child text content of a script element representing an + import map must match the following import map authoring + requirements:

                    + +
                      +
                    • It must be valid JSON.

                    • + +
                    • The JSON must represent a JSON object, with at most the two keys "imports" and "scopes".

                    • + +
                    • The values corresponding to the "imports" and "scopes" keys, if present, must themselves be JSON objects.

                    • + +
                    • The value corresponding to the "imports" key, if present, must be + a valid module specifier map.

                    • + +
                    • The value corresponding to the "scopes" key, if present, must be a + JSON object, whose keys are valid URL strings and whose + values are valid module specifier + maps.

                    • +
                    + +

                    A valid module specifier map is a JSON object that meets the following + requirements:

                    + +
                      +
                    • All of its keys must be nonempty.

                    • + +
                    • All of its values must be strings.

                    • + +
                    • Each value must be either a valid absolute URL or a + valid URL string that starts with "/", "./", or "../".

                    • + +
                    • If a given key ends with "/", then the corresponding + value must also.

                    • +
                    + + +
                    + +
                    Import map processing model
                    + +

                    Formally, an import map is a struct with two items:

                    + +
                      +
                    • imports, a module specifier + map; and

                    • + +
                    • scopes, an ordered map of + URLs to module specifier + maps.

                      +
                    + +

                    A module specifier map is an ordered map whose keys are strings and whose values are either URLs or nulls.

                    + +

                    An empty import map is an import map with its imports and scopes both being empty maps.

                    + +
                    + +

                    Each Window has an import map, + initially an empty import map.

                    + +

                    Each Window has an import maps allowed boolean, initially true.

                    + +

                    To disallow further import maps given an environment settings object + settingsObject:

                    + +
                      +
                    1. Let global be settingsObject's global object.

                    2. + +
                    3. If global does not implement Window, then return.

                    4. + +
                    5. Set global's import maps allowed to false.

                    6. +
                    + +

                    Import maps are currently disallowed once any module loading has started, or once + a single import map is loaded. These restrictions might be lifted in future specification + revisions.

                    + +
                    + +

                    To parse an import map string, given a string input and a + URL baseURL:

                    + +
                      +
                    1. Let parsed be the result of parsing a JSON string to an Infra value given input.

                    2. + +
                    3. If parsed is not an ordered map, then throw a + TypeError indicating that the top-level value needs to be a JSON object.

                    4. + +
                    5. Let sortedAndNormalizedImports be an empty ordered map.

                    6. + +
                    7. +

                      If parsed["imports"] exists, then:

                      + +
                        +
                      1. If parsed["imports"] is not an ordered + map, then throw a TypeError indicating that the value for the "imports" top-level key needs to be a JSON object.

                      2. + +
                      3. Set sortedAndNormalizedImports to the result of sorting and + normalizing a module specifier map given parsed["imports"] and baseURL.

                      4. +
                      +
                    8. + +
                    9. Let sortedAndNormalizedScopes be an empty ordered map.

                    10. + +
                    11. +

                      If parsed["scopes"] exists, then:

                      + +
                        +
                      1. If parsed["scopes"] is not an ordered + map, then throw a TypeError indicating that the value for the "scopes" top-level key needs to be a JSON object.

                      2. + +
                      3. Set sortedAndNormalizedScopes to the result of sorting and normalizing + scopes given parsed["scopes"] and + baseURL.

                      4. +
                      +
                    12. + +
                    13. +

                      If parsed's keys contains any items besides "imports" or "scopes", then the user agent should report a warning to the + console indicating that an invalid top-level key was present in the import map.

                      + +

                      This can help detect typos. It is not an error, because that would prevent any + future extensions from being added backward-compatibly.

                      +
                    14. + +
                    15. Return an import map whose imports are sortedAndNormalizedImports and + whose scopes are + sortedAndNormalizedScopes.

                    16. +
                    + +
                    +

                    The import map that results from this parsing algorithm is highly normalized. + For example, given a base URL of https://example.com/base/page.html, the + input

                    + +
                    {
                    +  "imports": {
                    +    "/app/helper": "node_modules/helper/index.mjs",
                    +    "lodash": "/node_modules/lodash-es/lodash.js"
                    +  }
                    +}
                    + +

                    will generate an import map with imports of

                    + +
                    «[
                    +  "https://example.com/app/helper" → https://example.com/base/node_modules/helper/index.mjs
                    +  "lodash" → https://example.com/node_modules/lodash-es/lodash.js
                    +]»
                    + +

                    and (despite nothing being present in the input string) an empty ordered map for + its scopes.

                    +
                    + +

                    To sort and normalize a module + specifier map, given an ordered map originalMap and a + URL baseURL:

                    + +
                      +
                    1. Let normalized be an empty ordered map.

                    2. + +
                    3. +

                      For each specifierKeyvalue of + originalMap:

                      + +
                        +
                      1. Let normalizedSpecifierKey be the result of normalizing a specifier + key given specifierKey and baseURL.

                      2. + +
                      3. If normalizedSpecifierKey is null, then continue.

                      4. + +
                      5. +

                        If value is not a string, then:

                        + +
                          +
                        1. The user agent may report a warning to the console indicating that + addresses need to be strings.

                        2. + +
                        3. Set normalized[normalizedSpecifierKey] to null.

                        4. + +
                        5. Continue.

                        6. +
                        +
                      6. + +
                      7. Let addressURL be the result of resolving a URL-like module + specifier given value and baseURL.

                      8. + +
                      9. +

                        If addressURL is null, then:

                        + +
                          +
                        1. The user agent may report a warning to the console indicating that the + address was invalid.

                        2. + +
                        3. Set normalized[normalizedSpecifierKey] to null.

                        4. + +
                        5. Continue.

                        6. +
                        +
                      10. + +
                      11. +

                        If specifierKey ends with U+002F (/), and the serialization of addressURL does not end + with U+002F (/), then:

                        + +
                          +
                        1. The user agent may report a warning to the console indicating that an + invalid address was given for the specifier key specifierKey; since + specifierKey ends with a slash, the address needs to as well.

                        2. + +
                        3. Set normalized[normalizedSpecifierKey] to null.

                        4. + +
                        5. Continue.

                        6. +
                        +
                      12. + +
                      13. Set normalized[normalizedSpecifierKey] to + addressURL.

                      14. +
                      +
                    4. + +
                    5. Return the result of sorting in descending order + normalized, with an entry a being less than an entry b if + a's key is code unit less than + b's key.

                    6. +
                    + +

                    To sort and normalize scopes, given an + ordered map originalMap and a URL baseURL:

                    + +
                      +
                    1. Let normalized be an empty ordered map.

                    2. + +
                    3. +

                      For each scopePrefix → + potentialSpecifierMap of originalMap:

                      + +
                        +
                      1. If potentialSpecifierMap is not an ordered map, then throw a + TypeError indicating that the value of the scope with prefix + scopePrefix needs to be a JSON object.

                      2. + +
                      3. Let scopePrefixURL be the result of URL + parsing scopePrefix with baseURL.

                      4. + +
                      5. +

                        If scopePrefixURL is failure, then:

                        + +
                          +
                        1. The user agent may report a warning to the console that the scope prefix + URL was not parseable.

                        2. + +
                        3. Continue.

                        4. +
                        +
                      6. + +
                      7. Let normalizedScopePrefix be the serialization of scopePrefixURL.

                      8. + +
                      9. Set normalized[normalizedScopePrefix] to the result of + sorting and normalizing a module specifier map given + potentialSpecifierMap and baseURL.

                      10. +
                      +
                    4. + +
                    5. Return the result of sorting in descending + order normalized, with an entry a being less than an entry + b if a's key is code unit less + than b's key.

                    6. +
                    + +

                    In the above two algorithms, sorting keys and scopes in descending order has the + effect of putting "foo/bar/" before "foo/". This in + turn gives "foo/bar/" a higher priority than "foo/" + during module specifier resolution.

                    + +

                    To normalize a specifier key, given a string specifierKey and a URL baseURL:

                    + +
                      +
                    1. +

                      If specifierKey is the empty string, then:

                      + +
                        +
                      1. The user agent may report a warning to the console indicating that specifier keys may not be the empty string.

                      2. + +
                      3. Return null.

                      4. +
                      +
                    2. + +
                    3. Let url be the result of resolving a URL-like module specifier, given specifierKey and baseURL.

                    4. + +
                    5. If url is not null, then return the serialization of url.

                    6. + +
                    7. Return specifierKey.

                    8. +
                    + +

                    JavaScript specification host hooks

                    The JavaScript specification contains a number of implementation-defined abstract @@ -94807,8 +95736,6 @@ dictionary PromiseRejectionEventInit : EventInit

                  - -
                  Job-related host hooks

                  The JavaScript specification defines Jobs to be scheduled and run later by the host, as well as @@ -95057,6 +95984,8 @@ dictionary PromiseRejectionEventInit : EventInitscript execution context } }.

                + +
                Module-related host hooks
                @@ -95079,7 +96008,7 @@ dictionary PromiseRejectionEventInit : EventInitspecifier. This allows dynamic importing of module scripts at runtime, instead of statically using the import statement form. The specifier will be resolved relative to the active - script's base URL.

                + script
                .

                The returned promise will be rejected if an invalid specifier is given, or if a failure is encountered while fetching or PromiseRejectionEventInit : EventInit

                Returns specifier, resolved - relative to the active script's base - URL. That is, this returns the URL that would be imported by using import(specifier).

                + relative to the active script. That is, this returns the URL that would be imported + by using import(specifier).

                Throws a TypeError exception if an invalid specifier is given.

                @@ -95205,86 +96133,6 @@ import "https://example.com/foo/../module2.mjs";
                -

                To resolve a module specifier given a URL base URL and a - string specifier, perform the following steps. It will return either a - URL record or failure.

                - -
                  -
                1. Apply the URL parser to specifier. If the result is not failure, - return the result.

                2. - -
                3. -

                  If specifier does not start with the character U+002F SOLIDUS (/), the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the three-character sequence U+002E FULL STOP, U+002E FULL STOP, - U+002F SOLIDUS (../), return failure.

                  - -

                  This restriction is in place so that in the future we can allow custom module - loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any - such imports will fail, instead of being treated as relative URLs.

                  -
                4. - -
                5. Return the result of applying the URL parser to specifier with - base URL.

                6. -
                - -
                - -
                -

                The following are valid module specifiers according to the above - algorithm:

                - -
                  -
                • https://example.com/apples.mjs
                • - -
                • http:example.com\pears.js (becomes http://example.com/pears.js as step 1 parses with no base - URL)
                • - -
                • //example.com/bananas
                • - -
                • ./strawberries.mjs.cgi
                • - -
                • ../lychees
                • - -
                • /limes.jsx
                • - -
                • data:text/javascript,export default 'grapes';
                • - -
                • blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f
                • -
                - -

                The following are valid module specifiers according to the above algorithm, but will - invariably cause failures when they are fetched:

                - -
                  -
                • javascript:export default 'artichokes';
                • - -
                • data:text/plain,export default 'kale';
                • - -
                • about:legumes
                • - -
                • wss://example.com/celery
                • -
                - -

                The following are not valid module specifiers according to the above algorithm:

                - -
                  -
                • https://eggplant:b/c
                • - -
                • pumpkins.js
                • - -
                • .tomato
                • - -
                • ..zucchini.mjs
                • - -
                • .\yam.es
                • -
                -
                - -
                HostGetImportMetaProperties(moduleRecord)
                @@ -95311,10 +96159,7 @@ import "https://example.com/foo/../module2.mjs";
              5. Set specifier to ? ToString(specifier).

              6. Let url be the result of resolving - a module specifier given moduleScript's base URL and specifier.

              7. - -
              8. If url is failure, then throw a TypeError exception.

              9. + a module specifier given moduleScript and specifier.

              10. Return the serialization of url.

              11. @@ -95356,8 +96201,7 @@ import "https://example.com/foo/../module2.mjs";
            9. -
            10. Let base URL be settings object's API base - URL.

            11. +
            12. Let referencing script be null.

            13. Let fetch options be the default classic script fetch options.

            14. @@ -95366,31 +96210,27 @@ import "https://example.com/foo/../module2.mjs";

              If referencingScriptOrModule is not null, then:

                -
              1. Let referencing script be +

              2. Set referencing script to referencingScriptOrModule.[[HostDefined]].

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

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

              6. -
              7. Set fetch options to the descendant script fetch options for referencing script's fetch options.

              8. -
              9. Assert: Neither base URL nor fetch options is null, as - referencing script is a classic script or a JavaScript module - script.

              10. +
              11. Assert: fetch options is not null, as referencing script is a + classic script or a JavaScript module script.

              -

              As explained above for HostResolveImportedModule, in the common +

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

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

            16. + referencing script, settings object, and fetch options. Wait + until the algorithm asynchronously completes with result.

            17. Let promise be null. @@ -95416,14 +96256,13 @@ import "https://example.com/foo/../module2.mjs";

              1. Let settings object be the current settings object.

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

              4. +
              5. Let referencing script be null.

              6. If referencingScriptOrModule is not null, then:

                  -
                1. Let referencing script be +

                2. Set referencing script to referencingScriptOrModule.[[HostDefined]].

                3. Set settings object to referencing script's settings @@ -95455,13 +96294,14 @@ import "https://example.com/foo/../module2.mjs"; data-x="concept-settings-object-module-map">module map.

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

                5. -
                6. 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).

                7. +
                8. Assert: the previous step never throws an exception, 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).

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

                10. @@ -127391,6 +128231,9 @@ INSERT INTERFACES HERE
                  [COMPUTABLE]
                  (Non-normative) On computable numbers, with an application to the Entscheidungsproblem, A. Turing. In Proceedings of the London Mathematical Society, series 2, volume 42, pages 230-265. London Mathematical Society, 1937.
                  +
                  [CONSOLE]
                  +
                  Console, T. Stock, R. Kowalski, D. Farolino. WHATWG.
                  +
                  [COOKIES]
                  HTTP State Management Mechanism, A. Barth. IETF.
                  @@ -129212,6 +130055,13 @@ INSERT INTERFACES HERE href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">W3C Software and Document License.

                  +

                  Part of the revision history of the import maps feature can be found in the WICG/import-maps + repository, which is available under the W3C Software and + Document License.

                  +

                  Copyright © WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a Creative Commons Attribution 4.0 International License. To the extent portions of it are incorporated into source code, such diff --git a/styles.css b/styles.css index a152c0fcbde..268b85d8321 100644 --- a/styles.css +++ b/styles.css @@ -35,6 +35,8 @@ td.eg { border-width: thin; text-align: center; } #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; } #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; } +#table-import-map-scopes-example th[row="3"] { writing-mode: vertical-rl; } + #table-fa { border-top: solid; } #table-fa .example { margin: 2em 0 1.5em 0;