Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: src/i18n.js

Issue 1274653002: Ensure `String.prototype.normalize.length` is `0` (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/i18n.js
diff --git a/src/i18n.js b/src/i18n.js
index 1028bbb07b3d70706290848f14110d4bee8d7dd5..194080bce555b04bf4ce8b3970c6d747ea75d8f2 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -1995,27 +1995,29 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
* If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw
* a RangeError Exception.
*/
-OverrideFunction(GlobalString.prototype, 'normalize', function(form) {
- if (%_IsConstructCall()) {
- throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
- }
- CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
+function StringNormalizeJS(form) {
+ if (%_IsConstructCall()) {
+ throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
+ }
- form = IS_UNDEFINED(form) ? 'NFC' : form;
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
- var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
+ form = IS_UNDEFINED(form) ? 'NFC' : form;
- var normalizationForm =
- %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf);
- if (normalizationForm === -1) {
- throw MakeRangeError(kNormalizationForm,
- %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin));
- }
+ var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
- return %StringNormalize(this, normalizationForm);
+ var normalizationForm =
+ %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf);
+ if (normalizationForm === -1) {
+ throw MakeRangeError(kNormalizationForm,
+ %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin));
}
-);
+
+ return %StringNormalize(this, normalizationForm);
+}
+%FunctionSetLength(StringNormalizeJS, 0);
rossberg 2015/08/05 14:23:05 I'd prefer avoiding the runtime call and instead d
mathias 2015/08/05 14:28:11 Done.
+OverrideFunction(GlobalString.prototype, 'normalize', StringNormalizeJS);
/**
« no previous file with comments | « no previous file | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698