Skip to content

Commit a985b62

Browse files
authored
Editorial: separate TextDecoderStream constructor to two algorithms
One (the constructor) for use by JS and one (the set up steps) for use by other specifications. See whatwg/fetch#1862 (review).
1 parent d96155b commit a985b62

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

encoding.bs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,23 +1851,41 @@ constructor steps are:
18511851

18521852
<li><p>If <var>encoding</var> is failure or <a>replacement</a>, then <a>throw</a> a {{RangeError}}.
18531853

1854-
<li><p>Set <a>this</a>'s <a for=TextDecoderCommon>encoding</a> to <var>encoding</var>.
1854+
<li><p>Let <var>errorMode</var> be "<code>fatal</code>" if
1855+
<var>options</var>["{{TextDecoderOptions/fatal}}"] is true; otherwise "<code>replacement</code>".
18551856

1856-
<li><p>If <var>options</var>["{{TextDecoderOptions/fatal}}"] is true, then set <a>this</a>'s
1857-
<a for=TextDecoderCommon>error mode</a> to "<code>fatal</code>".
1857+
<li><p><a>Set up a text decoder stream</a> with <a>this</a>, <var>encoding</var>,
1858+
<var>errorMode</var>, and <var>options</var>["{{TextDecoderOptions/ignoreBOM}}"].
1859+
</ol>
1860+
</div>
18581861

1859-
<li><p>Set <a>this</a>'s <a for=TextDecoderCommon>ignore BOM</a> to
1860-
<var>options</var>["{{TextDecoderOptions/ignoreBOM}}"].
1862+
<div algorithm>
1863+
<p>To <dfn export>set up a text decoder stream</dfn> given a {{TextDecoderStream}} object
1864+
<var>stream</var>, an optional [=/encoding=] <var>encoding</var> (default <a>UTF-8</a>), an optional
1865+
<a for=/>error mode</a> <var>errorMode</var> (default "<code>replacement</code>"), and an optional
1866+
boolean <var>ignoreBOM</var> (default false), run these steps:
18611867

1862-
<li><p>Set <a>this</a>'s <a for=TextDecoderCommon>decoder</a> to a new instance of <a>this</a>'s
1863-
<a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a>, and set <a>this</a>'s
1864-
<a for=TextDecoderCommon>I/O queue</a> to a new <a for=/>I/O queue</a>.
1868+
<ol>
1869+
<li><p><a>Assert</a>: <var>encoding</var> is not <a>replacement</a>.
1870+
1871+
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>encoding</a> to <var>encoding</var>.
1872+
1873+
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>error mode</a> to <var>errorMode</var>.
1874+
1875+
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>ignore BOM</a> to <var>ignoreBOM</var>.
1876+
1877+
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>decoder</a> to a new instance of
1878+
<var>encoding</var>'s <a for=/>decoder</a>.
1879+
1880+
<li><p>Set <var>stream</var>'s <a for=TextDecoderCommon>I/O queue</a> to a new <a for=/>I/O
1881+
queue</a>.
18651882

18661883
<li><p>Let <var>transformAlgorithm</var> be an algorithm which takes a <var>chunk</var> argument
1867-
and runs the <a>decode and enqueue a chunk</a> algorithm with <a>this</a> and <var>chunk</var>.
1884+
and runs the <a>decode and enqueue a chunk</a> algorithm with <var>stream</var> and
1885+
<var>chunk</var>.
18681886

1869-
<li><p>Let <var>flushAlgorithm</var> be an algorithm which takes no arguments and runs the
1870-
<a>flush and enqueue</a> algorithm with <a>this</a>.
1887+
<li><p>Let <var>flushAlgorithm</var> be an algorithm which takes no arguments and runs the <a>flush
1888+
and enqueue</a> algorithm with <var>stream</var>.
18711889

18721890
<li><p>Let <var>transformStream</var> be a [=new=] {{TransformStream}}.
18731891

@@ -1877,7 +1895,8 @@ constructor steps are:
18771895
<a for="TransformStream/set up"><var ignore>flushAlgorithm</var></a> set to
18781896
<var>flushAlgorithm</var>.
18791897

1880-
<li><p>Set <a>this</a>'s <a for=GenericTransformStream>transform</a> to <var>transformStream</var>.
1898+
<li><p>Set <var>stream</var>'s <a for=GenericTransformStream>transform</a> to
1899+
<var>transformStream</var>.
18811900
</ol>
18821901
</div>
18831902

0 commit comments

Comments
 (0)