From 2302e02e939d1d3460851e086e31a63d9fd16edc Mon Sep 17 00:00:00 2001 From: Jason Westbrook Date: Fri, 12 Jul 2013 15:18:23 -0700 Subject: [PATCH] include perf boost as well as ECMA6 detect for include or contains --- src/prototype/lang/string.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/prototype/lang/string.js b/src/prototype/lang/string.js index 1e0277ca4..cd02b3e04 100644 --- a/src/prototype/lang/string.js +++ b/src/prototype/lang/string.js @@ -769,7 +769,7 @@ Object.extend(String.prototype, (function() { * //-> false **/ function include(pattern) { - return this.indexOf(pattern) > -1; + return this.indexOf(pattern) !== -1; } /** @@ -910,7 +910,8 @@ Object.extend(String.prototype, (function() { unfilterJSON: unfilterJSON, isJSON: isJSON, evalJSON: NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON, - include: include, + //ECMA 6 supports contains(), if it exists map include() to contains() + include: String.prototype.contains || include, // Firefox 18+ supports String.prototype.startsWith, String.prototype.endsWith startsWith: String.prototype.startsWith || startsWith, endsWith: String.prototype.endsWith || endsWith,