summaryrefslogtreecommitdiff
path: root/js/src/builtin/intl/Collator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/builtin/intl/Collator.js')
-rw-r--r--js/src/builtin/intl/Collator.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/js/src/builtin/intl/Collator.js b/js/src/builtin/intl/Collator.js
index 48040e1abd..eb96f6cc54 100644
--- a/js/src/builtin/intl/Collator.js
+++ b/js/src/builtin/intl/Collator.js
@@ -107,11 +107,13 @@ function resolveCollatorInternals(lazyCollatorData)
/**
- * Returns an object containing the Collator internal properties of |obj|, or
- * throws a TypeError if |obj| isn't Collator-initialized.
+ * Returns an object containing the Collator internal properties of |obj|.
*/
-function getCollatorInternals(obj, methodName) {
- var internals = getIntlObjectInternals(obj, "Collator", methodName);
+function getCollatorInternals(obj) {
+ assert(IsObject(obj), "getCollatorInternals called with non-object");
+ assert(IsCollator(obj), "getCollatorInternals called with non-Collator");
+
+ var internals = getIntlObjectInternals(obj);
assert(internals.type === "Collator", "bad type escaped getIntlObjectInternals");
// If internal properties have already been computed, use them.
@@ -138,14 +140,11 @@ function getCollatorInternals(obj, methodName) {
* Spec: ECMAScript Internationalization API Specification, 10.1.1.
*/
function InitializeCollator(collator, locales, options) {
- assert(IsObject(collator), "InitializeCollator");
-
- // Step 1.
- if (isInitializedIntlObject(collator))
- ThrowTypeError(JSMSG_INTL_OBJECT_REINITED);
+ assert(IsObject(collator), "InitializeCollator called with non-object");
+ assert(IsCollator(collator), "InitializeCollator called with non-Collator");
- // Step 2.
- var internals = initializeIntlObject(collator);
+ // Steps 1-2 (These steps are no longer required and should be removed
+ // from the spec; https://github.com/tc39/ecma402/issues/115).;
// Lazy Collator data has the following structure:
//
@@ -219,7 +218,7 @@ function InitializeCollator(collator, locales, options) {
//
// We've done everything that must be done now: mark the lazy data as fully
// computed and install it.
- setLazyData(internals, "Collator", lazyCollatorData);
+ initializeIntlObject(collator, "Collator", lazyCollatorData);
}
@@ -311,14 +310,17 @@ function collatorCompareToBind(x, y) {
*/
function Intl_Collator_compare_get() {
// Check "this Collator object" per introduction of section 10.3.
- var internals = getCollatorInternals(this, "compare");
+ if (!IsObject(this) || !IsCollator(this))
+ ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "Collator", "compare", "Collator");
+
+ var internals = getCollatorInternals(this);
// Step 1.
if (internals.boundCompare === undefined) {
// Step 1.a.
var F = collatorCompareToBind;
- // Step 1.b-d.
+ // Steps 1.b-d.
var bc = callFunction(FunctionBind, F, this);
internals.boundCompare = bc;
}
@@ -335,7 +337,10 @@ function Intl_Collator_compare_get() {
*/
function Intl_Collator_resolvedOptions() {
// Check "this Collator object" per introduction of section 10.3.
- var internals = getCollatorInternals(this, "resolvedOptions");
+ if (!IsObject(this) || !IsCollator(this))
+ ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "Collator", "resolvedOptions", "Collator");
+
+ var internals = getCollatorInternals(this);
var result = {
locale: internals.locale,