Closed Bug 1289340 Opened 8 years ago Closed 8 years ago

Expose Intl.DateTimeFormat.prototype.formatToParts

Categories

(Core :: JavaScript: Internationalization API, enhancement)

enhancement
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla51
Tracking Status
firefox51 --- verified

People

(Reporter: sebo, Assigned: zbraniecki)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

      No description provided.
Depends on: 1260858
No longer depends on: 1216150
Assignee: nobody → gandalf
V8 added DateTimeFormat.prototype.formatToParts - https://bugs.chromium.org/p/v8/issues/detail?id=5244 and seems like the API is pretty much verified and frozen, with three implementations (Intl.js, Gecko and Chrome) passing test262 tests suite for it.

We should be ready to expose it to content.
Comment on attachment 8790744 [details]
Bug 1289340 - Expose Intl.DateTimeFormat.prototype.formatToParts.

https://reviewboard.mozilla.org/r/78426/#review77040

The XXX bug you mention claims I'm module owner (which I am not), but IRC word is the staging for this is right, so I think we're good.

::: js/src/builtin/Intl.cpp:1819
(Diff revision 2)
> -        RootedValue ftp(cx);
> +    RootedValue ftp(cx);
> -        HandlePropertyName name = cx->names().formatToParts;
> +    HandlePropertyName name = cx->names().formatToParts;
> -        if (!GlobalObject::getSelfHostedFunction(cx, cx->global(),
> +    if (!GlobalObject::getSelfHostedFunction(cx, cx->global(),
> -                    cx->names().DateTimeFormatFormatToParts,
> +                cx->names().DateTimeFormatFormatToParts,
> -                    name,
> +                name,
> -                    0, &ftp))
> +                0, &ftp))

It'd be better adding this to the JSFunctionSpec for DateTimeFormat instead of preserving this needed-for-conditionality code.  But this gets the job done for now, and I can go back and fix it to be the idiomatic way at some later time.
Attachment #8790744 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/3f47a92541c8
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Works for me as expected.

Updated the compatibility info:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts#Browser_compatibility

And the release notes:
https://developer.mozilla.org/en-US/Firefox/Releases/51?document_saved=true#JavaScript

Zibi, can you please verify that the docs are correct?

Sebastian
Status: RESOLVED → VERIFIED
Flags: needinfo?(gandalf)
:sebo - sorry for late response. In the Specifications box the comments indicate that it's "Not yet part of the draft specification. ".

At this point it is merged into the ECMA 402 spec.

Also, V8/Chrome has it exposed behind --harmony flag - https://bugs.chromium.org/p/v8/issues/detail?id=5244

And since we're at it - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales is already exposed in Chrome as well :)
Flags: needinfo?(gandalf)
Flags: needinfo?(sebastianzartner)
Added the compatibility information and removed the outdated spec. comment. Zibi, can you please verify them again?

Sebastian
Flags: needinfo?(sebastianzartner) → needinfo?(gandalf)
LGTM!
Flags: needinfo?(gandalf)
Perfect! Thanks for the prompt feedback!

Sebastian
You need to log in before you can comment on or make changes to this bug.