Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@aa4a91e5bb
Browse files Browse the repository at this point in the history
[MERGE #5462 @jackhorton] Update NumberFormat to treat -0 as a negative number and PluralRules to not define sigfig properties on the resolved options if the user did not request them

Merge pull request #5462 from jackhorton:intl/sigfigs-and-negzero

OS#18105112

Reviewed-By: chakrabot <[email protected]>
  • Loading branch information
jackhorton authored and kfarnung committed Jul 18, 2018
1 parent 0b55fed commit 5b6d604
Show file tree
Hide file tree
Showing 7 changed files with 23,284 additions and 23,317 deletions.
34 changes: 16 additions & 18 deletions deps/chakrashim/core/lib/Runtime/Library/InJavascript/Intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,18 @@
*
* @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
* @param {Function} func An optional custom function(prop, resolved) run for each prop; it should return true when
* it handles a property itself. If it does not return true, the default logic will be used.
*/
const createResolvedOptions = function (props, hiddenObject, func = null) {
const resolved = _.create();
_.forEach(props, function (prop) {
if (func !== null) {
func(prop, resolved);
} else if (typeof hiddenObject[prop] !== "undefined") {
if (func !== null && func(prop, resolved) === true) {
// the callback returned true, which means this property was handled and we can go to the next one
return;
}

if (typeof hiddenObject[prop] !== "undefined") {
resolved[prop] = hiddenObject[prop];
}
});
Expand Down Expand Up @@ -1220,8 +1224,7 @@
InitializeNumberFormat(stateObject, arguments[0], arguments[1]);

const n = Internal.ToNumber(this);
// Need to special case the "-0" case to format as 0 instead of -0.
return platform.formatNumber(n === -0 ? 0 : n, stateObject, /* toParts */ false, /* forNumberPrototypeToLocaleString */ true);
return platform.formatNumber(n, stateObject, /* toParts */ false, /* forNumberPrototypeToLocaleString */ true);
}), IntlBuiltInFunctionID.NumberToLocaleString);

if (InitType === "Number") {
Expand Down Expand Up @@ -1266,8 +1269,7 @@
platform.raiseNeedObjectOfType("NumberFormat.prototype.format", "NumberFormat");
}

// Need to special case the '-0' case to format as 0 instead of -0.
return platform.formatNumber(n === -0 ? 0 : n, hiddenObject, /* toParts */ false, /* forNumberPrototypeToLocaleString */ false);
return platform.formatNumber(n, hiddenObject, /* toParts */ false, /* forNumberPrototypeToLocaleString */ false);
});

const formatToParts = tagPublicFunction("Intl.NumberFormat.prototype.formatToParts", function formatToParts(n) {
Expand All @@ -1282,8 +1284,7 @@
platform.raiseNeedObjectOfType("NumberFormat.prototype.formatToParts", "NumberFormat");
}

// Need to special case the '-0' case to format as 0 instead of -0.
return platform.formatNumber(n === -0 ? 0 : n, hiddenObject, /* toParts */ true, /* forNumberPrototypeToLocaleString */ false);
return platform.formatNumber(n, hiddenObject, /* toParts */ true, /* forNumberPrototypeToLocaleString */ false);
});

// See explanation of `getCanonicalLocales`
Expand Down Expand Up @@ -1933,8 +1934,8 @@
resolved.hourCycle = hc;
resolved.hour12 = hc === "h11" || hc === "h12";
}
} else if (hiddenObject[prop] !== undefined && hiddenObject[prop] !== null) {
resolved[prop] = hiddenObject[prop];

return true;
}
});
},
Expand Down Expand Up @@ -2096,8 +2097,7 @@
if (prop === "pluralCategories") {
// https://github.com/tc39/ecma402/issues/224: create a copy of the pluralCategories array
resolved.pluralCategories = _.slice(pr.pluralCategories, 0);
} else {
resolved[prop] = pr[prop];
return true;
}
});
};
Expand Down Expand Up @@ -3181,8 +3181,7 @@
InitializeNumberFormat(stateObject, arguments[0], arguments[1]);

var n = Internal.ToNumber(this);
// Need to special case the '-0' case to format as 0 instead of -0.
return String(platform.formatNumber(n === -0 ? 0 : n, stateObject));
return String(platform.formatNumber(n, stateObject));
}), IntlBuiltInFunctionID.NumberToLocaleString);

if (InitType === 'Intl') {
Expand Down Expand Up @@ -3226,8 +3225,7 @@
platform.raiseNeedObjectOfType("NumberFormat.prototype.format", "NumberFormat");
}

// Need to special case the '-0' case to format as 0 instead of -0.
return String(platform.formatNumber(n === -0 ? 0 : n, hiddenObject));
return String(platform.formatNumber(n, hiddenObject));
}
tagPublicFunction("Intl.NumberFormat.prototype.format", format);

Expand Down
Loading

0 comments on commit 5b6d604

Please sign in to comment.