Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
General spec fixes
Browse files Browse the repository at this point in the history
- Pass options to ApplyOptionsToTag
- Move ToString into constructor to ensure ToString(tag) appears before ToObject(options)
- Add definition for opt record
- Add missing underscores, fix typos, etc.
  • Loading branch information
anba committed Feb 6, 2018
1 parent 6c10aaa commit 637d9c9
Showing 1 changed file with 46 additions and 37 deletions.
83 changes: 46 additions & 37 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,36 @@ <h1>The Intl.Locale Constructor</h1>


<emu-clause id="sec-apply-options-to-tag" aoid=ApplyOptionsToTag>
<h1>ApplyOptionsToTag( tag, options )</h1>
<h1>ApplyOptionsToTag( _tag_, _options_ )</h1>
<p>
The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>.
</p>

<emu-alg>
1. Set _tag_ to ? ToString(_tag_).
1. Assert: Type(_tag_) is String.
1. If IsStructurallyValidLanguageTag(_tag_) is *false*, throw a *RangeError* exception.
1. If _tag_ matches the `langtag` production,
1. If _tag_ matches the `langtag` production, then
1. Let _language_ be ? Get(_options_, `"language"`).
1. If _language_ is not *undefined*,
1. If _language_ is not *undefined*, then
1. Set _language_ to ? ToString(_language_).
1. If _language_ does not match the `language` production, throw a *RangeError* exception.
1. Set _tag_ to _tag_ with the substring corresponding to the `language` production replaced by the string _language_.
1. Let _script_ be ? Get(_options_, `"script"`).
1. If _script_ is not *undefined*,
1. If _script_ is not *undefined*, then
1. Set _script_ to ? ToString(_script_).
1. If _script_ does not match the `script` production, throw a *RangeError* exception.
1. If _tag_ does not contain a `script` production,
1. If _tag_ does not contain a `script` production, then
1. Set _tag_ to the concatenation of the `language` production of _tag_, `"-"`, _script_, and the rest of _tag_.
1. Else,
1. Set _tag_ to _tag_ with the substring corresponding to the `region` production replaced by the string _language_.
1. Set _tag_ to _tag_ with the substring corresponding to the `script` production replaced by the string _script_.
1. Let _region_ be ? Get(_options_, `"region"`).
1. If _region_ is not *undefined*,
1. If _region_ is not *undefined*, then
1. Set _region_ to ? ToString(_region_).
1. If _region_ does not match the `region` production, throw a *RangeError* exception.
1. If _tag_ does not contain a `region` production,
1. Set _tag_ to the concatenation of the `language` production of _tag_, the substring corresponding to the `"-" script` production if present, `"-"`, _script_, and the rest of _tag_.
1. If _tag_ does not contain a `region` production, then
1. Set _tag_ to the concatenation of the `language` production of _tag_, the substring corresponding to the `"-" script` production if present, `"-"`, _region_, and the rest of _tag_.
1. Else,
1. Set _tag_ to _tag_ with the substring corresponding to the `region` production replaced by the string _language_.
1. Set _tag_ to _tag_ with the substring corresponding to the `region` production replaced by the string _region_.
1. Return CanonicalizeLanguageTag(_tag_).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -143,7 +143,7 @@ <h1>UnicodeExtensionValue ( _extension_, _key_ )</h1>
</emu-clause>

<emu-clause id="sec-unused-extensions" aoid="UnusedExtensions">
<h1>UnusedExtensions ( r )</h1>
<h1>UnusedExtensions ( _r_ )</h1>
<emu-alg>
1. Let _extension_ be _r_.[[extension]].
1. For _key_ in %Locale%.[[RelevantExtensionKeys]],
Expand All @@ -158,7 +158,7 @@ <h1>UnusedExtensions ( r )</h1>
</emu-clause>

<emu-clause id="sec-Intl.Locale">
<h1>Intl.Locale( tag[, options] )</h1>
<h1>Intl.Locale( _tag_ [, _options_] )</h1>

