Fix "isSupported" behavior - Closes #666

This commit is contained in:
Zeno Rocha
2020-03-04 22:24:24 -08:00
parent 289389322e
commit e430d056ad
2 changed files with 5 additions and 5 deletions

View File

@@ -86,10 +86,10 @@ class Clipboard extends Emitter {
*/ */
static isSupported(action = ['copy', 'cut']) { static isSupported(action = ['copy', 'cut']) {
const actions = (typeof action === 'string') ? [action] : action; const actions = (typeof action === 'string') ? [action] : action;
let support = !document.queryCommandSupported; let support = !!document.queryCommandSupported;
actions.forEach((action) => { actions.forEach((action) => {
support = support && !document.queryCommandSupported(action); support = support && !!document.queryCommandSupported(action);
}); });
return support; return support;

View File

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