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

Unified Diff: src/js/string.js

Issue 2335553002: Revert of [builtins] Move StringNormalize to a cpp builtin. (Closed)
Patch Set: Created 4 years, 3 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 | « src/builtins/builtins-string.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/string.js
diff --git a/src/js/string.js b/src/js/string.js
index 00fee68ac9fc6d02598c212d89f9af54d135b84a..38caab7b125d1adbe25957d474250faa46eb6f59 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -116,6 +116,30 @@
RegExpInitialize(regexp, pattern);
return regexp[matchSymbol](subject);
}
+
+
+// ECMA-262 v6, section 21.1.3.12
+//
+// For now we do nothing, as proper normalization requires big tables.
+// If Intl is enabled, then i18n.js will override it and provide the the
+// proper functionality.
+function StringNormalize(formArg) { // length == 0
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
+ var s = TO_STRING(this);
+
+ var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg);
+
+ var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
+ var normalizationForm = %ArrayIndexOf(NORMALIZATION_FORMS, form, 0);
+ if (normalizationForm === -1) {
+ throw %make_range_error(kNormalizationForm,
+ %_Call(ArrayJoin, NORMALIZATION_FORMS, ', '));
+ }
+
+ return s;
+}
+
+%FunctionSetLength(StringNormalize, 0);
// This has the same size as the RegExpLastMatchInfo array, and can be used
@@ -716,6 +740,7 @@
"lastIndexOf", StringLastIndexOf,
"localeCompare", StringLocaleCompareJS,
"match", StringMatchJS,
+ "normalize", StringNormalize,
"repeat", StringRepeat,
"replace", StringReplace,
"search", StringSearch,
« no previous file with comments | « src/builtins/builtins-string.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698