<p>
When the *Intl.Locale* function is called with an argument _tag_ and an optional argument _options_, the following steps are taken:
Expand All @@ -167,12 +167,14 @@ <h1>Intl.Locale( tag[, options] )</h1>
<emu-alg>
1. If NewTarget is *undefined*, throw a *TypeError* exception.
1. Let _locale_ be ? OrdinaryCreateFromConstructor(NewTarget, *%LocalePrototype%*, &laquo; [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[HourCycle]], [[CaseFirst]], [[Numeric]], [[NumberingSystem]], [[OtherExtensions]] &raquo;).
1. Set _tag_ to ApplyOptionsToTag(_tag_).
1. Let _requestedLocales_ be ? CreateArrayFromList(&laquo; _tag_ &raquo;).
1. Let _tag_ be ? ToString(_tag_).
1. If _options_ is *undefined*, then
1. Let _options_ be ObjectCreate(*null*).
1. Let _options_ be ! ObjectCreate(*null*).
1. Else
1. Let _options_ be ? ToObject(_options_).
1. Set _tag_ to ? ApplyOptionsToTag(_tag_, _options_).
1. Let _requestedLocales_ be ? CreateArrayFromList(&laquo; _tag_ &raquo;).
1. Let _opt_ be a new Record.
1. Set _opt_.[[localeMatcher]] to `"best fit"`.
1. Let _calendar_ be ? Get(_options_, `"calendar"`).
1. If _calendar_ is not *undefined*, set _calendar_ to ? ToString(_calendar_).
Expand All @@ -185,7 +187,7 @@ <h1>Intl.Locale( tag[, options] )</h1>
1. Let _kf_ be ? GetOption(_options_, `"caseFirst"`, `"string"`, &laquo; `"upper"`, `"lower"`, `"false"` &raquo;, *undefined*).
1. Set _opt_.[[kf]] to _kf_.
1. Let _kn_ be ? GetOption(_options_, `"numeric"`, `"boolean"`, *undefined*, *undefined*).
1. If _kn_ is not *undefined*, set _kn_ to ? ToString(_kn_).
1. If _kn_ is not *undefined*, set _kn_ to ! ToString(_kn_).
1. Set _opt_.[[kn]] to _kn_.
1. Let _numberingSystem_ be ? Get(_options_, `"numberingSystem"`).
1. If _numberingSystem_ is not *undefined*, set _numberingSystem_ to ? ToString(_numeringSystem_).
Expand Down Expand Up @@ -268,10 +270,7 @@ <h1>Internal slots</h1>
<h1>Properties of the Intl.Locale Prototype Object</h1>

<p>
The Intl.Locale prototype object is itself an Intl.Locale instance as specified in <emu-xref href="#sec-properties-of-intl-locale-instances"></emu-xref>, whose internal slots are set as if it had been constructed by the expression Construct(*%Locale%*).
</p>
<p>
In the following descriptions of functions that are properties or [[Get]] attributes of properties of *%LocalePrototype%*, the phrase "this Locale object" refers to the object that is the this value for the invocation of the function; a *TypeError* exception is thrown if the this value is not an object or an object.
The Intl.Locale prototype object is itself an ordinary object. %LocalePrototype% is not an Intl.Locale instance and does not have an [[InitializedLocale]] internal slot or any of the other internal slots of Intl.Locale instance objects.
</p>

<emu-clause id="sec-Intl.Locale.prototype.constructor">
Expand All @@ -295,14 +294,14 @@ <h1>Intl.Locale.prototype[ @@toStringTag ]</h1>
</emu-clause>

<emu-clause id="sec-locale-to-string" aoid=LocaleToString>
<h1>LocaleToString ( loc )</h1>
<h1>LocaleToString ( _loc_ )</h1>

<emu-alg>
1. Assert: _loc_ has an [[InitializedLocale]] internal slot.
1. Let _locale_ be _loc_.[[Locale]].
1. Let _extension_ be an empty String.
1. For each row in <emu-xref href="#table-locale-options"></emu-xref>, except the header row, in table order, do:
1. Let _name_ be the name given in the Option column of the row.
1. Let _key_ be the extension key given in the Extension key column of the row.
1. Let _slot_ be the Internal Slot column of the row.
1. Let _value_ be _locale_.[[&lt;_slot_&gt;]].
1. If _value_ is not *undefined*,
Expand All @@ -323,7 +322,8 @@ <h1>Intl.Locale.prototype.toString ()</h1>

