From 5a00d0a32f4d5a44144b0fe0136d8113cb10c090 Mon Sep 17 00:00:00 2001 From: morning-star Date: Sun, 3 Sep 2023 08:20:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20lay.clipboard.writeTex?= =?UTF-8?q?t=20IE8=20=E4=B8=8B=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 lay.clipboard.writeText IE8 下报错的问题,catch 是保留字 --- src/modules/lay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/lay.js b/src/modules/lay.js index 99963200..a42e59ce 100644 --- a/src/modules/lay.js +++ b/src/modules/lay.js @@ -318,7 +318,7 @@ try { navigator.clipboard.writeText(text).then( options.done - ).catch(options.error); + ).['catch'](options.error); } catch(e) { var elem = document.createElement('textarea'); From cc9cdeb03e99d7f6e19e30b6d653cdc2750fdb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 3 Sep 2023 12:14:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=20ie8=20`.remove()`=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=92=8C=E5=A4=8D=E5=88=B6=E6=97=B6=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E7=BD=AE=E5=BA=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/lay.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/lay.js b/src/modules/lay.js index a42e59ce..21d0b6a1 100644 --- a/src/modules/lay.js +++ b/src/modules/lay.js @@ -318,13 +318,16 @@ try { navigator.clipboard.writeText(text).then( options.done - ).['catch'](options.error); + )['catch'](options.error); } catch(e) { var elem = document.createElement('textarea'); elem.value = text; - elem.style.position = 'absolute'; + elem.style.position = 'fixed'; elem.style.opacity = '0'; + elem.style.top = '0px'; + elem.style.left = '0px'; + document.body.appendChild(elem); elem.select(); @@ -333,9 +336,9 @@ typeof options.done === 'function' && options.done(); } catch(err) { typeof options.error === 'function' && options.error(err); + } finally { + elem.remove ? elem.remove() : document.body.removeChild(elem); } - - elem.remove(); } } };