From 8e3e31a566c0d5e3dd25352d9b680357dc1aef7a Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 25 Mar 2024 06:30:38 +0200 Subject: [PATCH] Remove jQuery `.attr` from the reaction selector (#30052) - Switched from jQuery `attr` to plain javascript `getAttribute` - Tested the reaction selector and it works as before Signed-off-by: Yarden Shoham (cherry picked from commit 2e31a2800e1112ee0ab5a8d3c66b0fba2e737870) --- web_src/js/features/comp/ReactionSelector.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_src/js/features/comp/ReactionSelector.js b/web_src/js/features/comp/ReactionSelector.js index 6df4bde06..fc966c398 100644 --- a/web_src/js/features/comp/ReactionSelector.js +++ b/web_src/js/features/comp/ReactionSelector.js @@ -7,9 +7,9 @@ export function initCompReactionSelector($parent) { if ($(this).hasClass('disabled')) return; - const actionUrl = $(this).closest('[data-action-url]').attr('data-action-url'); - const reactionContent = $(this).attr('data-reaction-content'); - const hasReacted = $(this).closest('.ui.segment.reactions').find(`a[data-reaction-content="${reactionContent}"]`).attr('data-has-reacted') === 'true'; + const actionUrl = this.closest('[data-action-url]')?.getAttribute('data-action-url'); + const reactionContent = this.getAttribute('data-reaction-content'); + const hasReacted = this.closest('.ui.segment.reactions')?.querySelector(`a[data-reaction-content="${reactionContent}"]`)?.getAttribute('data-has-reacted') === 'true'; const res = await POST(`${actionUrl}/${hasReacted ? 'unreact' : 'react'}`, { data: new URLSearchParams({content: reactionContent}),