diff --git a/src/clipboard-copy-element.js b/src/clipboard-copy-element.js index aebdcc8..c8f6920 100644 --- a/src/clipboard-copy-element.js +++ b/src/clipboard-copy-element.js @@ -1,6 +1,6 @@ /* @flow strict */ -import {copyInput, copyNode, copyText} from './clipboard' +import {copyNode, copyText} from './clipboard' function copy(button: HTMLElement) { const id = button.getAttribute('for') @@ -22,11 +22,7 @@ function copy(button: HTMLElement) { function copyTarget(content: Element) { if (content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement) { - if (content.type === 'hidden') { - return copyText(content.value) - } else { - return copyInput(content) - } + return copyText(content.value) } else if (content instanceof HTMLAnchorElement && content.hasAttribute('href')) { return copyText(content.href) } else { diff --git a/src/clipboard.js b/src/clipboard.js index bbaf6b9..add7520 100644 --- a/src/clipboard.js +++ b/src/clipboard.js @@ -51,19 +51,3 @@ export function copyText(text: string): Promise { body.removeChild(node) return Promise.resolve() } - -export function copyInput(node: HTMLInputElement | HTMLTextAreaElement): Promise { - if ('clipboard' in navigator) { - // eslint-disable-next-line flowtype/no-flow-fix-me-comments - // $FlowFixMe Clipboard is not defined in Flow yet. - return navigator.clipboard.writeText(node.value) - } - - node.select() - document.execCommand('copy') - const selection = getSelection() - if (selection != null) { - selection.removeAllRanges() - } - return Promise.resolve() -}