Skip to content

Commit

Permalink
Merge pull request #48 from pugnascotia/master
Browse files Browse the repository at this point in the history
Set span styling via individual style properties
  • Loading branch information
sudodoki authored Apr 23, 2017
2 parents 3e06d9c + 29b7dcb commit efb9ce7
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@ function copy(text, options) {

mark = document.createElement('span');
mark.textContent = text;
mark.setAttribute('style', [
// reset user styles for span element
'all: unset',
// prevents scrolling to the end of the page
'position: fixed',
'top: 0',
'clip: rect(0, 0, 0, 0)',
// used to preserve spaces and line breaks
'white-space: pre',
// do not inherit user-select (it may be `none`)
'-webkit-user-select: text',
'-moz-user-select: text',
'-ms-user-select: text',
'user-select: text',
].join(';'));
// reset user styles for span element
mark.style.all = 'unset';
// prevents scrolling to the end of the page
mark.style.position = 'fixed';
mark.style.top = 0;
mark.style.clip = 'rect(0, 0, 0, 0)';
// used to preserve spaces and line breaks
mark.style.whiteSpace = 'pre';
// do not inherit user-select (it may be `none`)
mark.style.webkitUserSelect = 'text';
mark.style.MozUserSelect = 'text';
mark.style.msUserSelect = 'text';
mark.style.userSelect = 'text';

document.body.appendChild(mark);

Expand Down

0 comments on commit efb9ce7

Please sign in to comment.