| Index: src/i18n.js
|
| diff --git a/src/i18n.js b/src/i18n.js
|
| index 81212b8476f6db1c223d2c5dd50334b74127c372..94fe7d653e9dd78352b2ccf7f120c52c484c093c 100644
|
| --- a/src/i18n.js
|
| +++ b/src/i18n.js
|
| @@ -8,19 +8,28 @@
|
| * Intl object is a single object that has some named properties,
|
| * all of which are constructors.
|
| */
|
| -(function(global, shared, exports) {
|
| +(function(global, utils) {
|
|
|
| "use strict";
|
|
|
| %CheckIsBootstrapping();
|
|
|
| +// -------------------------------------------------------------------
|
| +// Imports
|
| +
|
| var GlobalBoolean = global.Boolean;
|
| var GlobalDate = global.Date;
|
| var GlobalNumber = global.Number;
|
| var GlobalRegExp = global.RegExp;
|
| var GlobalString = global.String;
|
|
|
| -var undefined = global.undefined;
|
| +var MathFloor;
|
| +
|
| +utils.Import(function(from) {
|
| + MathFloor = from.MathFloor;
|
| +});
|
| +
|
| +// -------------------------------------------------------------------
|
|
|
| var Intl = {};
|
|
|
| @@ -30,24 +39,24 @@ var Intl = {};
|
| * Caches available locales for each service.
|
| */
|
| var AVAILABLE_LOCALES = {
|
| - 'collator': undefined,
|
| - 'numberformat': undefined,
|
| - 'dateformat': undefined,
|
| - 'breakiterator': undefined
|
| + 'collator': UNDEFINED,
|
| + 'numberformat': UNDEFINED,
|
| + 'dateformat': UNDEFINED,
|
| + 'breakiterator': UNDEFINED
|
| };
|
|
|
| /**
|
| * Caches default ICU locale.
|
| */
|
| -var DEFAULT_ICU_LOCALE = undefined;
|
| +var DEFAULT_ICU_LOCALE = UNDEFINED;
|
|
|
| /**
|
| * Unicode extension regular expression.
|
| */
|
| -var UNICODE_EXTENSION_RE = undefined;
|
| +var UNICODE_EXTENSION_RE = UNDEFINED;
|
|
|
| function GetUnicodeExtensionRE() {
|
| - if (UNICODE_EXTENSION_RE === undefined) {
|
| + if (IS_UNDEFINED(UNDEFINED)) {
|
| UNICODE_EXTENSION_RE = new GlobalRegExp('-u(-[a-z0-9]{2,8})+', 'g');
|
| }
|
| return UNICODE_EXTENSION_RE;
|
| @@ -56,10 +65,10 @@ function GetUnicodeExtensionRE() {
|
| /**
|
| * Matches any Unicode extension.
|
| */
|
| -var ANY_EXTENSION_RE = undefined;
|
| +var ANY_EXTENSION_RE = UNDEFINED;
|
|
|
| function GetAnyExtensionRE() {
|
| - if (ANY_EXTENSION_RE === undefined) {
|
| + if (IS_UNDEFINED(ANY_EXTENSION_RE)) {
|
| ANY_EXTENSION_RE = new GlobalRegExp('-[a-z0-9]{1}-.*', 'g');
|
| }
|
| return ANY_EXTENSION_RE;
|
| @@ -68,10 +77,10 @@ function GetAnyExtensionRE() {
|
| /**
|
| * Replace quoted text (single quote, anything but the quote and quote again).
|
| */
|
| -var QUOTED_STRING_RE = undefined;
|
| +var QUOTED_STRING_RE = UNDEFINED;
|
|
|
| function GetQuotedStringRE() {
|
| - if (QUOTED_STRING_RE === undefined) {
|
| + if (IS_UNDEFINED(QUOTED_STRING_RE)) {
|
| QUOTED_STRING_RE = new GlobalRegExp("'[^']+'", 'g');
|
| }
|
| return QUOTED_STRING_RE;
|
| @@ -80,10 +89,10 @@ function GetQuotedStringRE() {
|
| /**
|
| * Matches valid service name.
|
| */
|
| -var SERVICE_RE = undefined;
|
| +var SERVICE_RE = UNDEFINED;
|
|
|
| function GetServiceRE() {
|
| - if (SERVICE_RE === undefined) {
|
| + if (IS_UNDEFINED(SERVICE_RE)) {
|
| SERVICE_RE =
|
| new GlobalRegExp('^(collator|numberformat|dateformat|breakiterator)$');
|
| }
|
| @@ -94,10 +103,10 @@ function GetServiceRE() {
|
| * Validates a language tag against bcp47 spec.
|
| * Actual value is assigned on first run.
|
| */
|
| -var LANGUAGE_TAG_RE = undefined;
|
| +var LANGUAGE_TAG_RE = UNDEFINED;
|
|
|
| function GetLanguageTagRE() {
|
| - if (LANGUAGE_TAG_RE === undefined) {
|
| + if (IS_UNDEFINED(LANGUAGE_TAG_RE)) {
|
| BuildLanguageTagREs();
|
| }
|
| return LANGUAGE_TAG_RE;
|
| @@ -106,10 +115,10 @@ function GetLanguageTagRE() {
|
| /**
|
| * Helps find duplicate variants in the language tag.
|
| */
|
| -var LANGUAGE_VARIANT_RE = undefined;
|
| +var LANGUAGE_VARIANT_RE = UNDEFINED;
|
|
|
| function GetLanguageVariantRE() {
|
| - if (LANGUAGE_VARIANT_RE === undefined) {
|
| + if (IS_UNDEFINED(LANGUAGE_VARIANT_RE)) {
|
| BuildLanguageTagREs();
|
| }
|
| return LANGUAGE_VARIANT_RE;
|
| @@ -118,10 +127,10 @@ function GetLanguageVariantRE() {
|
| /**
|
| * Helps find duplicate singletons in the language tag.
|
| */
|
| -var LANGUAGE_SINGLETON_RE = undefined;
|
| +var LANGUAGE_SINGLETON_RE = UNDEFINED;
|
|
|
| function GetLanguageSingletonRE() {
|
| - if (LANGUAGE_SINGLETON_RE === undefined) {
|
| + if (IS_UNDEFINED(LANGUAGE_SINGLETON_RE)) {
|
| BuildLanguageTagREs();
|
| }
|
| return LANGUAGE_SINGLETON_RE;
|
| @@ -130,10 +139,10 @@ function GetLanguageSingletonRE() {
|
| /**
|
| * Matches valid IANA time zone names.
|
| */
|
| -var TIMEZONE_NAME_CHECK_RE = undefined;
|
| +var TIMEZONE_NAME_CHECK_RE = UNDEFINED;
|
|
|
| function GetTimezoneNameCheckRE() {
|
| - if (TIMEZONE_NAME_CHECK_RE === undefined) {
|
| + if (IS_UNDEFINED(TIMEZONE_NAME_CHECK_RE)) {
|
| TIMEZONE_NAME_CHECK_RE =
|
| new GlobalRegExp('^([A-Za-z]+)/([A-Za-z]+)(?:_([A-Za-z]+))*$');
|
| }
|
| @@ -149,10 +158,10 @@ function addBoundMethod(obj, methodName, implementation, length) {
|
| throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
|
| }
|
| var internalName = '__bound' + methodName + '__';
|
| - if (this[internalName] === undefined) {
|
| + if (IS_UNDEFINED(this[internalName])) {
|
| var that = this;
|
| var boundMethod;
|
| - if (length === undefined || length === 2) {
|
| + if (IS_UNDEFINED(length) || length === 2) {
|
| boundMethod = function(x, y) {
|
| if (%_IsConstructCall()) {
|
| throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
| @@ -211,14 +220,14 @@ function supportedLocalesOf(service, locales, options) {
|
| }
|
|
|
| // Provide defaults if matcher was not specified.
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| } else {
|
| options = $toObject(options);
|
| }
|
|
|
| var matcher = options.localeMatcher;
|
| - if (matcher !== undefined) {
|
| + if (!IS_UNDEFINED(matcher)) {
|
| matcher = GlobalString(matcher);
|
| if (matcher !== 'lookup' && matcher !== 'best fit') {
|
| throw MakeRangeError(kLocaleMatcher, matcher);
|
| @@ -230,7 +239,7 @@ function supportedLocalesOf(service, locales, options) {
|
| var requestedLocales = initializeLocaleList(locales);
|
|
|
| // Cache these, they don't ever change per service.
|
| - if (AVAILABLE_LOCALES[service] === undefined) {
|
| + if (IS_UNDEFINED(AVAILABLE_LOCALES[service])) {
|
| AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
|
| }
|
|
|
| @@ -256,7 +265,7 @@ function lookupSupportedLocalesOf(requestedLocales, availableLocales) {
|
| // Remove -u- extension.
|
| var locale = requestedLocales[i].replace(GetUnicodeExtensionRE(), '');
|
| do {
|
| - if (availableLocales[locale] !== undefined) {
|
| + if (!IS_UNDEFINED(availableLocales[locale])) {
|
| // Push requested locale not the resolved one.
|
| matchedLocales.push(requestedLocales[i]);
|
| break;
|
| @@ -292,10 +301,10 @@ function bestFitSupportedLocalesOf(requestedLocales, availableLocales) {
|
| * is out of range for that property it throws RangeError.
|
| */
|
| function getGetOption(options, caller) {
|
| - if (options === undefined) throw MakeError(kDefaultOptionsMissing, caller);
|
| + if (IS_UNDEFINED(options)) throw MakeError(kDefaultOptionsMissing, caller);
|
|
|
| var getOption = function getOption(property, type, values, defaultValue) {
|
| - if (options[property] !== undefined) {
|
| + if (!IS_UNDEFINED(options[property])) {
|
| var value = options[property];
|
| switch (type) {
|
| case 'boolean':
|
| @@ -310,7 +319,7 @@ function getGetOption(options, caller) {
|
| default:
|
| throw MakeError(kWrongValueType);
|
| }
|
| - if (values !== undefined && values.indexOf(value) === -1) {
|
| + if (!IS_UNDEFINED(values) && values.indexOf(value) === -1) {
|
| throw MakeRangeError(kValueOutOfRange, value, caller, property);
|
| }
|
|
|
| @@ -364,7 +373,7 @@ function lookupMatcher(service, requestedLocales) {
|
| }
|
|
|
| // Cache these, they don't ever change per service.
|
| - if (AVAILABLE_LOCALES[service] === undefined) {
|
| + if (IS_UNDEFINED(AVAILABLE_LOCALES[service])) {
|
| AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
|
| }
|
|
|
| @@ -372,7 +381,7 @@ function lookupMatcher(service, requestedLocales) {
|
| // Remove all extensions.
|
| var locale = requestedLocales[i].replace(GetAnyExtensionRE(), '');
|
| do {
|
| - if (AVAILABLE_LOCALES[service][locale] !== undefined) {
|
| + if (!IS_UNDEFINED(AVAILABLE_LOCALES[service][locale])) {
|
| // Return the resolved locale and extension.
|
| var extensionMatch = requestedLocales[i].match(GetUnicodeExtensionRE());
|
| var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
|
| @@ -388,7 +397,7 @@ function lookupMatcher(service, requestedLocales) {
|
| }
|
|
|
| // Didn't find a match, return default.
|
| - if (DEFAULT_ICU_LOCALE === undefined) {
|
| + if (IS_UNDEFINED(DEFAULT_ICU_LOCALE)) {
|
| DEFAULT_ICU_LOCALE = %GetDefaultICULocale();
|
| }
|
|
|
| @@ -423,16 +432,16 @@ function parseExtension(extension) {
|
| // Key is {2}alphanum, value is {3,8}alphanum.
|
| // Some keys may not have explicit values (booleans).
|
| var extensionMap = {};
|
| - var previousKey = undefined;
|
| + var previousKey = UNDEFINED;
|
| for (var i = 2; i < extensionSplit.length; ++i) {
|
| var length = extensionSplit[i].length;
|
| var element = extensionSplit[i];
|
| if (length === 2) {
|
| - extensionMap[element] = undefined;
|
| + extensionMap[element] = UNDEFINED;
|
| previousKey = element;
|
| - } else if (length >= 3 && length <=8 && previousKey !== undefined) {
|
| + } else if (length >= 3 && length <=8 && !IS_UNDEFINED(previousKey)) {
|
| extensionMap[previousKey] = element;
|
| - previousKey = undefined;
|
| + previousKey = UNDEFINED;
|
| } else {
|
| // There is a value that's too long, or that doesn't have a key.
|
| return {};
|
| @@ -465,21 +474,21 @@ function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
|
| value = (value === 'true') ? true : false;
|
| }
|
|
|
| - if (property !== undefined) {
|
| + if (!IS_UNDEFINED(property)) {
|
| defineWEProperty(outOptions, property, value);
|
| }
|
| }
|
|
|
| for (var key in keyValues) {
|
| if (keyValues.hasOwnProperty(key)) {
|
| - var value = undefined;
|
| + var value = UNDEFINED;
|
| var map = keyValues[key];
|
| - if (map.property !== undefined) {
|
| + if (!IS_UNDEFINED(map.property)) {
|
| // This may return true if user specifies numeric: 'false', since
|
| // Boolean('nonempty') === true.
|
| value = getOption(map.property, map.type, map.values);
|
| }
|
| - if (value !== undefined) {
|
| + if (!IS_UNDEFINED(value)) {
|
| updateProperty(map.property, map.type, value);
|
| extension += updateExtension(key, value);
|
| continue;
|
| @@ -489,7 +498,7 @@ function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
|
| // values (not a user error).
|
| if (extensionMap.hasOwnProperty(key)) {
|
| value = extensionMap[key];
|
| - if (value !== undefined) {
|
| + if (!IS_UNDEFINED(value)) {
|
| updateProperty(map.property, map.type, value);
|
| extension += updateExtension(key, value);
|
| } else if (map.type === 'boolean') {
|
| @@ -590,7 +599,7 @@ function defineWEProperty(object, property, value) {
|
| * Sets configurable descriptor to false.
|
| */
|
| function addWEPropertyIfDefined(object, property, value) {
|
| - if (value !== undefined) {
|
| + if (!IS_UNDEFINED(value)) {
|
| defineWEProperty(object, property, value);
|
| }
|
| }
|
| @@ -612,7 +621,7 @@ function defineWECProperty(object, property, value) {
|
| * Sets all descriptors to true.
|
| */
|
| function addWECPropertyIfDefined(object, property, value) {
|
| - if (value !== undefined) {
|
| + if (!IS_UNDEFINED(value)) {
|
| defineWECProperty(object, property, value);
|
| }
|
| }
|
| @@ -660,7 +669,7 @@ function canonicalizeLanguageTag(localeID) {
|
| */
|
| function initializeLocaleList(locales) {
|
| var seen = [];
|
| - if (locales === undefined) {
|
| + if (IS_UNDEFINED(locales)) {
|
| // Constructor is called without arguments.
|
| seen = [];
|
| } else {
|
| @@ -793,7 +802,7 @@ function initializeCollator(collator, locales, options) {
|
| throw MakeTypeError(kReinitializeIntl, "Collator");
|
| }
|
|
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| }
|
|
|
| @@ -806,13 +815,13 @@ function initializeCollator(collator, locales, options) {
|
|
|
| var sensitivity = getOption('sensitivity', 'string',
|
| ['base', 'accent', 'case', 'variant']);
|
| - if (sensitivity === undefined && internalOptions.usage === 'sort') {
|
| + if (IS_UNDEFINED(sensitivity) && internalOptions.usage === 'sort') {
|
| sensitivity = 'variant';
|
| }
|
| defineWEProperty(internalOptions, 'sensitivity', sensitivity);
|
|
|
| defineWEProperty(internalOptions, 'ignorePunctuation', getOption(
|
| - 'ignorePunctuation', 'boolean', undefined, false));
|
| + 'ignorePunctuation', 'boolean', UNDEFINED, false));
|
|
|
| var locale = resolveLocale('collator', locales, options);
|
|
|
| @@ -998,12 +1007,12 @@ function isWellFormedCurrencyCode(currency) {
|
| */
|
| function getNumberOption(options, property, min, max, fallback) {
|
| var value = options[property];
|
| - if (value !== undefined) {
|
| + if (!IS_UNDEFINED(value)) {
|
| value = GlobalNumber(value);
|
| if ($isNaN(value) || value < min || value > max) {
|
| throw MakeRangeError(kPropertyValueOutOfRange, property);
|
| }
|
| - return $floor(value);
|
| + return MathFloor(value);
|
| }
|
|
|
| return fallback;
|
| @@ -1019,7 +1028,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
| throw MakeTypeError(kReinitializeIntl, "NumberFormat");
|
| }
|
|
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| }
|
|
|
| @@ -1032,11 +1041,11 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
| 'style', 'string', ['decimal', 'percent', 'currency'], 'decimal'));
|
|
|
| var currency = getOption('currency', 'string');
|
| - if (currency !== undefined && !isWellFormedCurrencyCode(currency)) {
|
| + if (!IS_UNDEFINED(currency) && !isWellFormedCurrencyCode(currency)) {
|
| throw MakeRangeError(kInvalidCurrencyCode, currency);
|
| }
|
|
|
| - if (internalOptions.style === 'currency' && currency === undefined) {
|
| + if (internalOptions.style === 'currency' && IS_UNDEFINED(currency)) {
|
| throw MakeTypeError(kCurrencyCode);
|
| }
|
|
|
| @@ -1059,7 +1068,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
|
|
| var mnsd = options['minimumSignificantDigits'];
|
| var mxsd = options['maximumSignificantDigits'];
|
| - if (mnsd !== undefined || mxsd !== undefined) {
|
| + if (!IS_UNDEFINED(mnsd) || !IS_UNDEFINED(mxsd)) {
|
| mnsd = getNumberOption(options, 'minimumSignificantDigits', 1, 21, 0);
|
| defineWEProperty(internalOptions, 'minimumSignificantDigits', mnsd);
|
|
|
| @@ -1069,7 +1078,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
|
|
| // Grouping.
|
| defineWEProperty(internalOptions, 'useGrouping', getOption(
|
| - 'useGrouping', 'boolean', undefined, true));
|
| + 'useGrouping', 'boolean', UNDEFINED, true));
|
|
|
| // ICU prefers options to be passed using -u- extension key/values for
|
| // number format, so we need to build that.
|
| @@ -1080,7 +1089,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
| * for a number format.
|
| */
|
| var NUMBER_FORMAT_KEY_MAP = {
|
| - 'nu': {'property': undefined, 'type': 'string'}
|
| + 'nu': {'property': UNDEFINED, 'type': 'string'}
|
| };
|
|
|
| var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP,
|
| @@ -1100,10 +1109,10 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
| useGrouping: {writable: true}
|
| });
|
| if (internalOptions.hasOwnProperty('minimumSignificantDigits')) {
|
| - defineWEProperty(resolved, 'minimumSignificantDigits', undefined);
|
| + defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED);
|
| }
|
| if (internalOptions.hasOwnProperty('maximumSignificantDigits')) {
|
| - defineWEProperty(resolved, 'maximumSignificantDigits', undefined);
|
| + defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED);
|
| }
|
| var formatter = %CreateNumberFormat(requestedLocale,
|
| internalOptions,
|
| @@ -1272,7 +1281,7 @@ function toLDMLString(options) {
|
|
|
| var hr12 = getOption('hour12', 'boolean');
|
| option = getOption('hour', 'string', ['2-digit', 'numeric']);
|
| - if (hr12 === undefined) {
|
| + if (IS_UNDEFINED(hr12)) {
|
| ldmlString += appendToLDMLString(option, {'2-digit': 'jj', 'numeric': 'j'});
|
| } else if (hr12 === true) {
|
| ldmlString += appendToLDMLString(option, {'2-digit': 'hh', 'numeric': 'h'});
|
| @@ -1297,7 +1306,7 @@ function toLDMLString(options) {
|
| * Returns either LDML equivalent of the current option or empty string.
|
| */
|
| function appendToLDMLString(option, pairs) {
|
| - if (option !== undefined) {
|
| + if (!IS_UNDEFINED(option)) {
|
| return pairs[option];
|
| } else {
|
| return '';
|
| @@ -1371,7 +1380,7 @@ function fromLDMLString(ldmlString) {
|
| function appendToDateTimeObject(options, option, match, pairs) {
|
| if (IS_NULL(match)) {
|
| if (!options.hasOwnProperty(option)) {
|
| - defineWEProperty(options, option, undefined);
|
| + defineWEProperty(options, option, UNDEFINED);
|
| }
|
| return options;
|
| }
|
| @@ -1387,7 +1396,7 @@ function appendToDateTimeObject(options, option, match, pairs) {
|
| * Returns options with at least default values in it.
|
| */
|
| function toDateTimeOptions(options, required, defaults) {
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| } else {
|
| options = TO_OBJECT_INLINE(options);
|
| @@ -1395,14 +1404,14 @@ function toDateTimeOptions(options, required, defaults) {
|
|
|
| var needsDefault = true;
|
| if ((required === 'date' || required === 'any') &&
|
| - (options.weekday !== undefined || options.year !== undefined ||
|
| - options.month !== undefined || options.day !== undefined)) {
|
| + (!IS_UNDEFINED(options.weekday) || !IS_UNDEFINED(options.year) ||
|
| + !IS_UNDEFINED(options.month) || !IS_UNDEFINED(options.day))) {
|
| needsDefault = false;
|
| }
|
|
|
| if ((required === 'time' || required === 'any') &&
|
| - (options.hour !== undefined || options.minute !== undefined ||
|
| - options.second !== undefined)) {
|
| + (!IS_UNDEFINED(options.hour) || !IS_UNDEFINED(options.minute) ||
|
| + !IS_UNDEFINED(options.second))) {
|
| needsDefault = false;
|
| }
|
|
|
| @@ -1450,7 +1459,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
| throw MakeTypeError(kReinitializeIntl, "DateTimeFormat");
|
| }
|
|
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| }
|
|
|
| @@ -1483,8 +1492,8 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
| * for a date/time format.
|
| */
|
| var DATETIME_FORMAT_KEY_MAP = {
|
| - 'ca': {'property': undefined, 'type': 'string'},
|
| - 'nu': {'property': undefined, 'type': 'string'}
|
| + 'ca': {'property': UNDEFINED, 'type': 'string'},
|
| + 'nu': {'property': UNDEFINED, 'type': 'string'}
|
| };
|
|
|
| var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP,
|
| @@ -1514,7 +1523,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
| var formatter = %CreateDateTimeFormat(
|
| requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved);
|
|
|
| - if (tz !== undefined && tz !== resolved.timeZone) {
|
| + if (!IS_UNDEFINED(tz) && tz !== resolved.timeZone) {
|
| throw MakeRangeError(kUnsupportedTimeZone, tz);
|
| }
|
|
|
| @@ -1580,7 +1589,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
| var format = this;
|
| var fromPattern = fromLDMLString(format.resolved.pattern);
|
| var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar];
|
| - if (userCalendar === undefined) {
|
| + if (IS_UNDEFINED(userCalendar)) {
|
| // Use ICU name if we don't have a match. It shouldn't happen, but
|
| // it would be too strict to throw for this.
|
| userCalendar = format.resolved.calendar;
|
| @@ -1644,7 +1653,7 @@ $setFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
|
| */
|
| function formatDate(formatter, dateValue) {
|
| var dateMs;
|
| - if (dateValue === undefined) {
|
| + if (IS_UNDEFINED(dateValue)) {
|
| dateMs = GlobalDate.now();
|
| } else {
|
| dateMs = $toNumber(dateValue);
|
| @@ -1680,7 +1689,7 @@ addBoundMethod(Intl.DateTimeFormat, 'v8Parse', parseDate, 1);
|
| */
|
| function canonicalizeTimeZoneID(tzID) {
|
| // Skip undefined zones.
|
| - if (tzID === undefined) {
|
| + if (IS_UNDEFINED(tzID)) {
|
| return tzID;
|
| }
|
|
|
| @@ -1698,7 +1707,7 @@ function canonicalizeTimeZoneID(tzID) {
|
|
|
| var result = toTitleCaseWord(match[1]) + '/' + toTitleCaseWord(match[2]);
|
| var i = 3;
|
| - while (match[i] !== undefined && i < match.length) {
|
| + while (!IS_UNDEFINED(match[i]) && i < match.length) {
|
| result = result + '_' + toTitleCaseWord(match[i]);
|
| i++;
|
| }
|
| @@ -1715,7 +1724,7 @@ function initializeBreakIterator(iterator, locales, options) {
|
| throw MakeTypeError(kReinitializeIntl, "v8BreakIterator");
|
| }
|
|
|
| - if (options === undefined) {
|
| + if (IS_UNDEFINED(options)) {
|
| options = {};
|
| }
|
|
|
| @@ -1878,11 +1887,11 @@ var savedObjects = {
|
| // Default (created with undefined locales and options parameters) collator,
|
| // number and date format instances. They'll be created as needed.
|
| var defaultObjects = {
|
| - 'collator': undefined,
|
| - 'numberformat': undefined,
|
| - 'dateformatall': undefined,
|
| - 'dateformatdate': undefined,
|
| - 'dateformattime': undefined,
|
| + 'collator': UNDEFINED,
|
| + 'numberformat': UNDEFINED,
|
| + 'dateformatall': UNDEFINED,
|
| + 'dateformatdate': UNDEFINED,
|
| + 'dateformattime': UNDEFINED,
|
| };
|
|
|
|
|
| @@ -1891,9 +1900,9 @@ var defaultObjects = {
|
| * We cache only default instances (where no locales or options are provided).
|
| */
|
| function cachedOrNewService(service, locales, options, defaults) {
|
| - var useOptions = (defaults === undefined) ? options : defaults;
|
| - if (locales === undefined && options === undefined) {
|
| - if (defaultObjects[service] === undefined) {
|
| + var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults;
|
| + if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) {
|
| + if (IS_UNDEFINED(defaultObjects[service])) {
|
| defaultObjects[service] = new savedObjects[service](locales, useOptions);
|
| }
|
| return defaultObjects[service];
|
|
|