From 637d9c90b9bc5b5424cca728eeec6e8a4665f7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Tue, 6 Feb 2018 07:28:13 -0800 Subject: [PATCH] General spec fixes - 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. --- spec.html | 83 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/spec.html b/spec.html index b9c46f5..89787ba 100644 --- a/spec.html +++ b/spec.html @@ -60,36 +60,36 @@

The Intl.Locale Constructor

-

ApplyOptionsToTag( tag, options )

+

ApplyOptionsToTag( _tag_, _options_ )

The following algorithm refers to RFC 5646's Language-Tag grammar.

- 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_).
@@ -143,7 +143,7 @@

UnicodeExtensionValue ( _extension_, _key_ )

-

UnusedExtensions ( r )

+

UnusedExtensions ( _r_ )

1. Let _extension_ be _r_.[[extension]]. 1. For _key_ in %Locale%.[[RelevantExtensionKeys]], @@ -158,7 +158,7 @@

UnusedExtensions ( r )

-

Intl.Locale( tag[, options] )

+

Intl.Locale( _tag_ [, _options_] )

When the *Intl.Locale* function is called with an argument _tag_ and an optional argument _options_, the following steps are taken: @@ -167,12 +167,14 @@

Intl.Locale( tag[, options] )

1. If NewTarget is *undefined*, throw a *TypeError* exception. 1. Let _locale_ be ? OrdinaryCreateFromConstructor(NewTarget, *%LocalePrototype%*, « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[HourCycle]], [[CaseFirst]], [[Numeric]], [[NumberingSystem]], [[OtherExtensions]] »). - 1. Set _tag_ to ApplyOptionsToTag(_tag_). - 1. Let _requestedLocales_ be ? CreateArrayFromList(« _tag_ »). + 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(« _tag_ »). + 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_). @@ -185,7 +187,7 @@

Intl.Locale( tag[, options] )

1. Let _kf_ be ? GetOption(_options_, `"caseFirst"`, `"string"`, « `"upper"`, `"lower"`, `"false"` », *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_). @@ -268,10 +270,7 @@

Internal slots

Properties of the Intl.Locale Prototype Object

- The Intl.Locale prototype object is itself an Intl.Locale instance as specified in , whose internal slots are set as if it had been constructed by the expression Construct(*%Locale%*). -

-

- 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.

@@ -295,14 +294,14 @@

Intl.Locale.prototype[ @@toStringTag ]

-

LocaleToString ( loc )

+

LocaleToString ( _loc_ )

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 , 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_.[[<_slot_>]]. 1. If _value_ is not *undefined*, @@ -323,7 +322,8 @@

Intl.Locale.prototype.toString ()

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_).
@@ -333,7 +333,8 @@

get Intl.Locale.prototype.calendar

`Intl.Locale.prototype.calendar` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]].
@@ -343,7 +344,8 @@

get Intl.Locale.prototype.collation

`Intl.Locale.prototype.collation` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]]. @@ -353,7 +355,8 @@

get Intl.Locale.prototype.hourCycle

`Intl.Locale.prototype.hourCycle` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]]. @@ -364,7 +367,8 @@

get Intl.Locale.prototype.caseFirst

`Intl.Locale.prototype.caseFirst` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]]. @@ -375,7 +379,8 @@

get Intl.Locale.prototype.numeric

`Intl.Locale.prototype.numeric` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]]. @@ -385,7 +390,8 @@

get Intl.Locale.prototype.numberingSystem

`Intl.Locale.prototype.numberingSystem` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

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]]. @@ -395,7 +401,8 @@

get Intl.Locale.prototype.language

`Intl.Locale.prototype.language` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to RFC 5646's Language-Tag grammar. Its get accessor function performs the following steps:

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. @@ -407,10 +414,11 @@

get Intl.Locale.prototype.script

`Intl.Locale.prototype.script` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to RFC 5646's Language-Tag grammar. Its get accessor function performs the following steps:

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. @@ -420,10 +428,11 @@

get Intl.Locale.prototype.region

`Intl.Locale.prototype.region` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to RFC 5646's Language-Tag grammar. Its get accessor function performs the following steps:

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. @@ -456,9 +465,9 @@

CanonicalizeLocaleList ( _locales_ )

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. If Type(_kValue_) is Object and _kValue_ has an [[InitializedLocale]] internal slot, + 1. If Type(_kValue_) is Object and _kValue_ has an [[InitializedLocale]] internal slot, then 1. Let _tag_ be LocaleToString(_kValue_). - 1. Otherwise, + 1. Else, 1. Let _tag_ be ? ToString(_kValue_). 1. If IsStructurallyValidLanguageTag(_tag_) is *false*, throw a *RangeError* exception. 1. Let _canonicalizedTag_ be CanonicalizeLanguageTag(_tag_).