|
|
@@ -692,17 +692,19 @@
|
|
|
? BestFitSupportedLocales(isAvailableLocale, requestedLocales)
|
|
|
: LookupSupportedLocales(isAvailableLocale, requestedLocales);
|
|
|
|
|
|
+ // make sure property descriptor is null-prototyped to avoid tainting of Object.prototype.{get|set}
|
|
|
+ const descriptor = _.setPrototypeOf({ configurable: false, writable: false });
|
|
|
for (let i = 0; i < supportedLocales.length; i++) {
|
|
|
- _.defineProperty(supportedLocales, Internal.ToString(i), { configurable: false, writable: false });
|
|
|
+ _.defineProperty(supportedLocales, Internal.ToString(i), descriptor);
|
|
|
}
|
|
|
|
|
|
// test262 supportedLocalesOf-returned-array-elements-are-frozen.js:
|
|
|
// Property length of object returned by SupportedLocales should not be writable
|
|
|
- _.defineProperty(supportedLocales, "length", {
|
|
|
+ _.defineProperty(supportedLocales, "length", _.setPrototypeOf({
|
|
|
writable: false,
|
|
|
configurable: false,
|
|
|
enumerable: false,
|
|
|
- });
|
|
|
+ }));
|
|
|
|
|
|
return supportedLocales;
|
|
|
};
|
|
|
@@ -771,11 +773,14 @@
|
|
|
*
|
|
|
* @param {String[]} props The list of properties to extract from hiddenObject and add to the final resolved options
|
|
|
* @param {Object} hiddenObject The hiddenObject of the calling constructor that contains values for each prop in props
|
|
|
+ * @param {Function} func An optional custom function(prop, resolved) run for each prop; if omitted, default logic will be used
|
|
|
*/
|
|
|
- const createResolvedOptions = function (props, hiddenObject) {
|
|
|
+ const createResolvedOptions = function (props, hiddenObject, func = null) {
|
|
|
const resolved = _.create();
|
|
|
_.forEach(props, function (prop) {
|
|
|
- if (typeof hiddenObject[prop] !== undefined) {
|
|
|
+ if (func !== null) {
|
|
|
+ func(prop, resolved);
|
|
|
+ } else if (typeof hiddenObject[prop] !== "undefined") {
|
|
|
resolved[prop] = hiddenObject[prop];
|
|
|
}
|
|
|
});
|
|
|
@@ -1790,7 +1795,17 @@
|
|
|
"timeZoneName",
|
|
|
];
|
|
|
|
|
|
- return createResolvedOptions(options, hiddenObject);
|
|
|
+ return createResolvedOptions(options, hiddenObject, function (prop, resolved) {
|
|
|
+ if (prop === "hourCycle") {
|
|
|
+ const hc = hiddenObject.hourCycle;
|
|
|
+ if (hiddenObject.hour !== undefined && hc !== null) {
|
|
|
+ resolved.hourCycle = hc;
|
|
|
+ resolved.hour12 = hc === "h11" || hc === "h12";
|
|
|
+ }
|
|
|
+ } else if (hiddenObject[prop] !== undefined && hiddenObject[prop] !== null) {
|
|
|
+ resolved[prop] = hiddenObject[prop];
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
writable: true,
|
|
|
enumerable: false,
|