mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 08:07:30 +09:00
Issue #2259 - Introduce helper for self-hosted hasOwnProperty calls in intl
This commit is contained in:
parent
a7d752deff
commit
adffcb127a
4 changed files with 20 additions and 12 deletions
|
|
@ -5,6 +5,14 @@
|
||||||
/* Portions Copyright Norbert Lindenberg 2011-2012. */
|
/* Portions Copyright Norbert Lindenberg 2011-2012. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shorthand for hasOwnProperty.
|
||||||
|
*/
|
||||||
|
function hasOwn(propName, object) {
|
||||||
|
return callFunction(std_Object_hasOwnProperty, object, propName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder object for encapsulating regexp instances.
|
* Holder object for encapsulating regexp instances.
|
||||||
*
|
*
|
||||||
|
|
@ -346,7 +354,7 @@ function CanonicalizeLanguageTag(locale) {
|
||||||
locale = callFunction(std_String_toLowerCase, locale);
|
locale = callFunction(std_String_toLowerCase, locale);
|
||||||
|
|
||||||
// Handle mappings for complete tags.
|
// Handle mappings for complete tags.
|
||||||
if (callFunction(std_Object_hasOwnProperty, langTagMappings, locale))
|
if (hasOwn(locale, langTagMappings))
|
||||||
return langTagMappings[locale];
|
return langTagMappings[locale];
|
||||||
|
|
||||||
var subtags = StringSplitString(ToString(locale), "-");
|
var subtags = StringSplitString(ToString(locale), "-");
|
||||||
|
|
@ -378,7 +386,7 @@ function CanonicalizeLanguageTag(locale) {
|
||||||
subtag = callFunction(std_String_toUpperCase, subtag);
|
subtag = callFunction(std_String_toUpperCase, subtag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callFunction(std_Object_hasOwnProperty, langSubtagMappings, subtag)) {
|
if (hasOwn(subtag, langSubtagMappings)) {
|
||||||
// Replace deprecated subtags with their preferred values.
|
// Replace deprecated subtags with their preferred values.
|
||||||
// "BU" -> "MM"
|
// "BU" -> "MM"
|
||||||
// This has to come after we capitalize region codes because
|
// This has to come after we capitalize region codes because
|
||||||
|
|
@ -388,7 +396,7 @@ function CanonicalizeLanguageTag(locale) {
|
||||||
// Note that the script generating langSubtagMappings makes sure
|
// Note that the script generating langSubtagMappings makes sure
|
||||||
// that no regular subtag mapping will replace an extlang code.
|
// that no regular subtag mapping will replace an extlang code.
|
||||||
subtag = langSubtagMappings[subtag];
|
subtag = langSubtagMappings[subtag];
|
||||||
} else if (callFunction(std_Object_hasOwnProperty, extlangMappings, subtag)) {
|
} else if (hasOwn(subtag, extlangMappings)) {
|
||||||
// Replace deprecated extlang subtags with their preferred values,
|
// Replace deprecated extlang subtags with their preferred values,
|
||||||
// and remove the preceding subtag if it's a redundant prefix.
|
// and remove the preceding subtag if it's a redundant prefix.
|
||||||
// "zh-nan" -> "nan"
|
// "zh-nan" -> "nan"
|
||||||
|
|
@ -516,7 +524,7 @@ function DefaultLocaleIgnoringAvailableLocales() {
|
||||||
// remove any present in the candidate.
|
// remove any present in the candidate.
|
||||||
candidate = removeUnicodeExtensions(candidate);
|
candidate = removeUnicodeExtensions(candidate);
|
||||||
|
|
||||||
if (callFunction(std_Object_hasOwnProperty, oldStyleLanguageTagMappings, candidate))
|
if (hasOwn(candidate, oldStyleLanguageTagMappings))
|
||||||
candidate = oldStyleLanguageTagMappings[candidate];
|
candidate = oldStyleLanguageTagMappings[candidate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1163,14 +1171,14 @@ function isInitializedIntlObject(obj) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
var internals = callFunction(std_WeakMap_get, internalsMap, obj);
|
var internals = callFunction(std_WeakMap_get, internalsMap, obj);
|
||||||
if (IsObject(internals)) {
|
if (IsObject(internals)) {
|
||||||
assert(callFunction(std_Object_hasOwnProperty, internals, "type"), "missing type");
|
assert(hasOwn("type", internals), "missing type");
|
||||||
var type = internals.type;
|
var type = internals.type;
|
||||||
assert(type === "partial" || type === "Collator" ||
|
assert(type === "partial" || type === "Collator" ||
|
||||||
type === "DateTimeFormat" || type === "NumberFormat" ||
|
type === "DateTimeFormat" || type === "NumberFormat" ||
|
||||||
type === "PluralRules" || type === "RelativeTimeFormat",
|
type === "PluralRules" || type === "RelativeTimeFormat",
|
||||||
"unexpected type");
|
"unexpected type");
|
||||||
assert(callFunction(std_Object_hasOwnProperty, internals, "lazyData"), "missing lazyData");
|
assert(hasOwn("lazyData", internals), "missing lazyData");
|
||||||
assert(callFunction(std_Object_hasOwnProperty, internals, "internalProps"), "missing internalProps");
|
assert(hasOwn("internalProps", internals), "missing internalProps");
|
||||||
} else {
|
} else {
|
||||||
assert(internals === undefined, "bad mapping for |obj|");
|
assert(internals === undefined, "bad mapping for |obj|");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -623,7 +623,7 @@ function BasicFormatMatcher(options, formats) {
|
||||||
formatProp = undefined;
|
formatProp = undefined;
|
||||||
|
|
||||||
// Steps 11.c.ii-iii.
|
// Steps 11.c.ii-iii.
|
||||||
if (callFunction(std_Object_hasOwnProperty, format, property))
|
if (hasOwn(property, format))
|
||||||
formatProp = format[property];
|
formatProp = format[property];
|
||||||
|
|
||||||
if (optionsProp === undefined && formatProp !== undefined) {
|
if (optionsProp === undefined && formatProp !== undefined) {
|
||||||
|
|
@ -886,7 +886,7 @@ function resolveICUPattern(pattern, result) {
|
||||||
default:
|
default:
|
||||||
// skip other pattern characters and literal text
|
// skip other pattern characters and literal text
|
||||||
}
|
}
|
||||||
if (callFunction(std_Object_hasOwnProperty, icuPatternCharToComponent, c))
|
if (hasOwn(c, icuPatternCharToComponent))
|
||||||
_DefineDataProperty(result, icuPatternCharToComponent[c], value);
|
_DefineDataProperty(result, icuPatternCharToComponent[c], value);
|
||||||
if (c === "h" || c === "K")
|
if (c === "h" || c === "K")
|
||||||
_DefineDataProperty(result, "hour12", true);
|
_DefineDataProperty(result, "hour12", true);
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ function CurrencyDigits(currency) {
|
||||||
assert(typeof currency === "string", "CurrencyDigits");
|
assert(typeof currency === "string", "CurrencyDigits");
|
||||||
assert(regexp_test_no_statics(getCurrencyDigitsRE(), currency), "CurrencyDigits");
|
assert(regexp_test_no_statics(getCurrencyDigitsRE(), currency), "CurrencyDigits");
|
||||||
|
|
||||||
if (callFunction(std_Object_hasOwnProperty, currencyDigits, currency))
|
if (hasOwn(currency, currencyDigits))
|
||||||
return currencyDigits[currency];
|
return currencyDigits[currency];
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -502,7 +502,7 @@ function Intl_NumberFormat_resolvedOptions() {
|
||||||
];
|
];
|
||||||
for (var i = 0; i < optionalProperties.length; i++) {
|
for (var i = 0; i < optionalProperties.length; i++) {
|
||||||
var p = optionalProperties[i];
|
var p = optionalProperties[i];
|
||||||
if (callFunction(std_Object_hasOwnProperty, internals, p))
|
if (hasOwn(p, internals))
|
||||||
_DefineDataProperty(result, p, internals[p]);
|
_DefineDataProperty(result, p, internals[p]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ function Intl_PluralRules_resolvedOptions() {
|
||||||
|
|
||||||
for (var i = 0; i < optionalProperties.length; i++) {
|
for (var i = 0; i < optionalProperties.length; i++) {
|
||||||
var p = optionalProperties[i];
|
var p = optionalProperties[i];
|
||||||
if (callFunction(std_Object_hasOwnProperty, internals, p))
|
if (hasOwn(p, internals))
|
||||||
_DefineDataProperty(result, p, internals[p]);
|
_DefineDataProperty(result, p, internals[p]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue