Add String.prototype.includes polyfill
Summary: Add a polyfill for `String.prototype.includes` taken from MDN (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes) See https://github.com/facebook/react-native/issues/5727 Closes https://github.com/facebook/react-native/pull/5735 Reviewed By: svcscm Differential Revision: D2906667 Pulled By: vjeux fb-gh-sync-id: e02f605bf57171062b29a98b98ba9fc898cedfc2
This commit is contained in:
parent
d2ab6cabd4
commit
2f73ad0241
|
@ -83,3 +83,18 @@ if (!String.prototype.repeat) {
|
|||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue