This is imported from https://github.com/mozilla-services/screenshots/. It has been reviewed as patches landed, but also reviewed by Mossop and kmag. This also includes the patch from bug 1356394 MozReview-Commit-ID: FXIVw7WjxlN
24 lines
473 B
JavaScript
24 lines
473 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;
|