copy to clipboard in IE (#19281)

This commit is contained in:
Nathan Reese 2018-05-22 14:51:50 -06:00 committed by GitHub
parent 51592c652a
commit 1f6f662c08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,12 +20,12 @@ function createHiddenTextElement(text) {
export function copyToClipboard(text) {
let isCopied = true;
const range = document.createRange();
const selection = document.getSelection();
const selection = window.getSelection();
const elementToBeCopied = createHiddenTextElement(text);
document.body.appendChild(elementToBeCopied);
range.selectNode(elementToBeCopied);
selection.empty();
selection.removeAllRanges();
selection.addRange(range);
if (!document.execCommand('copy')) {