Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 09:54:24 +01:00

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 <git@yardenshoham.com>
(cherry picked from commit 2e31a2800e1112ee0ab5a8d3c66b0fba2e737870)
This commit is contained in:
Yarden Shoham 2024-03-25 06:30:38 +02:00 committed by Earl Warren
parent 8557c6ae43
commit 8e3e31a566
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -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}),