Skip to content

Editorial Changes to Align with 262 #120

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

Merged
merged 3 commits into from
Feb 2, 2017
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ env:
language: node_js

node_js:
- "5"
- "6"

sudo: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"license": "SEE LICENSE IN https://tc39.github.io/ecma402/#sec-copyright-and-software-license",
"homepage": "https://tc39.github.io/ecma402/",
"dependencies": {
"ecmarkup": "^3.3.2"
"ecmarkup": "^3.4.0"
},
"devDependencies": {
"@alrra/travis-scripts": "^2.0.0"
Expand Down
92 changes: 47 additions & 45 deletions spec/collator.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,31 @@ <h1>InitializeCollator ( _collator_, _locales_, _options_ )</h1>
</p>

<p>
Several steps in the algorithm use values from the following table, which associates Unicode locale extension keys, property names, types, and allowable values:
Several steps in the algorithm use values from the following table, which associates Unicode locale extension keys, internal slots, property names, types, and allowable values:
</p>

<emu-table id="table-collator-options">
<emu-caption>Collator options settable through both extension keys and options properties</emu-caption>
<emu-caption>Collator options settable through extension keys, internal slots and options properties</emu-caption>
<table class="real-table">
<thead>
<tr>
<th>Key</th>
<th>Internal Slot</th>
<th>Property</th>
<th>Type</th>
<th>Values</th>
</tr>
</thead>
<tr>
<td>kn</td>
<td>[[Numeric]]</td>
<td>numeric</td>
<td>"boolean"</td>
<td></td>
</tr>
<tr>
<td>kf</td>
<td>[[CaseFirst]]</td>
<td>caseFirst</td>
Copy link
Member

Choose a reason for hiding this comment

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

Editorial suggestion: now that this is just a property name and not also an internal slot, maybe it should be written as "caseFirst" rather than caseFirst.

Copy link
Contributor Author

@caridy caridy Feb 10, 2017

Choose a reason for hiding this comment

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

@littledan this is now fixed: e4eaa72

<td>"string"</td>
<td>"upper", "lower", "false"</td>
Expand All @@ -48,19 +51,19 @@ <h1>InitializeCollator ( _collator_, _locales_, _options_ )</h1>
</p>

<emu-alg>
1. If _collator_.[[initializedIntlObject]] is *true*, throw a *TypeError* exception.
1. Set _collator_.[[initializedIntlObject]] to *true*.
1. If _collator_.[[InitializedIntlObject]] is *true*, throw a *TypeError* exception.
1. Set _collator_.[[InitializedIntlObject]] to *true*.
1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
1. If _options_ is *undefined*, then
1. Let _options_ be ObjectCreate(%ObjectPrototype%).
1. Else,
1. Let _options_ be ? ToObject(_options_).
1. Let _u_ be ? GetOption(_options_, *"usage"*, *"string"*, &laquo; *"sort"*, *"search"* &raquo;, *"sort"*).
1. Set _collator_.[[usage]] to _u_.
1. Set _collator_.[[Usage]] to _u_.
1. If _u_ is *"sort"*, then
1. Let _localeData_ be %Collator%.[[sortLocaleData]].
1. Let _localeData_ be %Collator%.[[SortLocaleData]].
1. Else,
1. Let _localeData_ be %Collator%.[[searchLocaleData]].
1. Let _localeData_ be %Collator%.[[SearchLocaleData]].
1. Let _opt_ be a new Record.
1. Let _matcher_ be ? GetOption(_options_, *"localeMatcher"*, *"string"*, &laquo; *"lookup"*, *"best fit"* &raquo;, *"best fit"*).
1. Set _opt_.[[localeMatcher]] to _matcher_.
Expand All @@ -73,23 +76,22 @@ <h1>InitializeCollator ( _collator_, _locales_, _options_ )</h1>
1. If the string given in the Type column of the row is *"boolean"* and value is not *undefined*, then
1. Let _value_ be ! ToString(_value_).
1. Set _opt_.[[&lt;_key_&gt;]] to _value_.
1. Let _relevantExtensionKeys_ be %Collator%.[[relevantExtensionKeys]].
1. Let _r_ be ResolveLocale(%Collator%.[[availableLocales]], _requestedLocales_, _opt_, _relevantExtensionKeys_, _localeData_).
1. Set _collator_.[[locale]] to _r_.[[locale]].
1. Let _relevantExtensionKeys_ be %Collator%.[[RelevantExtensionKeys]].
1. Let _r_ be ResolveLocale(%Collator%.[[AvailableLocales]], _requestedLocales_, _opt_, _relevantExtensionKeys_, _localeData_).
1. Set _collator_.[[Locale]] to _r_.[[locale]].
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the field on _r_ also be Locale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the problem with ResolveLocale is that it creates an arbitrary record with fields, and we use that to match the keys provided via options. We could attempt to do the same, but those are not internal slots, just fields in a record. I think we can keep them like that. I know it is confusing though.

1. Let _k_ be 0.
1. Let _rExtensionKeys_ be CreateArrayFromList(_relevantExtensionKeys_).
1. Let _len_ be ! ToLength(! Get(_rExtensionKeys_, *"length"*)).
1. Repeat while _k_ < _len_:
1. Let _key_ be ! Get(_rExtensionKeys_, ! ToString(_k_)).
1. If _key_ is *"co"*, then
1. Let _property_ be *"collation"*.
1. Let _value_ be _r_.[[co]].
1. If _value_ is *null*, let _value_ be *"default"*.
1. Set _collator_.[[Collation]] to _value_.
1. Else use the row of <emu-xref href="#table-collator-options"></emu-xref> that contains _key_ in the Key column:
1. Let _property_ be the name given in the Property column of the row.
1. Let _value_ be _r_.[[&lt;_key_&gt;]].
Copy link
Contributor

Choose a reason for hiding this comment

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

So happy to get rid of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It took some time, and some big refactors, but we are getting there :). Still using it in a couple of places where a record with fields is created and matching some options keys, but it is at least narrowed down to one or two abstracts at the moment.

