[fix] cache Clipboard.isAvailable() value

Fix #1149
Close #1150
This commit is contained in:
Charlie Croom
2018-10-22 13:45:52 -07:00
committed by Nicolas Gallagher
parent 5033e12d18
commit 5855e55615

View File

@@ -8,11 +8,16 @@
* @flow
*/
let clipboardAvailable;
export default class Clipboard {
static isAvailable() {
return (
typeof document.queryCommandSupported === 'function' && document.queryCommandSupported('copy')
);
if (clipboardAvailable === undefined) {
clipboardAvailable =
typeof document.queryCommandSupported === 'function' &&
document.queryCommandSupported('copy');
}
return clipboardAvailable;
}
static getString(): Promise<string> {