summaryrefslogtreecommitdiff
path: root/js/src/jsstr.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-07 13:21:06 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-07 13:26:01 +0200
commit240f52db8e97c9c65592771ddffb6efbdd210c15 (patch)
treec45e426238784ed96f7f6a3583e865fd4d048fe8 /js/src/jsstr.cpp
parentc8f1b9fc6c1c86674148b5875c1eb27335899b35 (diff)
downloaduxp-240f52db8e97c9c65592771ddffb6efbdd210c15.tar.gz
Reinstate string.prototype.contains()
This adds a compatibility function aliased to string.prototype.includes().
Diffstat (limited to 'js/src/jsstr.cpp')
-rw-r--r--js/src/jsstr.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp
index 01b4076262..4151d012b6 100644
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -1534,7 +1534,7 @@ RopeMatch(JSContext* cx, JSRope* text, JSLinearString* pat, int* match)
return true;
}
-/* ES6 draft rc4 21.1.3.7. */
+/* ES6 2015 ST 21.1.3.7 String.prototype.includes */
bool
js::str_includes(JSContext* cx, unsigned argc, Value* vp)
{
@@ -1591,6 +1591,13 @@ js::str_includes(JSContext* cx, unsigned argc, Value* vp)
return true;
}
+/* ES6 draft <RC4 String.prototype.contains for compatibility */
+bool
+js::str_contains(JSContext* cx, unsigned argc, Value* vp)
+{
+ return js::str_includes(cx, argc, vp);
+}
+
/* ES6 20120927 draft 15.5.4.7. */
bool
js::str_indexOf(JSContext* cx, unsigned argc, Value* vp)
@@ -2555,6 +2562,7 @@ static const JSFunctionSpec string_methods[] = {
JS_SELF_HOSTED_FN("padEnd", "String_pad_end", 2,0),
JS_SELF_HOSTED_FN("codePointAt", "String_codePointAt", 1,0),
JS_FN("includes", str_includes, 1,0),
+ JS_FN("contains", str_contains, 1,0),
JS_FN("indexOf", str_indexOf, 1,0),
JS_FN("lastIndexOf", str_lastIndexOf, 1,0),
JS_FN("startsWith", str_startsWith, 1,0),