From 7fa72e21cb5bff9da3749b155b5835060647995f Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Thu, 20 Nov 2025 14:58:34 +0900 Subject: [PATCH 1/5] Add text imports Adds support for the `{ type: 'text' }` import attribute, which enables importing text content as a JavaScript string. --- source | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/source b/source index ca1389014e0..3ba163fc407 100644 --- a/source +++ b/source @@ -3189,6 +3189,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The HostGetCodeForEval abstract operation
  • +

    User agents that support JavaScript must also implement the Import Text proposal. + The following term is defined there, and used in this specification: JSIMPORTTEXT

    + + +

    User agents that support JavaScript must also implement ECMAScript Internationalization API. JSINTL

    @@ -116056,7 +116063,8 @@ document.querySelector("button").addEventListener("click", bound); script">JavaScript module scripts;

  • a Synthetic Module Record, for CSS module - scripts and JSON module scripts;

  • + scripts, JSON module scripts, and + text module scripts;

  • a WebAssembly Module Record, for WebAssembly module scripts; or

  • @@ -116166,6 +116174,15 @@ document.querySelector("button").addEventListener("click", bound); --> +
  • +
    +

    A module script is a text module script if its record is a Synthetic Module Record, and it + was created via the create a text module + script algorithm. Text module scripts represent a text document.

    +
    +
  • +
  • A module script is a WebAssembly module script if @@ -116175,11 +116192,11 @@ document.querySelector("button").addEventListener("click", bound);

  • -

    As CSS style sheets and JSON documents do not import dependent modules, and do not +

    As CSS style sheets, JSON documents, and text do not import dependent modules, and do not throw exceptions on evaluation, the fetch options and base URL of CSS module scripts and JSON module - scripts and are always null.

    + module script">CSS module scripts, JSON module + scripts, and text module scripts are always null.

    The active script is determined by the following algorithm:

    @@ -117115,6 +117132,10 @@ document.querySelector("button").addEventListener("click", bound);
  • Let sourceText be the result of UTF-8 decoding bodyBytes.

  • +
  • If moduleType is "text", then set + moduleScript to the result of creating a text module script given + sourceText and settingsObject.

  • +
  • If mimeType is a JavaScript MIME type and moduleType is "javascript-or-wasm", then set moduleScript to the result of creating a JavaScript module script given sourceText, @@ -117442,6 +117463,38 @@ document.querySelector("button").addEventListener("click", bound);

  • +
    +

    To create a text module script, given a + string text and an environment settings object settings:

    + +
      +
    1. Let script be a new module script that this algorithm will + subsequently initialize.

    2. + +
    3. Set script's settings + object to settings.

    4. + +
    5. Set script's base URL and + fetch options to null.

    6. + +
    7. Set script's parse error and + error to rethrow to null.

    8. + +
    9. +

      Let result be CreateTextModule(text).

      + +

      If this throws an exception, catch it, and set script's parse error to that exception, and return + script.

      +
    10. + +
    11. Set script's record to + result.

    12. + +
    13. Return script.

    14. +
    +
    +

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

    @@ -117480,7 +117533,8 @@ document.querySelector("button").addEventListener("click", bound);
    1. If moduleType is not "javascript-or-wasm", "css", or "json", then return false.

    2. + data-x="">css", "json", or "text", then + return false.

    3. If moduleType is "css" and the CSSStyleSheet interface is not exposed in @@ -117503,6 +117557,9 @@ document.querySelector("button").addEventListener("click", bound);

    4. If moduleType is "css", then return "style".
    5. +
    6. If moduleType is "text", then return "text".
    7. +
    8. Return defaultDestination.
    @@ -155474,6 +155531,9 @@ INSERT INTERFACES HERE
    [JSDYNAMICCODEBRANDCHECKS]
    Dynamic code brand checks. Ecma International.
    +
    [JSIMPORTTEXT]
    +
    Import Text. Ecma International.
    +
    [JSINTL]
    ECMAScript Internationalization API Specification. Ecma International.
    From 2b4eeaf662ec1f1b6b187f029ae088a08e5c7066 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Wed, 17 Dec 2025 17:37:44 +0200 Subject: [PATCH 2/5] Fix CreateTextModule definition + ignore mimetype when preloading text modules --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 3ba163fc407..8c20bc9dc77 100644 --- a/source +++ b/source @@ -3193,7 +3193,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute The following term is defined there, and used in this specification: JSIMPORTTEXT

    User agents that support JavaScript must also implement ECMAScript @@ -28940,7 +28940,7 @@ document.body.appendChild(wbr);

    1. If type is an empty string, then return true.

    2. -
    3. If destination is "fetch", then return true.

    4. +
    5. If destination is "fetch" or "text", then return true.

    6. Let mimeTypeRecord be the result of parsing type.

    7. From 78c73d120a03870d7bd25826d1b0cc3392151cbc Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Thu, 12 Mar 2026 19:22:25 +0200 Subject: [PATCH 3/5] Include "text" as a module preload destination --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 180990663c8..33512e9cbfc 100644 --- a/source +++ b/source @@ -28603,7 +28603,7 @@ document.body.appendChild(wbr);

      A user agent must not delay the load event for this link type.

      A module preload destination is "json", "style", or a style", "text", or a script-like destination.

      @@ -29231,7 +29231,7 @@ document.body.appendChild(wbr);
      1. If type is an empty string, then return true.

      2. -
      3. If destination is "fetch" or "text", then return true.

      4. +
      5. If destination is "fetch", then return true.

      6. Let mimeTypeRecord be the result of parsing type.

      7. From 9503facb2f97538dd9b9abe80d2d4760972a4465 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 20 Mar 2026 19:08:27 +0200 Subject: [PATCH 4/5] Remove error handling from around CreateTextModule(text) --- source | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/source b/source index 33512e9cbfc..946c4e46ec5 100644 --- a/source +++ b/source @@ -118162,13 +118162,7 @@ document.querySelector("button").addEventListener("click", bound);
      8. Set script's parse error and error to rethrow to null.

      9. -
      10. -

        Let result be CreateTextModule(text).

        - -

        If this throws an exception, catch it, and set script's parse error to that exception, and return - script.

        -
      11. +
      12. Let result be CreateTextModule(text).

      13. Set script's record to result.

      14. From 7182a192e97f9e22573f16044bfda746623a4dc8 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 31 Mar 2026 22:19:07 +0300 Subject: [PATCH 5/5] Say that text module scripts represent textual data encoded as UTF-8 --- source | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source b/source index 0afcda0aafb..cd0d47cc723 100644 --- a/source +++ b/source @@ -117165,7 +117165,7 @@ document.querySelector("button").addEventListener("click", bound);

        A module script is a text module script if its record is a Synthetic Module Record, and it was created via the create a text module - script algorithm. Text module scripts represent a text document.

        + script algorithm. Text module scripts represent textual data encoded as UTF-8.

      @@ -157559,6 +157559,7 @@ INSERT INTERFACES HERE Eduardo Vela, Edward Welbourne, Edward Z. Yang, + Eemeli Aro, Ehsan Akhgari, Ehsan Karamad, Eira Monstad,