1. If the name given in the Type column of the row is *"boolean"*, let _value_ be the result of comparing value with *"true"*.
1. Set _collator_.[[&lt;_property_&gt;]] to _value_.
1. Set _collator_'s internal slot whose name is the Internal Slot column of the row to _value_.
1. Increase _k_ by 1.
1. Let _s_ be ? GetOption(_options_, *"sensitivity"*, *"string"*, &laquo; *"base"*, *"accent"*, *"case"*, *"variant"* &raquo;, *undefined*).
1. If _s_ is *undefined*, then
Expand All @@ -99,11 +101,11 @@ <h1>InitializeCollator ( _collator_, _locales_, _options_ )</h1>
1. Let _dataLocale_ be _r_.[[dataLocale]].
1. Let _dataLocaleData_ be Get(_localeData_, _dataLocale_).
1. Let _s_ be Get(_dataLocaleData_, *"sensitivity"*).
1. Set _collator_.[[sensitivity]] to _s_.
1. Set _collator_.[[Sensitivity]] to _s_.
1. Let _ip_ be ? GetOption(_options_, *"ignorePunctuation"*, *"boolean"*, *undefined*, *false*).
1. Set _collator_.[[ignorePunctuation]] to _ip_.
1. Set _collator_.[[boundCompare]] to *undefined*.
1. Set _collator_.[[initializedCollator]] to *true*.
1. Set _collator_.[[IgnorePunctuation]] to _ip_.
1. Set _collator_.[[BoundCompare]] to *undefined*.
1. Set _collator_.[[InitializedCollator]] to *true*.
1. Return _collator_.
</emu-alg>

Expand All @@ -118,11 +120,11 @@ <h1>Intl.Collator ( [ _locales_ [ , _options_ ] ] )</h1>

<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. Let _internalSlotsList_ be &laquo; [[initializedIntlObject]], [[initializedCollator]], [[locale]], [[usage]], [[sensitivity]], [[ignorePunctuation]], [[collation]], [[boundCompare]] &raquo;.
1. If %Collator%.[[relevantExtensionKeys]] contains `"kn"`, then
1. Append [[numeric]] as the last element of _internalSlotsList_.
1. If %Collator%.[[relevantExtensionKeys]] contains `"kf"`, then
1. Append [[caseFirst]] as the last element of _internalSlotsList_.
1. Let _internalSlotsList_ be &laquo; [[InitializedIntlObject]], [[InitializedCollator]], [[Locale]], [[Usage]], [[Sensitivity]], [[IgnorePunctuation]], [[Collation]], [[BoundCompare]] &raquo;.
1. If %Collator%.[[RelevantExtensionKeys]] contains `"kn"`, then
1. Append [[Numeric]] as the last element of _internalSlotsList_.
1. If %Collator%.[[RelevantExtensionKeys]] contains `"kf"`, then
1. Append [[CaseFirst]] as the last element of _internalSlotsList_.
1. Let _collator_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%CollatorPrototype%"`, _internalSlotsList_).
1. Return ? InitializeCollator(_collator_, _locales_, _options_).
</emu-alg>
Expand Down Expand Up @@ -157,7 +159,7 @@ <h1>Intl.Collator.supportedLocalesOf ( _locales_ [ , _options_ ] )</h1>

<emu-alg>
1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
1. Return ? SupportedLocales(%Collator%.[[availableLocales]], _requestedLocales_, _options_).
1. Return ? SupportedLocales(%Collator%.[[AvailableLocales]], _requestedLocales_, _options_).
</emu-alg>

