Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update editorial according #81 #85

Merged
merged 3 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions numberformat/diff.emu
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
1. <ins class="block">Let _roundingIncrement_ be ? GetNumberOption(_options_, *"roundingIncrement"*, 1, 5000, 1).</ins>
1. <ins class="block">If _roundingIncrement_ is not in « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 », throw a *RangeError* exception.</ins>
1. <ins class="block">If _roundingIncrement_ is not 1 and _numberFormat_.[[RoundingType]] is not ~fractionDigits~, throw a *RangeError* exception.</ins>
1. <ins class="block">If _roundingIncrement_ is not 1 and _numberFormat_.[[MaximumFractionDigits]] is not equal to _numberFormat_.[[MinimumFractionDigits]], throw a *RangeError* exception.</ins>
1. <ins class="block">Set _numberFormat_.[[RoundingIncrement]] to _roundingIncrement_.</ins>
1. <ins class="block">Let _trailingZeroDisplay_ be ? GetOption(_options_, *"trailingZeroDisplay"*, *"string"*, &laquo; *"auto"*, *"stripIfInteger"* &raquo;, *"auto"*).</ins>
1. <ins class="block">Set _numberFormat_.[[TrailingZeroDisplay]] to _trailingZeroDisplay_.</ins>
Expand Down
1 change: 1 addition & 0 deletions numberformat/proposed.emu
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
1. Let _roundingIncrement_ be ? GetNumberOption(_options_, *"roundingIncrement"*, 1, 5000, 1).
1. If _roundingIncrement_ is not in « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 », throw a *RangeError* exception.
1. If _roundingIncrement_ is not 1 and _numberFormat_.[[RoundingType]] is not ~fractionDigits~, throw a *RangeError* exception.
1. If _roundingIncrement_ is not 1 and _numberFormat_.[[MaximumFractionDigits]] is not equal to _numberFormat_.[[MinimumFractionDigits]], throw a *RangeError* exception.
1. Set _numberFormat_.[[RoundingIncrement]] to _roundingIncrement_.
Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @sffc this would be enough to solve the #81 ? Or we should further validate if values MaxFDigits/ MinFDigits before throw

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update diff.emu to keep them in sync

1. Let _trailingZeroDisplay_ be ? GetOption(_options_, *"trailingZeroDisplay"*, *"string"*, &laquo; *"auto"*, *"stripIfInteger"* &raquo;, *"auto"*).
1. Set _numberFormat_.[[TrailingZeroDisplay]] to _trailingZeroDisplay_.
Expand Down
47 changes: 37 additions & 10 deletions out/numberformat/diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -976,16 +976,43 @@
emu-val {
font-weight: bold;
}
emu-alg ol, emu-alg ol ol ol ol {
list-style-type: decimal;
}

emu-alg ol ol, emu-alg ol ol ol ol ol {
list-style-type: lower-alpha;
}

