Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery .attr from the user search box #29919

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions web_src/js/features/comp/SearchUserBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ const {appSubUrl} = window.config;
const looksLikeEmailAddressCheck = /^\S+@\S+$/;

export function initCompSearchUserBox() {
const $searchUserBox = $('#search-user-box');
const allowEmailInput = $searchUserBox.attr('data-allow-email') === 'true';
const allowEmailDescription = $searchUserBox.attr('data-allow-email-description');
const searchUserBox = document.getElementById('search-user-box');
if (!searchUserBox) return;

const $searchUserBox = $(searchUserBox);
const allowEmailInput = searchUserBox.getAttribute('data-allow-email') === 'true';
const allowEmailDescription = searchUserBox.getAttribute('data-allow-email-description') ?? undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we need to be aware that getAttribute returns null when not present, while jQuery returned undefined.

$searchUserBox.search({
minCharacters: 2,
apiSettings: {
Expand Down