diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index e7a90d4218..406708f976 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -3571,6 +3571,7 @@ class Vector { 'The v1 parameter should be of type Array or p5.Vector', 'p5.Vector.equals' ); + return false; } return v.equals(v2); } @@ -3660,6 +3661,11 @@ function vector(p5, fn) { return p5.disableFriendlyErrors; }; + Vector._friendlyError = p5._friendlyError; + Vector.friendlyErrorsDisabled = function() { + return p5.disableFriendlyErrors; + }; + /** * The x component of the vector * @type {Number} diff --git a/test/unit/math/p5.Vector.js b/test/unit/math/p5.Vector.js index df694d71a6..c867772da4 100644 --- a/test/unit/math/p5.Vector.js +++ b/test/unit/math/p5.Vector.js @@ -2189,4 +2189,12 @@ suite('p5.Vector', function () { ]); }); }); + + suite('p5.Vector.equals() [CLASS]', function () { + it('should trigger friendly error if first parameter is not a vector or array', function () { + FESCalled = false; + Vector.equals(1, new Vector(1, 2)); + assert.isTrue(FESCalled, 'Friendly error should have been triggered'); + }); + }); });