| Línea 99... |
Línea 99... |
| 99 |
}
|
99 |
}
|
| 100 |
} else {
|
100 |
} else {
|
| 101 |
// This copyTarget is not an input, or text area so cannot be used with the execCommand('copy') command.
|
101 |
// This copyTarget is not an input, or text area so cannot be used with the execCommand('copy') command.
|
| 102 |
// To work around this we create a new textarea and copy that.
|
102 |
// To work around this we create a new textarea and copy that.
|
| 103 |
// This textarea must be part of the DOM and must be visible.
|
103 |
// This textarea must be part of the DOM and must be visible.
|
| 104 |
// We (ab)use the sr-only tag to ensure that it is considered visible to the browser, whilst being
|
104 |
// We (ab)use the visually-hidden tag to ensure that it is considered visible to the browser, whilst being
|
| 105 |
// hidden from view by the user.
|
105 |
// hidden from view by the user.
|
| 106 |
const copyRegion = document.createElement('textarea');
|
106 |
const copyRegion = document.createElement('textarea');
|
| 107 |
copyRegion.value = textToCopy;
|
107 |
copyRegion.value = textToCopy;
|
| 108 |
copyRegion.classList.add('sr-only');
|
108 |
copyRegion.classList.add('visually-hidden');
|
| 109 |
document.body.appendChild(copyRegion);
|
109 |
document.body.appendChild(copyRegion);
|
| Línea 110... |
Línea 110... |
| 110 |
|
110 |
|
| Línea 111... |
Línea 111... |
| 111 |
copyNodeContentToClipboard(copyButton, copyRegion);
|
111 |
copyNodeContentToClipboard(copyButton, copyRegion);
|