From fd1b0c33f36420f343a5e917a64763a7c7b4c323 Mon Sep 17 00:00:00 2001 From: Shachar <34343793+ShaMan123@users.noreply.github.com> Date: Sun, 20 Feb 2022 17:18:19 +0200 Subject: [PATCH] feat(Object.isType): accept multiple `type` (#7715) --- src/shapes/object.class.js | 2 +- test/unit/object.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 633ead8386e..50bbf3f7409 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1777,7 +1777,7 @@ * @return {Boolean} */ isType: function(type) { - return this.type === type; + return arguments.length > 1 ? Array.from(arguments).includes(this.type) : this.type === type; }, /** diff --git a/test/unit/object.js b/test/unit/object.js index ec67dbe3d38..855b64f9d55 100644 --- a/test/unit/object.js +++ b/test/unit/object.js @@ -494,6 +494,8 @@ cObj = new fabric.Rect(); assert.ok(cObj.isType('rect')); assert.ok(!cObj.isType('object')); + assert.ok(cObj.isType('object', 'rect')); + assert.ok(!cObj.isType('object', 'circle')); }); QUnit.test('toggle', function(assert) {