Skip to content

Commit aa2cec3

Browse files
committed
🚿 map String.prototype.contains to String.include() (prototypejs#105)
1 parent cf0e825 commit aa2cec3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/prototype/lang/string.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ Object.extend(String.prototype, (function(){
799799
* //-> false
800800
**/
801801
function include(pattern){
802-
return this.indexOf(pattern) > -1;
802+
return this.indexOf(pattern) !== -1;
803803
}
804804

805805
/**
@@ -945,7 +945,8 @@ Object.extend(String.prototype, (function(){
945945
unfilterJSON : unfilterJSON,
946946
isJSON : isJSON,
947947
evalJSON : evalJSON,
948-
include : include,
948+
//ECMA 6 supports contains(), if it exists map include() to contains()
949+
include : String.prototype.contains || include,
949950
// Firefox 18+ supports String.prototype.startsWith, String.prototype.endsWith
950951
startsWith : String.prototype.startsWith || startsWith,
951952
endsWith : String.prototype.endsWith || endsWith,

0 commit comments

Comments
 (0)