summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-03-31 14:45:56 +0000
committerMoonchild <moonchild@palemoon.org>2021-03-31 14:45:56 +0000
commit685dafd7759e99afd09baa71dbe42f00543e28dc (patch)
tree9e2c25b041c2578c0ddac1ff13455cda327017aa /js/src
parent1271dbeaf373d8f32bb8c0bac1555d8019fd0895 (diff)
downloaduxp-685dafd7759e99afd09baa71dbe42f00543e28dc.tar.gz
Issue #1756 - Expose NumberFormat.formatToParts() to content.
Diffstat (limited to 'js/src')
-rw-r--r--js/src/builtin/Intl.cpp19
-rw-r--r--js/src/jsapi.h19
-rw-r--r--js/src/shell/js.cpp5
-rw-r--r--js/src/vm/CommonPropertyNames.h2
4 files changed, 1 insertions, 44 deletions
diff --git a/js/src/builtin/Intl.cpp b/js/src/builtin/Intl.cpp
index 71e40a2d54..92dea5687e 100644
--- a/js/src/builtin/Intl.cpp
+++ b/js/src/builtin/Intl.cpp
@@ -755,6 +755,7 @@ static const JSFunctionSpec numberFormat_static_methods[] = {
static const JSFunctionSpec numberFormat_methods[] = {
JS_SELF_HOSTED_FN("resolvedOptions", "Intl_NumberFormat_resolvedOptions", 0, 0),
+ JS_SELF_HOSTED_FN("formatToParts", "Intl_NumberFormat_formatToParts", 1, 0),
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, numberFormat_toSource, 0, 0),
#endif
@@ -905,24 +906,6 @@ CreateNumberFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObjec
return nullptr;
}
-#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
- // If the still-experimental NumberFormat.prototype.formatToParts method is
- // enabled, also add it.
- if (cx->compartment()->creationOptions().experimentalNumberFormatFormatToPartsEnabled()) {
- RootedValue ftp(cx);
- HandlePropertyName name = cx->names().formatToParts;
- if (!GlobalObject::getSelfHostedFunction(cx, cx->global(),
- cx->names().NumberFormatFormatToParts,
- name, 1, &ftp))
- {
- return nullptr;
- }
-
- if (!DefineProperty(cx, proto, cx->names().formatToParts, ftp, nullptr, nullptr, 0))
- return nullptr;
- }
-#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
-
RootedValue options(cx);
if (!CreateDefaultOptions(cx, &options))
return nullptr;
diff --git a/js/src/jsapi.h b/js/src/jsapi.h
index 63119cb288..1eecdbf749 100644
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2206,7 +2206,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
mergeable_(false),
preserveJitCode_(false),
cloneSingletons_(false),
- experimentalNumberFormatFormatToPartsEnabled_(false),
sharedMemoryAndAtomics_(false),
secureContext_(false)
{
@@ -2271,23 +2270,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
return *this;
}
- // ECMA-402 is considering adding a "formatToParts" NumberFormat method,
- // that exposes not just a formatted string but its subcomponents. The
- // method, its semantics, and its name aren't finalized, so for now it's
- // exposed *only* if requested.
- //
- // Until "formatToParts" is included in a final specification edition, it's
- // subject to change or removal at any time. Do *not* rely on it in
- // mission-critical code that can't be changed if ECMA-402 decides not to
- // accept the method in its current form.
- bool experimentalNumberFormatFormatToPartsEnabled() const {
- return experimentalNumberFormatFormatToPartsEnabled_;
- }
- CompartmentCreationOptions& setExperimentalNumberFormatFormatToPartsEnabled(bool flag) {
- experimentalNumberFormatFormatToPartsEnabled_ = flag;
- return *this;
- }
-
bool getSharedMemoryAndAtomicsEnabled() const;
CompartmentCreationOptions& setSharedMemoryAndAtomicsEnabled(bool flag);
@@ -2312,7 +2294,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
bool mergeable_;
bool preserveJitCode_;
bool cloneSingletons_;
- bool experimentalNumberFormatFormatToPartsEnabled_;
bool sharedMemoryAndAtomics_;
bool secureContext_;
};
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index 088551c302..6e155d3ff6 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -4684,11 +4684,6 @@ NewGlobal(JSContext* cx, unsigned argc, Value* vp)
if (v.isBoolean())
creationOptions.setCloneSingletons(v.toBoolean());
- if (!JS_GetProperty(cx, opts, "experimentalNumberFormatFormatToPartsEnabled", &v))
- return false;
- if (v.isBoolean())
- creationOptions.setExperimentalNumberFormatFormatToPartsEnabled(v.toBoolean());
-
if (!JS_GetProperty(cx, opts, "sameZoneAs", &v))
return false;
if (v.isObject())
diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h
index ed75802b1b..7df7563b5b 100644
--- a/js/src/vm/CommonPropertyNames.h
+++ b/js/src/vm/CommonPropertyNames.h
@@ -142,7 +142,6 @@
macro(forceInterpreter, forceInterpreter, "forceInterpreter") \
macro(forEach, forEach, "forEach") \
macro(format, format, "format") \
- macro(formatToParts, formatToParts, "formatToParts") \
macro(fraction, fraction, "fraction") \
macro(frame, frame, "frame") \
macro(from, from, "from") \
@@ -253,7 +252,6 @@
macro(notes, notes, "notes") \
macro(NumberFormat, NumberFormat, "NumberFormat") \
macro(NumberFormatFormatGet, NumberFormatFormatGet, "Intl_NumberFormat_format_get") \
- macro(NumberFormatFormatToParts, NumberFormatFormatToParts, "Intl_NumberFormat_formatToParts") \
macro(numeric, numeric, "numeric") \
macro(objectArguments, objectArguments, "[object Arguments]") \
macro(objectArray, objectArray, "[object Array]") \