Skip to content

Commit

Permalink
Remove jQuery .attr from the reaction selector (#30052)
Browse files Browse the repository at this point in the history
- Switched from jQuery `attr` to plain javascript `getAttribute`
- Tested the reaction selector and it works as before

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
  • Loading branch information
yardenshoham authored Mar 25, 2024
1 parent 428e056 commit 2e31a28
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions web_src/js/features/comp/ReactionSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
Expand Down

0 comments on commit 2e31a28

Please sign in to comment.