<p>
Expand All @@ -169,21 +171,21 @@ <h1>Intl.Collator.supportedLocalesOf ( _locales_ [ , _options_ ] )</h1>
<h1>Internal Slots</h1>

<p>
The value of the [[availableLocales]] internal slot is implementation defined within the constraints described in 9.1. The value of the [[relevantExtensionKeys]] internal slot is a List that must include the element *"co"*, may include any or all of the elements *"kn"* and *"kf"*, and must not include any other elements.
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in 9.1. The value of the [[RelevantExtensionKeys]] internal slot is a List that must include the element *"co"*, may include any or all of the elements *"kn"* and *"kf"*, and must not include any other elements.
</p>

<emu-note>
Unicode Technical Standard 35 describes ten locale extension keys that are relevant to collation: "co" for collator usage and specializations, "ka" for alternate handling, "kb" for backward second level weight, "kc" for case level, "kn" for numeric, "kh" for hiragana quaternary, "kk" for normalization, "kf" for case first, "kr" for reordering, "ks" for collation strength, and "vt" for variable top. Collator, however, requires that the usage is specified through the usage property of the options object, alternate handling through the ignorePunctuation property of the options object, and case level and the strength through the sensitivity property of the options object. The "co" key in the language tag is supported only for collator specializations, and the keys "kb", "kh", "kk", "kr", and "vt" are not allowed in this version of the Internationalization API. Support for the remaining keys is implementation dependent.
</emu-note>

<p>
The values of the [[sortLocaleData]] and [[searchLocaleData]] internal slots are implementation defined within the constraints described in 9.1 and the following additional constraints:
The values of the [[SortLocaleData]] and [[SearchLocaleData]] internal slots are implementation defined within the constraints described in 9.1 and the following additional constraints:
</p>

<ul>
<li>The first element of [[sortLocaleData]][locale].co and [[searchLocaleData]][locale].co must be *null* for all locale values.</li>
<li>The values *"standard"* and *"search"* must not be used as elements in any [[sortLocaleData]][locale].co and [[searchLocaleData]][locale].co array.</li>
<li>[[searchLocaleData]][locale] must have a sensitivity property with a String value equal to *"base"*, *"accent"*, *"case"*, or *"variant"* for all locale values.</li>
<li>The first element of [[SortLocaleData]][locale].co and [[SearchLocaleData]][locale].co must be *null* for all locale values.</li>
<li>The values *"standard"* and *"search"* must not be used as elements in any [[SortLocaleData]][locale].co and [[SearchLocaleData]][locale].co array.</li>
<li>[[SearchLocaleData]][locale] must have a sensitivity property with a String value equal to *"base"*, *"accent"*, *"case"*, or *"variant"* for all locale values.</li>
</ul>

</emu-clause>
Expand All @@ -197,7 +199,7 @@ <h1>Properties of the Intl.Collator Prototype Object</h1>
</p>

<p>
In the following descriptions of functions that are properties or [[Get]] attributes of properties of %CollatorPrototype%, the phrase "this Collator 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 that does not have an [[initializedCollator]] internal slot with value *true*.
In the following descriptions of functions that are properties or [[Get]] attributes of properties of %CollatorPrototype%, the phrase "this Collator 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 that does not have an [[InitializedCollator]] internal slot with value *true*.
</p>

<emu-clause id="sec-intl.collator.prototype.constructor">
Expand Down Expand Up @@ -233,13 +235,13 @@ <h1>get Intl.Collator.prototype.compare</h1>
<emu-alg>
1. Let _collator_ be *this* value.
1. If Type(_collator_) is not Object, throw a *TypeError* exception.
1. If _collator_ does not have an [[initializedCollator]] internal slot, throw a *TypeError* exception.
1. If _collator_.[[boundCompare]] is *undefined*, then
1. If _collator_ does not have an [[InitializedCollator]] internal slot, throw a *TypeError* exception.
1. If _collator_.[[BoundCompare]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in <emu-xref href="#sec-collator-compare-functions"></emu-xref>.
1. Let _bc_ be BoundFunctionCreate(_F_, _collator_, &laquo; &raquo;).
1. Perform ! DefinePropertyOrThrow(_bc_, `"length"`, PropertyDescriptor {[[Value]]: 2, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true*}).
1. Set _collator_.[[boundCompare]] to _bc_.
1. Return _collator_.[[boundCompare]].
1. Set _collator_.[[BoundCompare]] to _bc_.
1. Return _collator_.[[BoundCompare]].
</emu-alg>

<emu-note>
Expand All @@ -260,7 +262,7 @@ <h1>Collator Compare Functions</h1>

<emu-alg>
1. Let _collator_ be the *this* value.
1. Assert: Type(_collator_) is Object and _collator_ .[[initializedCollator]] is *true*.
1. Assert: Type(_collator_) is Object and _collator_ .[[InitializedCollator]] is *true*.
1. If _x_ is not provided, let _x_ be *undefined*.
1. If _y_ is not provided, let _y_ be *undefined*.
1. Let _X_ be ? ToString(_x_).
Expand Down Expand Up @@ -320,7 +322,7 @@ <h1>Intl.Collator.prototype.resolvedOptions ()</h1>
This function provides access to the locale and collation options computed during initialization of the object.
</p>
<p>
The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this Collator object (see <emu-xref href="#sec-properties-of-intl-collator-instances"></emu-xref>): locale, usage, sensitivity, ignorePunctuation, collation, as well as those properties shown in <emu-xref href="#table-collator-options"></emu-xref> whose keys are included in the %Collator%[[relevantExtensionKeys]] internal slot of the standard built-in object that is the initial value of Intl.Collator.
The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this Collator object (see <emu-xref href="#sec-properties-of-intl-collator-instances"></emu-xref>): locale, usage, sensitivity, ignorePunctuation, collation, as well as those properties shown in <emu-xref href="#table-collator-options"></emu-xref> whose keys are included in the %Collator%.[[RelevantExtensionKeys]] internal slot of the standard built-in object that is the initial value of Intl.Collator.
</p>
</emu-clause>
</emu-clause>
Expand All @@ -333,32 +335,32 @@ <h1>Properties of Intl.Collator Instances</h1>
</p>

<p>
Intl.Collator instances and other objects that have been successfully initialized as a Collator have [[initializedIntlObject]] and [[initializedCollator]] internal slots whose values are *true*.
Intl.Collator instances and other objects that have been successfully initialized as a Collator have [[InitializedIntlObject]] and [[InitializedCollator]] internal slots whose values are *true*.
</p>

<p>
Objects that have been successfully initialized as a Collator also have several internal slots that are computed by the constructor:
</p>

<ul>
<li>[[locale]] is a String value with the language tag of the locale whose localization is used for collation.</li>
<li>[[usage]] is one of the String values *"sort"* or *"search"*, identifying the collator usage.</li>
<li>[[sensitivity]] is one of the String values *"base"*, *"accent"*, *"case"*, or *"variant"*, identifying the collator’s sensitivity.</li>
<li>[[ignorePunctuation]] is a Boolean value, specifying whether punctuation should be ignored in comparisons.</li>
<li>[[collation]] is a String value with the "type" given in Unicode Technical Standard 35 for the collation, except that the values *"standard"* and *"search"* are not allowed, while the value *"default"* is allowed.</li>
<li>[[Locale]] is a String value with the language tag of the locale whose localization is used for collation.</li>
<li>[[Usage]] is one of the String values *"sort"* or *"search"*, identifying the collator usage.</li>
<li>[[Sensitivity]] is one of the String values *"base"*, *"accent"*, *"case"*, or *"variant"*, identifying the collator’s sensitivity.</li>
<li>[[IgnorePunctuation]] is a Boolean value, specifying whether punctuation should be ignored in comparisons.</li>
<li>[[Collation]] is a String value with the "type" given in Unicode Technical Standard 35 for the collation, except that the values *"standard"* and *"search"* are not allowed, while the value *"default"* is allowed.</li>
</ul>

<p>
Objects that have been successfully initialized as a Collator also have the following internal slots if the key corresponding to the name of the internal slot in <emu-xref href="#table-collator-options"></emu-xref> is included in the [[relevantExtensionKeys]] internal slot of Intl.Collator:
Objects that have been successfully initialized as a Collator also have the following internal slots if the key corresponding to the name of the internal slot in <emu-xref href="#table-collator-options"></emu-xref> is included in the [[RelevantExtensionKeys]] internal slot of Intl.Collator:
</p>

<ul>
<li>[[numeric]] is a Boolean value, specifying whether numeric sorting is used.</li>
<li>[[caseFirst]] is a String value; allowed values are specified in <emu-xref href="#table-collator-options"></emu-xref>.</li>
<li>[[Numeric]] is a Boolean value, specifying whether numeric sorting is used.</li>
<li>[[CaseFirst]] is a String value; allowed values are specified in <emu-xref href="#table-collator-options"></emu-xref>.</li>
</ul>

<p>
Finally, objects that have been successfully initialized as a Collator have a [[boundCompare]] internal slot that caches the function returned by the compare accessor (<emu-xref href="#sec-intl.collator.prototype.compare"></emu-xref>).
Finally, objects that have been successfully initialized as a Collator have a [[BoundCompare]] internal slot that caches the function returned by the compare accessor (<emu-xref href="#sec-intl.collator.prototype.compare"></emu-xref>).
</p>

</emu-clause>
Expand Down
Loading