mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-20 22:27:31 +09:00
Implement String.prototype.trimStart and trimEnd.
This renames our internal function names because *Left and *Right might be deprecated and have to be removed later, making that trivial. Resolves #1089
This commit is contained in:
parent
7dacd442cf
commit
dee48511aa
4 changed files with 22 additions and 16 deletions
|
|
@ -828,16 +828,16 @@ function String_static_trim(string) {
|
||||||
return callFunction(std_String_trim, string);
|
return callFunction(std_String_trim, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function String_static_trimLeft(string) {
|
function String_static_trimStart(string) {
|
||||||
if (arguments.length < 1)
|
if (arguments.length < 1)
|
||||||
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, 'String.trimLeft');
|
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, 'String.trimStart');
|
||||||
return callFunction(std_String_trimLeft, string);
|
return callFunction(std_String_trimStart, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function String_static_trimRight(string) {
|
function String_static_trimEnd(string) {
|
||||||
if (arguments.length < 1)
|
if (arguments.length < 1)
|
||||||
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, 'String.trimRight');
|
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, 'String.trimEnd');
|
||||||
return callFunction(std_String_trimRight, string);
|
return callFunction(std_String_trimEnd, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function String_static_toLocaleLowerCase(string) {
|
function String_static_toLocaleLowerCase(string) {
|
||||||
|
|
|
||||||
|
|
@ -1970,14 +1970,14 @@ js::str_trim(JSContext* cx, unsigned argc, Value* vp)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
js::str_trimLeft(JSContext* cx, unsigned argc, Value* vp)
|
js::str_trimStart(JSContext* cx, unsigned argc, Value* vp)
|
||||||
{
|
{
|
||||||
CallArgs args = CallArgsFromVp(argc, vp);
|
CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
return TrimString(cx, args, true, false);
|
return TrimString(cx, args, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
js::str_trimRight(JSContext* cx, unsigned argc, Value* vp)
|
js::str_trimEnd(JSContext* cx, unsigned argc, Value* vp)
|
||||||
{
|
{
|
||||||
CallArgs args = CallArgsFromVp(argc, vp);
|
CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
return TrimString(cx, args, false, true);
|
return TrimString(cx, args, false, true);
|
||||||
|
|
@ -2568,8 +2568,10 @@ static const JSFunctionSpec string_methods[] = {
|
||||||
JS_FN("startsWith", str_startsWith, 1,0),
|
JS_FN("startsWith", str_startsWith, 1,0),
|
||||||
JS_FN("endsWith", str_endsWith, 1,0),
|
JS_FN("endsWith", str_endsWith, 1,0),
|
||||||
JS_FN("trim", str_trim, 0,0),
|
JS_FN("trim", str_trim, 0,0),
|
||||||
JS_FN("trimLeft", str_trimLeft, 0,0),
|
JS_FN("trimLeft", str_trimStart, 0,0),
|
||||||
JS_FN("trimRight", str_trimRight, 0,0),
|
JS_FN("trimStart", str_trimStart, 0,0),
|
||||||
|
JS_FN("trimRight", str_trimEnd, 0,0),
|
||||||
|
JS_FN("trimEnd", str_trimEnd, 0,0),
|
||||||
JS_FN("toLocaleLowerCase", str_toLocaleLowerCase, 0,0),
|
JS_FN("toLocaleLowerCase", str_toLocaleLowerCase, 0,0),
|
||||||
JS_FN("toLocaleUpperCase", str_toLocaleUpperCase, 0,0),
|
JS_FN("toLocaleUpperCase", str_toLocaleUpperCase, 0,0),
|
||||||
JS_SELF_HOSTED_FN("localeCompare", "String_localeCompare", 1,0),
|
JS_SELF_HOSTED_FN("localeCompare", "String_localeCompare", 1,0),
|
||||||
|
|
@ -2881,8 +2883,10 @@ static const JSFunctionSpec string_static_methods[] = {
|
||||||
JS_SELF_HOSTED_FN("startsWith", "String_static_startsWith", 2,0),
|
JS_SELF_HOSTED_FN("startsWith", "String_static_startsWith", 2,0),
|
||||||
JS_SELF_HOSTED_FN("endsWith", "String_static_endsWith", 2,0),
|
JS_SELF_HOSTED_FN("endsWith", "String_static_endsWith", 2,0),
|
||||||
JS_SELF_HOSTED_FN("trim", "String_static_trim", 1,0),
|
JS_SELF_HOSTED_FN("trim", "String_static_trim", 1,0),
|
||||||
JS_SELF_HOSTED_FN("trimLeft", "String_static_trimLeft", 1,0),
|
JS_SELF_HOSTED_FN("trimLeft", "String_static_trimStart", 1,0),
|
||||||
JS_SELF_HOSTED_FN("trimRight", "String_static_trimRight", 1,0),
|
JS_SELF_HOSTED_FN("trimStart", "String_static_trimStart", 1,0),
|
||||||
|
JS_SELF_HOSTED_FN("trimRight", "String_static_trimEnd", 1,0),
|
||||||
|
JS_SELF_HOSTED_FN("trimEnd", "String_static_trimEnd", 1,0),
|
||||||
JS_SELF_HOSTED_FN("toLocaleLowerCase","String_static_toLocaleLowerCase",1,0),
|
JS_SELF_HOSTED_FN("toLocaleLowerCase","String_static_toLocaleLowerCase",1,0),
|
||||||
JS_SELF_HOSTED_FN("toLocaleUpperCase","String_static_toLocaleUpperCase",1,0),
|
JS_SELF_HOSTED_FN("toLocaleUpperCase","String_static_toLocaleUpperCase",1,0),
|
||||||
JS_SELF_HOSTED_FN("normalize", "String_static_normalize", 1,0),
|
JS_SELF_HOSTED_FN("normalize", "String_static_normalize", 1,0),
|
||||||
|
|
|
||||||
|
|
@ -367,10 +367,10 @@ extern bool
|
||||||
str_trim(JSContext* cx, unsigned argc, Value* vp);
|
str_trim(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
str_trimLeft(JSContext* cx, unsigned argc, Value* vp);
|
str_trimStart(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
str_trimRight(JSContext* cx, unsigned argc, Value* vp);
|
str_trimEnd(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
str_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp);
|
str_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
|
||||||
|
|
@ -2200,8 +2200,10 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||||
JS_INLINABLE_FN("std_String_charAt", str_charAt, 1,0, StringCharAt),
|
JS_INLINABLE_FN("std_String_charAt", str_charAt, 1,0, StringCharAt),
|
||||||
JS_FN("std_String_endsWith", str_endsWith, 1,0),
|
JS_FN("std_String_endsWith", str_endsWith, 1,0),
|
||||||
JS_FN("std_String_trim", str_trim, 0,0),
|
JS_FN("std_String_trim", str_trim, 0,0),
|
||||||
JS_FN("std_String_trimLeft", str_trimLeft, 0,0),
|
JS_FN("std_String_trimLeft", str_trimStart, 0,0),
|
||||||
JS_FN("std_String_trimRight", str_trimRight, 0,0),
|
JS_FN("std_String_trimStart", str_trimStart, 0,0),
|
||||||
|
JS_FN("std_String_trimRight", str_trimEnd, 0,0),
|
||||||
|
JS_FN("std_String_trimEnd", str_trimEnd, 0,0),
|
||||||
JS_FN("std_String_toLocaleLowerCase", str_toLocaleLowerCase, 0,0),
|
JS_FN("std_String_toLocaleLowerCase", str_toLocaleLowerCase, 0,0),
|
||||||
JS_FN("std_String_toLocaleUpperCase", str_toLocaleUpperCase, 0,0),
|
JS_FN("std_String_toLocaleUpperCase", str_toLocaleUpperCase, 0,0),
|
||||||
JS_FN("std_String_normalize", str_normalize, 0,0),
|
JS_FN("std_String_normalize", str_normalize, 0,0),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue