diff --git a/index.js b/index.js index 3e88157..0e4bda8 100755 --- a/index.js +++ b/index.js @@ -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);