mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Fix "isSupported" behavior - Closes #666
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user