From b1fa8c098b6e672e16023b256326c62e7d264140 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Wed, 27 Dec 2017 17:47:13 +0800 Subject: [PATCH] refactor(common): refactor polyfill of String.prototype.includes --- resources/assets/src/js/common/polyfill.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/resources/assets/src/js/common/polyfill.js b/resources/assets/src/js/common/polyfill.js index 95695b03..5e0c6773 100644 --- a/resources/assets/src/js/common/polyfill.js +++ b/resources/assets/src/js/common/polyfill.js @@ -2,17 +2,9 @@ // polyfill of String.prototype.includes if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - 'use strict'; - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > this.length) { - return false; - } else { - return this.indexOf(search, start) !== -1; - } + String.prototype.includes = function(search) { + // Copied from core-js + return !!~this.indexOf(search, arguments.length > 1 ? arguments[1] : undefined); }; }