From 1a9dcc9ec9ed472e3dad6ee5eb43028c62dbfe42 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 19 May 2026 14:20:04 +0100 Subject: [PATCH 1/5] Editorial: separate TextDecoderStream constructor to two algos One algo (the constructor) is used by JS, and the "set up" steps is to be used by other specs. See https://github.com/whatwg/fetch/pull/1862#pullrequestreview-3294323155 --- encoding.bs | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/encoding.bs b/encoding.bs index fe69752..c872b0e 100644 --- a/encoding.bs +++ b/encoding.bs @@ -1851,23 +1851,31 @@ constructor steps are:
  • If encoding is failure or replacement, then throw a {{RangeError}}. -

  • Set this's encoding to encoding. +

  • Let errorMode be fatal if options["{{TextDecoderOptions/fatal}}"] is true; otherwise replacement. -

  • If options["{{TextDecoderOptions/fatal}}"] is true, then set this's - error mode to "fatal". +

  • Let ignoreBOM be true if options["{{TextDecoderOptions/ignoreBOM}}"] is true; otherwise false. -

  • Set this's ignore BOM to - options["{{TextDecoderOptions/ignoreBOM}}"]. +

  • Call set up a text decoder stream with this, encoding, errorMode, and ignoreBOM. + + + -

  • Set this's decoder to a new instance of this's - encoding's decoder, and set this's - I/O queue to a new I/O queue. +

    +

    To set up a text decoder stream stream, given an optional [=/encoding=] encoding (default UTF-8), +an optional error mode errorMode (default replacement), and an optional boolean ignoreBOM (default false), run these steps: + +

      +
    1. Set stream's encoding to encoding. + +

    2. Set stream's error mode to errorMode. + +

    3. Set stream's ignore BOM to ignoreBOM.

    4. Let transformAlgorithm be an algorithm which takes a chunk argument - and runs the decode and enqueue a chunk algorithm with this and chunk. + and runs the decode and enqueue a chunk algorithm with stream and chunk.

    5. Let flushAlgorithm be an algorithm which takes no arguments and runs the - flush and enqueue algorithm with this. + flush and enqueue algorithm with stream.

    6. Let transformStream be a [=new=] {{TransformStream}}. @@ -1877,7 +1885,11 @@ constructor steps are: flushAlgorithm set to flushAlgorithm. -

    7. Set this's transform to transformStream. +

    8. Set stream's decoder to a new instance of encoding's decoder. + +

    9. Set stream's I/O queue to a new I/O queue. + +

    10. Set stream's transform to transformStream.

    From 4f45254ce2f40d462ffd4e38e0ee6ab38bcf4349 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 19 May 2026 16:23:48 +0100 Subject: [PATCH 2/5] Update encoding.bs Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com> --- encoding.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding.bs b/encoding.bs index c872b0e..36d8b3b 100644 --- a/encoding.bs +++ b/encoding.bs @@ -1855,7 +1855,7 @@ constructor steps are:
  • Let ignoreBOM be true if options["{{TextDecoderOptions/ignoreBOM}}"] is true; otherwise false. -

  • Call set up a text decoder stream with this, encoding, errorMode, and ignoreBOM. +

  • Set up a text decoder stream with this, encoding, errorMode, and ignoreBOM. From 91132bdf2219d092ce85551eef82f60f2cf0a8d1 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 20 May 2026 09:56:38 +0100 Subject: [PATCH 3/5] buncha nits --- encoding.bs | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/encoding.bs b/encoding.bs index 36d8b3b..b959a1b 100644 --- a/encoding.bs +++ b/encoding.bs @@ -1851,31 +1851,40 @@ constructor steps are:

  • If encoding is failure or replacement, then throw a {{RangeError}}. -

  • Let errorMode be fatal if options["{{TextDecoderOptions/fatal}}"] is true; otherwise replacement. - -

  • Let ignoreBOM be true if options["{{TextDecoderOptions/ignoreBOM}}"] is true; otherwise false. - -

  • Set up a text decoder stream with this, encoding, errorMode, and ignoreBOM. +

  • Let errorMode be "fatal" if + options["{{TextDecoderOptions/fatal}}"] is true; otherwise "replacement". +

  • Set up a text decoder stream with this, encoding, + errorMode, and options["{{TextDecoderOptions/ignoreBOM}}"].

    -

    To set up a text decoder stream stream, given an optional [=/encoding=] encoding (default UTF-8), -an optional error mode errorMode (default replacement), and an optional boolean ignoreBOM (default false), run these steps: - +

    To set up a text decoder stream stream, given a +{{TextDecoderStream}} stream, an optional [=/encoding=] encoding (default UTF-8), +an optional error mode errorMode (default "replacement"), and +an optional boolean ignoreBOM (default false), run these steps:

      +
    1. Assert: encoding is not replacement. +

    2. Set stream's encoding to encoding.

    3. Set stream's error mode to errorMode.

    4. Set stream's ignore BOM to ignoreBOM. +

    5. Set stream's decoder to a new instance of + encoding's decoder. + +

    6. Set stream's I/O queue to a new I/O + queue. +

    7. Let transformAlgorithm be an algorithm which takes a chunk argument - and runs the decode and enqueue a chunk algorithm with stream and chunk. + and runs the decode and enqueue a chunk algorithm with stream and + chunk. -

    8. Let flushAlgorithm be an algorithm which takes no arguments and runs the - flush and enqueue algorithm with stream. +

    9. Let flushAlgorithm be an algorithm which takes no arguments and runs the flush + and enqueue algorithm with stream.

    10. Let transformStream be a [=new=] {{TransformStream}}. @@ -1885,11 +1894,8 @@ an optional error mode errorMode (default replacem flushAlgorithm set to flushAlgorithm. -

    11. Set stream's decoder to a new instance of encoding's decoder. - -

    12. Set stream's I/O queue to a new I/O queue. - -

    13. Set stream's transform to transformStream. +

    14. Set stream's transform to + transformStream.

    From 49ecab8d5fa6acb408c56d7fb77a36c22f870ffe Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 20 May 2026 14:25:47 +0100 Subject: [PATCH 4/5] Update encoding.bs Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com> --- encoding.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding.bs b/encoding.bs index b959a1b..d02dae8 100644 --- a/encoding.bs +++ b/encoding.bs @@ -1865,7 +1865,7 @@ constructor steps are: an optional error mode errorMode (default "replacement"), and an optional boolean ignoreBOM (default false), run these steps:
      -
    1. Assert: encoding is not replacement. +

    2. Assert: encoding is not replacement.

    3. Set stream's encoding to encoding. From 833be29b94742049dff28867600800c8f1fd1420 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 20 May 2026 19:09:28 +0100 Subject: [PATCH 5/5] nitty --- encoding.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/encoding.bs b/encoding.bs index d02dae8..684c72d 100644 --- a/encoding.bs +++ b/encoding.bs @@ -1860,10 +1860,11 @@ constructor steps are:

      -

      To set up a text decoder stream stream, given a -{{TextDecoderStream}} stream, an optional [=/encoding=] encoding (default UTF-8), -an optional error mode errorMode (default "replacement"), and -an optional boolean ignoreBOM (default false), run these steps: +

      To set up a text decoder stream given a {{TextDecoderStream}} object +stream, an optional [=/encoding=] encoding (default UTF-8), an optional +error mode errorMode (default "replacement"), and an optional +boolean ignoreBOM (default false), run these steps: +

      1. Assert: encoding is not replacement.