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

[IMPROVEMENT] Rewrite copyto in plain javascript #482

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

kfdm
Copy link
Collaborator

@kfdm kfdm commented Feb 19, 2024

As we work towards removing our dependence on jQuery, we want to rewrite our copyto helper in plain javascript

@kfdm kfdm requested a review from a team as a code owner February 19, 2024 00:15
document.querySelectorAll("[data-copyto]").forEach(srcElement => {
srcElement.style.cursor = "pointer";
srcElement.addEventListener("click", e => {
var dstElement = document.querySelector(srcElement.dataset.copyto);
Copy link
Contributor

Choose a reason for hiding this comment

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

I always recommend using const by default, unless the variable needs to be reassigned, in which case I recommend using let. In my opinion var should always be avoided.

That is my opinion on JS best practices, but you may have others, hence this comment is optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds reasonable. I think I just don't have enough awareness of javascript best practices since I don't write it as much. Changed to const but just force-pushed for the single, small change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Re-approved 👍

As we work towards removing our dependence on jQuery, we want to rewrite
our copyto helper in plain javascript
@kfdm kfdm merged commit 491c9b4 into line:master Feb 19, 2024
5 checks passed
@kfdm kfdm deleted the javascript-copyto branch February 19, 2024 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants