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

Call UnwrapNumberFormat in NumberFormat.prototype.formatToParts #274

Closed
ryzokuken opened this issue Sep 28, 2018 · 7 comments
Closed

Call UnwrapNumberFormat in NumberFormat.prototype.formatToParts #274

ryzokuken opened this issue Sep 28, 2018 · 7 comments

Comments

@ryzokuken
Copy link
Member

As we see in:

  1. get Intl.NumberFormat.prototype.format (https://tc39.github.io/ecma402/#sec-intl.numberformat.prototype.format)
  2. Intl.NumberFormat.prototype.resolvedOptions () (https://tc39.github.io/ecma402/#sec-intl.numberformat.prototype.resolvedoptions)

Intl.NumberFormat.prototype.formatToParts should also call UnwrapNumberFormat as the two mentioned above instead of:

3. If nf does not have an [[InitializedNumberFormat]] internal slot, throw a TypeError exception.

/cc @gsathya

ryzokuken added a commit to ryzokuken/ecma402 that referenced this issue Sep 28, 2018
…Parts

Call UnwrapNumberFormat in Intl.NumberFormat.prototype.formatToParts in
order to make it more consistent to format and resolvedOptions.

Fixes: tc39#274
@gsathya
Copy link
Member

gsathya commented Sep 28, 2018

I'm not sure if we want to add the Unwrapping here, as the unwrapping behavior was mostly a fix for the legacy mistake.

I'm interested in understanding why we decided not to add the Unwrapping behavior here in the first place?

cc @anba @littledan

@littledan
Copy link
Member

As @gsathya says, the unwrap logic is a legacy hack. I'd rather not add it to new things.

@ryzokuken
Copy link
Member Author

It is functionally the same either way, though. I guess consistency isn't a strong enough ground to change it?

@littledan
Copy link
Member

littledan commented Oct 9, 2018

Consistency is an important goal in general, but the design principle with this unwrapping stuff is to do as little of it as possible. See #57 for the agonizing history.

@ryzokuken
Copy link
Member Author

@littledan got it! Closing this.

@gsathya
Copy link
Member

gsathya commented Oct 10, 2018

@littledan I'm still confused why there is discrepancy in methods that do unwrapping. Why does NumberFormat.prototype.format do the unwrapping whilst NumberFormat.prototype.formatToParts does not?

@littledan
Copy link
Member

@gsathya Because legacy code uses format and expects it to be usable this way, whereas formatToParts was added later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants