You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Polyfill: Make Intl.DateTimeFormat replacement more conformant
Previously we did not care very much about fidelity for the replacement
Intl.DateTimeFormat object, since the point of this code is to run the
Temporal tests. Occasionally people want to run the Intl.DateTimeFormat
tests and are surprised that it doesn't work.
Things we have to do to get the Intl.DateTimeFormat tests to pass:
- Change ASCIILowercase not to use a RegExp, so that it doesn't clobber
legacy RegExp variables like RegExp.$_. (Probably this means that for a
100% conformant polyfill, you can't use any RegExp anywhere. I'm not
bothering with that.)
- Change DateTimeFormat to be a class, DateTimeFormatImpl. Methods defined
in a class body don't have a 'prototype' property and can't be called as
constructors, whereas regular functions do.
(However, we still need a regular function to construct DateTimeFormat,
because it needs to be able to be invoked without 'new'.)
- Use CreateSlots/GetSlot/SetSlot like the other Temporal objects, instead
of symbol-valued properties. The symbol-valued properties were
observably present for user code.
- In the constructor, observably read all the options from the options bag
in the expected order, and copy them to a null-prototype object with
which we do subsequent operations unobservably.
- Implement the behaviour of format() already having bound the correct
this-object.
- Previously we only half-implemented the normative optional behaviour of
being able to 'bless' a plain object into becoming a DateTimeFormat
object.
Instead, just don't implement it at all. (A real production polyfill
should probably check if the existing Intl.DateTimeFormat has that
behaviour, and match that.)
Closes: #2471
0 commit comments