Add isSupported method #355

This commit is contained in:
Itai Steinherz
2017-02-08 09:36:29 +02:00
committed by Zeno Rocha
parent 402c9ee17b
commit 63d1b0f014
4 changed files with 42 additions and 1 deletions

View File

@@ -77,6 +77,22 @@ class Clipboard extends Emitter {
}
}
/**
* Returns the support of the given action, or all actions if no action is
* given.
* @param {String} [action]
*/
static isSupported(action = ['copy', 'cut']) {
const actions = (typeof action === 'string') ? [action] : action;
let support = !!document.queryCommandSupported;
actions.forEach((action) => {
support = support && !!document.queryCommandSupported(action);
});
return support;
}
/**
* Default `text` lookup function.
* @param {Element} trigger