forked from mirrors/gecko-dev
MozReview-Commit-ID: DICbgINxnoa --HG-- extra : rebase_source : 065193b99216d68cf7f3ab3a41944f3d2a0836eb
23 lines
471 B
JavaScript
23 lines
471 B
JavaScript
/* globals catcher */
|
|
|
|
"use strict";
|
|
|
|
this.clipboard = (function() {
|
|
let exports = {};
|
|
|
|
exports.copy = function(text) {
|
|
let el = document.createElement("textarea");
|
|
document.body.appendChild(el);
|
|
el.value = text;
|
|
el.select();
|
|
const copied = document.execCommand("copy");
|
|
document.body.removeChild(el);
|
|
if (!copied) {
|
|
catcher.unhandled(new Error("Clipboard copy failed"));
|
|
}
|
|
return copied;
|
|
};
|
|
|
|
return exports;
|
|
})();
|
|
null;
|