<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) is not Object, or _loc_ does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return LocaleToString(_loc_).
</emu-alg>
</emu-clause>
Expand All @@ -333,7 +333,8 @@ <h1>get Intl.Locale.prototype.calendar</h1>
<p>`Intl.Locale.prototype.calendar` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[Calendar]].
</emu-alg>
</emu-clause>
Expand All @@ -343,7 +344,8 @@ <h1>get Intl.Locale.prototype.collation</h1>
<p>`Intl.Locale.prototype.collation` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[Collation]].
</emu-alg>
</emu-clause>
Expand All @@ -353,7 +355,8 @@ <h1>get Intl.Locale.prototype.hourCycle</h1>
<p>`Intl.Locale.prototype.hourCycle` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[HourCycle]].
</emu-alg>
</emu-clause>
Expand All @@ -364,7 +367,8 @@ <h1>get Intl.Locale.prototype.caseFirst</h1>
<p>`Intl.Locale.prototype.caseFirst` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[CaseFirst]].
</emu-alg>
</emu-clause>
Expand All @@ -375,7 +379,8 @@ <h1>get Intl.Locale.prototype.numeric</h1>
<p>`Intl.Locale.prototype.numeric` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[Numeric]].
</emu-alg>
</emu-clause>
Expand All @@ -385,7 +390,8 @@ <h1>get Intl.Locale.prototype.numberingSystem</h1>
<p>`Intl.Locale.prototype.numberingSystem` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _loc_.[[NumberingSystem]].
</emu-alg>
</emu-clause>
Expand All @@ -395,7 +401,8 @@ <h1>get Intl.Locale.prototype.language</h1>
<p>`Intl.Locale.prototype.language` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. If _locale_ does not match the `langtag` production, return *undefined*.
1. Return the substring of _locale_ corresponding to the `language` production.
Expand All @@ -407,10 +414,11 @@ <h1>get Intl.Locale.prototype.script</h1>
<p>`Intl.Locale.prototype.script` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. If _locale_ does not match the `langtag` production, return *undefined*.
1. If _locale_ contains a no repetitions of the `["-" script]` sequence, return *undefined*.
1. If _locale_ does not contain the `["-" script]` sequence, return *undefined*.
1. Return the substring of _locale_ corresponding to the `script` production.
</emu-alg>
</emu-clause>
Expand All @@ -420,10 +428,11 @@ <h1>get Intl.Locale.prototype.region</h1>
<p>`Intl.Locale.prototype.region` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) does not have an [[InitializedLocale]] internal slot, throw a *TypeError* exception.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. If _locale_ does not match the `langtag` production, return *undefined*.
1. If _locale_ contains a no repetitions of the `["-" region]` sequence, return *undefined*.
1. If _locale_ does not contain the `["-" region]` sequence, return *undefined*.
1. Return the substring of _locale_ corresponding to the `region` production.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -456,9 +465,9 @@ <h1>CanonicalizeLocaleList ( _locales_ )</h1>
1. If _kPresent_ is *true*, then
1. Let _kValue_ be ? Get(_O_, _Pk_).
1. If Type(_kValue_) is not String or Object, throw a *TypeError* exception.
1. <ins>If Type(_kValue_) is Object and _kValue_ has an [[InitializedLocale]] internal slot,</ins>
1. <ins>If Type(_kValue_) is Object and _kValue_ has an [[InitializedLocale]] internal slot, then</ins>
1. <ins>Let _tag_ be LocaleToString(_kValue_).</ins>
1. <ins>Otherwise,</ins>
1. <ins>Else,</ins>
1. Let _tag_ be ? ToString(_kValue_).
1. If IsStructurallyValidLanguageTag(_tag_) is *false*, throw a *RangeError* exception.
1. Let _canonicalizedTag_ be CanonicalizeLanguageTag(_tag_).
Expand Down

0 comments on commit 637d9c9

Please sign in to comment.