Skip to content

Editorial: separate TextDecoderStream constructor to two algos#364

Open
noamr wants to merge 3 commits into
mainfrom
noamr/tds-ctor-steps
Open

Editorial: separate TextDecoderStream constructor to two algos#364
noamr wants to merge 3 commits into
mainfrom
noamr/tds-ctor-steps

Conversation

@noamr
Copy link
Copy Markdown

@noamr noamr commented May 19, 2026

One algo (the constructor) is used by JS, and the "set up" steps is to be used by other specs.

See whatwg/fetch#1862 (review)

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

One algo (the constructor) is used by JS, and the "set up" steps is to be used by other specs.

See whatwg/fetch#1862 (review)
@noamr noamr changed the title Editorial: separate TextDecoderStream constructor to two algos Editorial: separate TextDecoderStream constructor to two algos May 19, 2026
Comment thread encoding.bs Outdated
Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com>
@noamr noamr requested a review from annevk May 19, 2026 15:32
Copy link
Copy Markdown
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I have a bunch of nits.

Comment thread encoding.bs Outdated
<li><p>If <var>encoding</var> is failure or <a>replacement</a>, then <a>throw</a> a {{RangeError}}.

<li><p>Set <a>this</a>'s <a for=TextDecoderCommon>encoding</a> to <var>encoding</var>.
<li><p>Let <var>errorMode</var> be <code>fatal</code> if <var>options</var>["{{TextDecoderOptions/fatal}}"] is true; otherwise <code>replacement</code>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatal and replacement here need quotes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread encoding.bs Outdated
Comment thread encoding.bs Outdated
Comment thread encoding.bs Outdated
<a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a>, and set <a>this</a>'s
<a for=TextDecoderCommon>I/O queue</a> to a new <a for=/>I/O queue</a>.
<div algorithm>
<p>To <dfn export>set up a text decoder stream</dfn> <var>stream</var>, given an optional [=/encoding=] <var>encoding</var> (default <a>UTF-8</a>),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also type stream while we're here. Maybe rephrased as:

To set up a text decoder stream, given a TYPE stream, optional encoding encoding, ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread encoding.bs
<p>To <dfn export>set up a text decoder stream</dfn> <var>stream</var>, given an optional [=/encoding=] <var>encoding</var> (default <a>UTF-8</a>),
an optional <a for=/>error mode</a> <var>errorMode</var> (default <code>replacement</code>), and an optional boolean <var>ignoreBOM</var> (default false), run these steps:

<ol>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assert that encoding is not replacement.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread encoding.bs Outdated
<li><p>Set <a>this</a>'s <a for=GenericTransformStream>transform</a> to <var>transformStream</var>.
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>decoder</a> to a new instance of <var>encoding</var>'s <a for=/>decoder</a>.

<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>I/O queue</a> to a new <a for=/>I/O queue</a>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to move these two steps further down? Making them separate steps makes sense, but it would be nicer for the diff if they are in the same place still.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants