From ecda2536ec41b3bb6c6ac99ba1115619986d90ea Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 7 Dec 2022 22:27:22 +0200 Subject: [PATCH] use insertAdjacentHTML --- files/assets/js/comments_v.js | 6 +++--- files/assets/js/emoji_modal.js | 3 ++- files/assets/js/gif_modal.js | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 19c16515b..1635b6a69 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -132,8 +132,8 @@ function post_reply(id){ if (data && data["comment"]) { const comments = document.getElementById('replies-of-c_' + id); const comment = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, ''); - - comments.innerHTML = comments.innerHTML + comment; + + comments.insertAdjacentHTML('beforeend', comment); bs_trigger(comments); @@ -229,7 +229,7 @@ function post_comment(fullname, wall_user_id, hide){ let comments = document.getElementById('replies-of-' + fullname); let comment = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, ''); - comments.insertAdjacentHTML('beforebegin', comment); + comments.insertAdjacentHTML('afterbegin', comment); bs_trigger(comments); diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 9daeb4b09..b8f8a21a6 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -388,7 +388,8 @@ function update_ghost_div_textarea(text) if (!ghostdiv) return; ghostdiv.innerText = text.value.substring(0, text.selectionStart); - ghostdiv.innerHTML += ""; + + ghostdiv.insertAdjacentHTML('beforeend', ""); // Now lets get coordinates diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 09f5346cd..2cc25dee9 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -56,10 +56,12 @@ async function getGif(searchTerm) { for (let i = 0; i < 48; i++) { gifURL[i] = "https://media.giphy.com/media/" + data[i].id + "/giphy.webp"; if (data[i].username==''){ - container.innerHTML += ('
'); + const insert = '
' + container.insertAdjacentHTML('beforeend', insert); } else { - container.innerHTML += ('
'); + const insert = '
' + container.insertAdjacentHTML('beforeend', insert); } noGIFs.innerHTML = null; loadGIFs.innerHTML = '

Thou've reached the end of the list!

';