diff --git a/implementation.js b/implementation.js index 30f31f4..ee2e989 100644 --- a/implementation.js +++ b/implementation.js @@ -4,21 +4,14 @@ var ToIntegerOrInfinity = require('es-abstract/2025/ToIntegerOrInfinity'); var ToLength = require('es-abstract/2025/ToLength'); var ToObject = require('es-object-atoms/ToObject'); var SameValueZero = require('es-abstract/2025/SameValueZero'); -var $isNaN = require('math-intrinsics/isNaN'); -var $isFinite = require('math-intrinsics/isFinite'); var $max = require('math-intrinsics/max'); -var GetIntrinsic = require('get-intrinsic'); var callBound = require('call-bound'); var isString = require('is-string'); var $charAt = callBound('String.prototype.charAt'); -var $indexOf = GetIntrinsic('%Array.prototype.indexOf%'); // TODO: use callBind.apply without breaking IE 8 module.exports = function includes(searchElement) { var fromIndex = arguments.length > 1 ? ToIntegerOrInfinity(arguments[1]) : 0; - if ($indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') { - return $indexOf.apply(this, arguments) > -1; - } var O = ToObject(this); var length = ToLength(O.length); diff --git a/package.json b/package.json index 0dff956..51da415 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "define-properties": "^1.2.1", "es-abstract": "^1.24.2", "es-object-atoms": "^1.1.2", - "get-intrinsic": "^1.3.0", "is-string": "^1.1.1", "math-intrinsics": "^1.1.0" }, diff --git a/test/tests.js b/test/tests.js index 78979d4..994b5c9 100644 --- a/test/tests.js +++ b/test/tests.js @@ -91,4 +91,24 @@ module.exports = function (includes, t) { st.end(); }); + + t.test( + 'exotic objects: uses Get, not HasProperty, unlike indexOf', + { skip: typeof Proxy !== 'function' }, + function (st) { + var target = [1, 2, 3, 4, 5]; + var proxy = new Proxy(target, { + has: function () { return false; }, + get: function (targ, k, r) { return Reflect.get(targ, k, r); } + }); + + st.equal( + true, + includes(proxy, 3), + 'a lying `has` trap does not stop an element visible via `get` from being found' + ); + + st.end(); + } + ); };