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
Add regionCode attribute #690
Changes from 1 commit
25bf943
66a1237
8f030ca
8199e35
58e0d95
2febe42
cdd18dc
5f23fac
d1aca5d
1695891
d2b59ee
699d329
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2185,7 +2185,8 @@ <h2> | |
<li>If <var>details</var> was not passed, return | ||
<var>address</var>. | ||
</li> | ||
<li>If <var>details</var>["<a>country</a>"] is present: | ||
<li>If <var>details</var>["<a>country</a>"] is present and not the | ||
empty string: | ||
<ol> | ||
<li>Set <var>country</var> the result of <a>strip leading and | ||
trailing ASCII whitespace</a> from | ||
|
@@ -2203,12 +2204,16 @@ <h2> | |
<li>If <var>details</var>["<a>regionCode</a>"] is present and not | ||
the empty string: | ||
<ol> | ||
<li>Let <var>regionCode</var> be the result of <a>strip leading | ||
<li>Let <var>regionPart</var> be the result of <a>strip leading | ||
and trailing ASCII whitespace</a> from | ||
<var>details</var>["<a>regionCode</a>"] and then | ||
<a data-cite="!INFRA#ascii-uppercase">ASCII uppercasing</a> | ||
the result. | ||
</li> | ||
<li>Let <var>regionCode</var> be the concatenation of | ||
<var>address</var>.<a>[[\country]]</a>, a single U+002D (-) <a> | ||
code point</a>, <var>regionPart</var>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing "and" after last comma. |
||
</li> | ||
<li> | ||
<p> | ||
If <var>regionCode</var> is not a valid <a>country | ||
|
@@ -2246,27 +2251,31 @@ <h2> | |
</div> | ||
</li> | ||
<li>Set <var>address</var>.<a>[[\regionCode]]</a> to | ||
<var>regionCode</var>. | ||
<var>regionPart</var>. | ||
</li> | ||
<li>Let <var>region</var> be the corresponding <a>country | ||
subdivision name</a> for <var>regionCode</var>. Where | ||
[[!ISO3166-2]] defines multiple <a>country subdivision | ||
names</a> for a <var>regionCode</var>, it is RECOMMENDED the | ||
user agent select one by matching on: | ||
<li>If <var>details</var>["<a>region</a>"] is not present: | ||
<ol> | ||
<li>The <a data-cite="!HTML#language">language</a> of | ||
<a data-cite="HTML#the-body-element-2">the body | ||
element</a>. | ||
</li> | ||
<li>The user's preferred languages. | ||
<li>Let <var>region</var> be the corresponding <a>country | ||
subdivision name</a> for <var>regionCode</var>. Where | ||
[[!ISO3166-2]] defines multiple <a>country subdivision | ||
names</a> for a <var>regionCode</var>, it is RECOMMENDED | ||
the user agent select one by matching on: | ||
<ol> | ||
<li>The <a data-cite="!HTML#language">language</a> of | ||
<a data-cite="HTML#the-body-element-2">the body | ||
element</a>. | ||
</li> | ||
<li>The user's preferred languages. | ||
</li> | ||
<li>Any other criteria the user agent deems suitable. | ||
</li> | ||
</ol> | ||
</li> | ||
<li>Any other criteria the user agent deems suitable. | ||
<li> | ||
<var>details</var>["<a>region</a>"] to <var>region</var>. | ||
</li> | ||
</ol> | ||
</li> | ||
<li>Set <var>address</var>.<a>[[\region]]</a> to | ||
<var>region</var>. | ||
</li> | ||
</ol> | ||
</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we consider deriving region from regionCode, so the caller only has to pass one? I'm thinking ahead to the constructor; do we want to prevent I guess for the cases where there is no corresponding regionCode, we'd still want to pass region. But if regionCode is not the empty string, deriving region from it might be good... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree. It's definitely doable. ISO3166-2 provides lookup tables, for example:
Where column 2 (defined thing) is "...the country subdivision names in the administrative language of the country concerned, where relevant with diacritic signs..." (as Unicode). Note that "a country’s administrative language is a written language used by the administration of the country at the national level". So, the result won't be in English a lot of the time - but that's fine, IMO. This is not for display purposes. So, something like: The steps to derive a region from a country subdivision code element are as follows. The string takes a DOMString subCode as input and returns a DOMString.
Sound good? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds great! Probably we should get implementer buy-ins though; maybe as a separate PR? Because it'd mean having to ship that table with the browser... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree... ☝️@rsolomakhin, @mnoorenberghe, something to start thinking about. Would appreciate your input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are already using libaddressinput (and I believe Chromium does too) so it would be great if we could also use that here instead of having two versions of similar data. Does ISO3166-2 only have one name per region? What about when there are multiple official languages? Consider CA-QC: is it "Quebec" or "Québec" in ISO3166-2. libaddressinput provides both but without a clear way to know which one would match ISO3166-2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure how this all fits together but won't this affect what gets returned in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably perform some kind of lookup, based on the document language. But then it gets into preference order for when it doesn't match the user's language (and there is no "en"). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems crazy town, but:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use libaddressinput in Chromium and @sebsg is helping us to add the ISO codes to that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The |
||
<li>If <var>details</var>["<a>languageCode</a>"] is present: | ||
|
@@ -2391,10 +2400,10 @@ <h2> | |
<dfn>regionCode</dfn> attribute | ||
</h2> | ||
<p data-link-for=""> | ||
Represents the <a>region</a> of the address as an [[!ISO3166-2]] | ||
<a>country subdivision code element</a>. When getting, returns the | ||
value of the <a>PaymentAddress</a>'s <a>[[\regionCode]]</a> | ||
internal slot. | ||
Represents the <a>region</a> of the address, but as the code | ||
element of an [[!ISO3166-2]] country subdivision name (e.g., "CA" | ||
for California, USA). When getting, returns the value of the | ||
<a>PaymentAddress</a>'s <a>[[\regionCode]]</a> internal slot. | ||
</p> | ||
</section> | ||
<section> | ||
|
@@ -2525,10 +2534,12 @@ <h2> | |
<dfn>[[\regionCode]]</dfn> | ||
</td> | ||
<td> | ||
A <a>region</a> represented as a [[!ISO3166-2]] <a>country | ||
subdivision code element</a> stored in its canonical uppercase | ||
form, or the empty string. For example, "<code>PT-11</code>" | ||
represents the Lisbon district of Portugal. | ||
Either the empty string, or one to three code points that | ||
represent a <a>region</a> as the code element of an | ||
[[!ISO3166-2]] country subdivision name (i.e., the characters | ||
after the hyphen in an ISO3166-2 <a>country subdivision code | ||
element</a>, such as "CA" for the state of California in the | ||
USA, or "11" for the Lisbon district of Portugal). | ||
</td> | ||
</tr> | ||
<tr> | ||
|
@@ -2647,8 +2658,12 @@ <h2> | |
<dfn>regionCode</dfn> member | ||
</dt> | ||
<dd> | ||
An <a>region</a>, represented as a <a>country subdivision code | ||
element</a>. | ||
Either the empty string, or one to three code points that represent | ||
a <a>region</a> as the code element of an [[!ISO3166-2]] country | ||
subdivision name (i.e., the characters after the hyphen in an | ||
ISO3166-2 <a>country subdivision code element</a>, such as "CA" for | ||
the state of California in the USA, or "11" for the Lisbon district | ||
of Portugal) | ||
</dd> | ||
<dt> | ||
<dfn>city</dfn> member | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable naming here is super-confusing. To a web developer, a regionCode is something like "CA", right? But in this algorithm,
details["regionCode"]
is "CA",regionPart
is "CA", andregionCode
is "USA-CA".I think the variable on this line should be regionCode, and on line 2213 should be putativeCountrySubdivisionCodeElement or similar.