Skip to content

Commit

Permalink
feat(Object.isType): accept multiple type (#7715)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Feb 20, 2022
1 parent 4e80e77 commit fd1b0c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

/**
Expand Down
2 changes: 2 additions & 0 deletions test/unit/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fd1b0c3

Please sign in to comment.