emu-alg ol ol ol, ol ol ol ol ol ol {
list-style-type: lower-roman;
/* depth 1 */
emu-alg ol,
/* depth 4 */
emu-alg ol ol ol ol,
emu-alg ol.nested-thrice,
emu-alg ol.nested-twice ol,
emu-alg ol.nested-once ol ol {
list-style-type: decimal;
}

/* depth 2 */
emu-alg ol ol,
emu-alg ol.nested-once,
/* depth 5 */
emu-alg ol ol ol ol ol,
emu-alg ol.nested-four-times,
emu-alg ol.nested-thrice ol,
emu-alg ol.nested-twice ol ol,
emu-alg ol.nested-once ol ol ol {
list-style-type: lower-alpha;
}

/* depth 3 */
emu-alg ol ol ol,
emu-alg ol.nested-twice,
emu-alg ol.nested-once ol,
/* depth 6 */
emu-alg ol ol ol ol ol ol,
emu-alg ol.nested-lots,
emu-alg ol.nested-four-times ol,
emu-alg ol.nested-thrice ol ol,
emu-alg ol.nested-twice ol ol ol,
emu-alg ol.nested-once ol ol ol ol,
/* depth 7+ */
emu-alg ol.nested-lots ol {
list-style-type: lower-roman;
}

emu-eqn {
Expand Down Expand Up @@ -1841,7 +1868,7 @@ <h1><span class="secnum">1.1.2</span> InitializeNumberFormat ( <var>numberFormat
The following algorithm refers to the <code>type</code> nonterminal from <a href="https://www.unicode.org/reports/tr35/#Unicode_locale_identifier">UTS 35's Unicode Locale Identifier grammar</a>.
</p>

<emu-alg><ol><li>Let <var>requestedLocales</var> be ?&nbsp;CanonicalizeLocaleList(<var>locales</var>).</li><li>Set <var>options</var> to ?&nbsp;CoerceOptionsToObject(<var>options</var>).</li><li>Let <var>opt</var> be a new <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref>.</li><li>Let <var>matcher</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"localeMatcher"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"lookup"</emu-val>, <emu-val>"best fit"</emu-val> », <emu-val>"best fit"</emu-val>).</li><li>Set <var>opt</var>.[[localeMatcher]] to <var>matcher</var>.</li><li>Let <var>numberingSystem</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"numberingSystem"</emu-val>, <emu-val>"string"</emu-val>, <emu-val>undefined</emu-val>, <emu-val>undefined</emu-val>).</li><li>If <var>numberingSystem</var> is not <emu-val>undefined</emu-val>, then<ol><li>If <var>numberingSystem</var> does not match the Unicode Locale Identifier <code>type</code> nonterminal, throw a <emu-val>RangeError</emu-val> exception.</li></ol></li><li>Set <var>opt</var>.[[nu]] to <var>numberingSystem</var>.</li><li>Let <var>localeData</var> be <emu-xref href="#sec-intl-numberformat-constructor" id="_ref_25"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[LocaleData]].</li><li>Let <var>r</var> be ResolveLocale(<emu-xref href="#sec-intl-numberformat-constructor" id="_ref_26"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[AvailableLocales]], <var>requestedLocales</var>, <var>opt</var>, <emu-xref href="#sec-intl-numberformat-constructor" id="_ref_27"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[RelevantExtensionKeys]], <var>localeData</var>).</li><li>Set <var>numberFormat</var>.[[Locale]] to <var>r</var>.[[locale]].</li><li>Set <var>numberFormat</var>.[[DataLocale]] to <var>r</var>.[[dataLocale]].</li><li>Set <var>numberFormat</var>.[[NumberingSystem]] to <var>r</var>.[[nu]].</li><li>Perform ?&nbsp;<emu-xref aoid="SetNumberFormatUnitOptions" id="_ref_28"><a href="#sec-setnumberformatunitoptions">SetNumberFormatUnitOptions</a></emu-xref>(<var>numberFormat</var>, <var>options</var>).</li><li>Let <var>style</var> be <var>numberFormat</var>.[[Style]].</li><li>If <var>style</var> is <emu-val>"currency"</emu-val>, then<ol><li>Let <var>currency</var> be <var>numberFormat</var>.[[Currency]].</li><li>Let <var>cDigits</var> be <emu-xref aoid="CurrencyDigits" id="_ref_29"><a href="#sec-currencydigits">CurrencyDigits</a></emu-xref>(<var>currency</var>).</li><li>Let <var>mnfdDefault</var> be <var>cDigits</var>.</li><li>Let <var>mxfdDefault</var> be <var>cDigits</var>.</li></ol></li><li>Else,<ol><li>Let <var>mnfdDefault</var> be 0.</li><li>If <var>style</var> is <emu-val>"percent"</emu-val>, then<ol><li>Let <var>mxfdDefault</var> be 0.</li></ol></li><li>Else,<ol><li>Let <var>mxfdDefault</var> be 3.</li></ol></li></ol></li><li>Let <var>notation</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"notation"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"standard"</emu-val>, <emu-val>"scientific"</emu-val>, <emu-val>"engineering"</emu-val>, <emu-val>"compact"</emu-val> », <emu-val>"standard"</emu-val>).</li><li>Set <var>numberFormat</var>.[[Notation]] to <var>notation</var>.</li><li>Perform ?&nbsp;<emu-xref aoid="SetNumberFormatDigitOptions" id="_ref_30"><a href="#sec-setnfdigitoptions">SetNumberFormatDigitOptions</a></emu-xref>(<var>numberFormat</var>, <var>options</var>, <var>mnfdDefault</var>, <var>mxfdDefault</var>, <var>notation</var>).</li><li><ins class="block">Let <var>roundingIncrement</var> be ?&nbsp;GetNumberOption(<var>options</var>, <emu-val>"roundingIncrement"</emu-val>, 1, 5000, 1).</ins></li><li><ins class="block">If <var>roundingIncrement</var> is not in « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 », throw a <emu-val>RangeError</emu-val> exception.</ins></li><li><ins class="block">If <var>roundingIncrement</var> is not 1 and <var>numberFormat</var>.[[RoundingType]] is not <emu-const>fractionDigits</emu-const>, throw a <emu-val>RangeError</emu-val> exception.</ins></li><li><ins class="block">Set _numberFormat.[[RoundingIncrement]] to <var>roundingIncrement</var>.</ins></li><li><ins class="block">Let <var>trailingZeroDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"trailingZeroDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"stripIfInteger"</emu-val> », <emu-val>"auto"</emu-val>).</ins></li><li><ins class="block">Set <var>numberFormat</var>.[[TrailingZeroDisplay]] to <var>trailingZeroDisplay</var>.</ins></li><li>Let <var>compactDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"compactDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"short"</emu-val>, <emu-val>"long"</emu-val> », <emu-val>"short"</emu-val>).</li><li><ins class="block">Let <var>defaultUseGrouping</var> be <emu-val>"auto"</emu-val>.</ins></li><li>If <var>notation</var> is <emu-val>"compact"</emu-val>, then<ol><li>Set <var>numberFormat</var>.[[CompactDisplay]] to <var>compactDisplay</var>.</li><li><ins class="block">Set <var>defaultUseGrouping</var> to <emu-val>"min2"</emu-val>.</ins></li></ol></li><li>Let <var>useGrouping</var> be ? <emu-xref aoid="Get" id="_ref_31"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></emu-xref><ins>StringOrBoolean</ins>Option(<var>options</var>, <emu-val>"useGrouping"</emu-val>, <del><emu-val>"boolean"</emu-val>, <emu-val>undefined</emu-val>, <emu-val>true</emu-val></del> <ins>« <emu-val>"min2"</emu-val>, <emu-val>"auto"</emu-val>, <emu-val>"always"</emu-val> », <emu-val>"always"</emu-val>, <emu-val>false</emu-val>, <var>defaultUseGrouping</var></ins>).</li><li>Set <var>numberFormat</var>.[[UseGrouping]] to <var>useGrouping</var>.</li><li>Let <var>signDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"signDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"never"</emu-val>, <emu-val>"always"</emu-val>, <emu-val>"exceptZero"</emu-val><ins>, <emu-val>"negative"</emu-val></ins> », <emu-val>"auto"</emu-val>).</li><li>Set <var>numberFormat</var>.[[SignDisplay]] to <var>signDisplay</var>.</li><li><ins class="block">Let <var>roundingMode</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"roundingMode"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"ceil"</emu-val>, <emu-val>"floor"</emu-val>, <emu-val>"expand"</emu-val>, <emu-val>"trunc"</emu-val>, <emu-val>"halfCeil"</emu-val>, <emu-val>"halfFloor"</emu-val>, <emu-val>"halfExpand"</emu-val>, <emu-val>"halfTrunc"</emu-val>, <emu-val>"halfEven"</emu-val> », <emu-val>"halfExpand"</emu-val>).</ins></li><li><ins class="block">Set <var>numberFormat</var>.[[RoundingMode]] to <var>roundingMode</var>.</ins></li><li>Return <var>numberFormat</var>.</li></ol></emu-alg>
<emu-alg><ol><li>Let <var>requestedLocales</var> be ?&nbsp;CanonicalizeLocaleList(<var>locales</var>).</li><li>Set <var>options</var> to ?&nbsp;CoerceOptionsToObject(<var>options</var>).</li><li>Let <var>opt</var> be a new <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref>.</li><li>Let <var>matcher</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"localeMatcher"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"lookup"</emu-val>, <emu-val>"best fit"</emu-val> », <emu-val>"best fit"</emu-val>).</li><li>Set <var>opt</var>.[[localeMatcher]] to <var>matcher</var>.</li><li>Let <var>numberingSystem</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"numberingSystem"</emu-val>, <emu-val>"string"</emu-val>, <emu-val>undefined</emu-val>, <emu-val>undefined</emu-val>).</li><li>If <var>numberingSystem</var> is not <emu-val>undefined</emu-val>, then<ol><li>If <var>numberingSystem</var> does not match the Unicode Locale Identifier <code>type</code> nonterminal, throw a <emu-val>RangeError</emu-val> exception.</li></ol></li><li>Set <var>opt</var>.[[nu]] to <var>numberingSystem</var>.</li><li>Let <var>localeData</var> be <emu-xref href="#sec-intl-numberformat-constructor" id="_ref_25"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[LocaleData]].</li><li>Let <var>r</var> be ResolveLocale(<emu-xref href="#sec-intl-numberformat-constructor" id="_ref_26"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[AvailableLocales]], <var>requestedLocales</var>, <var>opt</var>, <emu-xref href="#sec-intl-numberformat-constructor" id="_ref_27"><a href="#sec-intl-numberformat-constructor">%NumberFormat%</a></emu-xref>.[[RelevantExtensionKeys]], <var>localeData</var>).</li><li>Set <var>numberFormat</var>.[[Locale]] to <var>r</var>.[[locale]].</li><li>Set <var>numberFormat</var>.[[DataLocale]] to <var>r</var>.[[dataLocale]].</li><li>Set <var>numberFormat</var>.[[NumberingSystem]] to <var>r</var>.[[nu]].</li><li>Perform ?&nbsp;<emu-xref aoid="SetNumberFormatUnitOptions" id="_ref_28"><a href="#sec-setnumberformatunitoptions">SetNumberFormatUnitOptions</a></emu-xref>(<var>numberFormat</var>, <var>options</var>).</li><li>Let <var>style</var> be <var>numberFormat</var>.[[Style]].</li><li>If <var>style</var> is <emu-val>"currency"</emu-val>, then<ol><li>Let <var>currency</var> be <var>numberFormat</var>.[[Currency]].</li><li>Let <var>cDigits</var> be <emu-xref aoid="CurrencyDigits" id="_ref_29"><a href="#sec-currencydigits">CurrencyDigits</a></emu-xref>(<var>currency</var>).</li><li>Let <var>mnfdDefault</var> be <var>cDigits</var>.</li><li>Let <var>mxfdDefault</var> be <var>cDigits</var>.</li></ol></li><li>Else,<ol><li>Let <var>mnfdDefault</var> be 0.</li><li>If <var>style</var> is <emu-val>"percent"</emu-val>, then<ol><li>Let <var>mxfdDefault</var> be 0.</li></ol></li><li>Else,<ol><li>Let <var>mxfdDefault</var> be 3.</li></ol></li></ol></li><li>Let <var>notation</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"notation"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"standard"</emu-val>, <emu-val>"scientific"</emu-val>, <emu-val>"engineering"</emu-val>, <emu-val>"compact"</emu-val> », <emu-val>"standard"</emu-val>).</li><li>Set <var>numberFormat</var>.[[Notation]] to <var>notation</var>.</li><li>Perform ?&nbsp;<emu-xref aoid="SetNumberFormatDigitOptions" id="_ref_30"><a href="#sec-setnfdigitoptions">SetNumberFormatDigitOptions</a></emu-xref>(<var>numberFormat</var>, <var>options</var>, <var>mnfdDefault</var>, <var>mxfdDefault</var>, <var>notation</var>).</li><li><ins class="block">Let <var>roundingIncrement</var> be ?&nbsp;GetNumberOption(<var>options</var>, <emu-val>"roundingIncrement"</emu-val>, 1, 5000, 1).</ins></li><li><ins class="block">If <var>roundingIncrement</var> is not in « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 », throw a <emu-val>RangeError</emu-val> exception.</ins></li><li><ins class="block">If <var>roundingIncrement</var> is not 1 and <var>numberFormat</var>.[[RoundingType]] is not <emu-const>fractionDigits</emu-const>, throw a <emu-val>RangeError</emu-val> exception.</ins></li><li><ins class="block">If <var>roundingIncrement</var> is not 1 and <var>numberFormat</var>.[[MaximumFractionDigits]] is not equal to <var>numberFormat</var>.[[MinimumFractionDigits]], throw a <emu-val>RangeError</emu-val> exception.</ins></li><li><ins class="block">Set <var>numberFormat</var>.[[RoundingIncrement]] to <var>roundingIncrement</var>.</ins></li><li><ins class="block">Let <var>trailingZeroDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"trailingZeroDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"stripIfInteger"</emu-val> », <emu-val>"auto"</emu-val>).</ins></li><li><ins class="block">Set <var>numberFormat</var>.[[TrailingZeroDisplay]] to <var>trailingZeroDisplay</var>.</ins></li><li>Let <var>compactDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"compactDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"short"</emu-val>, <emu-val>"long"</emu-val> », <emu-val>"short"</emu-val>).</li><li><ins class="block">Let <var>defaultUseGrouping</var> be <emu-val>"auto"</emu-val>.</ins></li><li>If <var>notation</var> is <emu-val>"compact"</emu-val>, then<ol><li>Set <var>numberFormat</var>.[[CompactDisplay]] to <var>compactDisplay</var>.</li><li><ins class="block">Set <var>defaultUseGrouping</var> to <emu-val>"min2"</emu-val>.</ins></li></ol></li><li>Let <var>useGrouping</var> be ? <emu-xref aoid="Get" id="_ref_31"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></emu-xref><ins>StringOrBoolean</ins>Option(<var>options</var>, <emu-val>"useGrouping"</emu-val>, <del><emu-val>"boolean"</emu-val>, <emu-val>undefined</emu-val>, <emu-val>true</emu-val></del> <ins>« <emu-val>"min2"</emu-val>, <emu-val>"auto"</emu-val>, <emu-val>"always"</emu-val> », <emu-val>"always"</emu-val>, <emu-val>false</emu-val>, <var>defaultUseGrouping</var></ins>).</li><li>Set <var>numberFormat</var>.[[UseGrouping]] to <var>useGrouping</var>.</li><li>Let <var>signDisplay</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"signDisplay"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"never"</emu-val>, <emu-val>"always"</emu-val>, <emu-val>"exceptZero"</emu-val><ins>, <emu-val>"negative"</emu-val></ins> », <emu-val>"auto"</emu-val>).</li><li>Set <var>numberFormat</var>.[[SignDisplay]] to <var>signDisplay</var>.</li><li><ins class="block">Let <var>roundingMode</var> be ?&nbsp;GetOption(<var>options</var>, <emu-val>"roundingMode"</emu-val>, <emu-val>"string"</emu-val>, « <emu-val>"ceil"</emu-val>, <emu-val>"floor"</emu-val>, <emu-val>"expand"</emu-val>, <emu-val>"trunc"</emu-val>, <emu-val>"halfCeil"</emu-val>, <emu-val>"halfFloor"</emu-val>, <emu-val>"halfExpand"</emu-val>, <emu-val>"halfTrunc"</emu-val>, <emu-val>"halfEven"</emu-val> », <emu-val>"halfExpand"</emu-val>).</ins></li><li><ins class="block">Set <var>numberFormat</var>.[[RoundingMode]] to <var>roundingMode</var>.</ins></li><li>Return <var>numberFormat</var>.</li></ol></emu-alg>
</emu-clause>

<emu-clause id="sec-currencydigits" aoid="CurrencyDigits">
Expand Down
Loading