+ // minimise styling in case it is (briefly) rendered
+ textArea.style.position = 'fixed';
+ textArea.style.top = 0;
+ textArea.style.left = 0;
+ textArea.style.width = '2em';
+ textArea.style.height = '2em';
+ textArea.style.padding = 0;
+ textArea.style.border = 'none';
+ textArea.style.outline = 'none';
+ textArea.style.boxShadow = 'none';
+ textArea.style.background = 'transparent';
+
+ // temporarily add input field to copy text from
+ textArea.value = val;
+ document.body.appendChild(textArea);