From 520b772bc8fe8b4521f4ac8491fd2092f1d9fda0 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Fri, 26 May 2023 20:24:29 +0200 Subject: [PATCH] fix #112 and differentiate between textContent and innerText --- public/scripts/ui.js | 4 ++-- public/scripts/util.js | 2 +- public_included_ws_fallback/scripts/ui.js | 4 ++-- public_included_ws_fallback/scripts/util.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 673726d..bfbca32 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -1419,7 +1419,7 @@ class ReceiveTextDialog extends Dialog { } async _onCopy() { - await navigator.clipboard.writeText(this.$text.textContent); + await navigator.clipboard.writeText(this.$text.innerText); Events.fire('notify-user', 'Copied to clipboard'); this.hide(); } @@ -1594,7 +1594,7 @@ class Toast extends Dialog { _onNotify(message) { if (this.hideTimeout) clearTimeout(this.hideTimeout); - this.$el.textContent = message; + this.$el.innerText = message; this.show(); this.hideTimeout = setTimeout(_ => this.hide(), 5000); } diff --git a/public/scripts/util.js b/public/scripts/util.js index bae1e39..f6156f8 100644 --- a/public/scripts/util.js +++ b/public/scripts/util.js @@ -5,7 +5,7 @@ if (!navigator.clipboard) { // A contains the text to copy const span = document.createElement('span'); - span.textContent = text; + span.innerText = text; span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines // Paint the span outside the viewport diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index 4f2229b..971fe21 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -1420,7 +1420,7 @@ class ReceiveTextDialog extends Dialog { } async _onCopy() { - await navigator.clipboard.writeText(this.$text.textContent); + await navigator.clipboard.writeText(this.$text.innerText); Events.fire('notify-user', 'Copied to clipboard'); this.hide(); } @@ -1595,7 +1595,7 @@ class Toast extends Dialog { _onNotify(message) { if (this.hideTimeout) clearTimeout(this.hideTimeout); - this.$el.textContent = message; + this.$el.innerText = message; this.show(); this.hideTimeout = setTimeout(_ => this.hide(), 5000); } diff --git a/public_included_ws_fallback/scripts/util.js b/public_included_ws_fallback/scripts/util.js index e0cbf24..9b7548c 100644 --- a/public_included_ws_fallback/scripts/util.js +++ b/public_included_ws_fallback/scripts/util.js @@ -5,7 +5,7 @@ if (!navigator.clipboard) { // A contains the text to copy const span = document.createElement('span'); - span.textContent = text; + span.innerText = text; span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines // Paint the span outside the viewport