Skip to content

Commit

Permalink
Fix "isSupported" behavior - Closes zenorocha#666
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Mar 5, 2020
1 parent 2893893 commit e430d05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class Clipboard extends Emitter {
*/
static isSupported(action = ['copy', 'cut']) {
const actions = (typeof action === 'string') ? [action] : action;
let support = !document.queryCommandSupported;
let support = !!document.queryCommandSupported;

actions.forEach((action) => {
support = support && !document.queryCommandSupported(action);
support = support && !!document.queryCommandSupported(action);
});

return support;
Expand Down
6 changes: 3 additions & 3 deletions test/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ describe('Clipboard', () => {

describe('#static isSupported', () => {
it('should return the support of the given action', () => {
assert.equal(Clipboard.isSupported('copy'), false);
assert.equal(Clipboard.isSupported('cut'), false);
assert.equal(Clipboard.isSupported('copy'), true);
assert.equal(Clipboard.isSupported('cut'), true);
});

it('should return the support of the cut and copy actions', () => {
assert.equal(Clipboard.isSupported(), false);
assert.equal(Clipboard.isSupported(), true);
});
});

Expand Down

0 comments on commit e430d05

Please sign in to comment.