-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reorganize comment.js & dragdrop.js Script-Loading #9037
Reorganize comment.js & dragdrop.js Script-Loading #9037
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9037 +/- ##
=======================================
Coverage ? 82.05%
=======================================
Files ? 100
Lines ? 5939
Branches ? 0
=======================================
Hits ? 4873
Misses ? 1066
Partials ? 0 |
@@ -1,5 +1,4 @@ | |||
(function() { | |||
|
|||
$(function() { | |||
$('.comment-form').each(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that all along, these eventHandlers weren't being attached on document.load!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch 🎉
Code Climate has analyzed commit 7a1b0f2 and detected 0 issues on this pull request. View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Looks great! Shall we merge? Omg event listeners initialization is such a common JS bug!!! 😭😂🎉 |
@jywarren Yep, ready to merge! |
🎉 🎉 🎉 🎉 |
…b#9037) * move comment.js & dragdrop.js to higher-level views publiclab#9004 * attach eventListeners on document.load publiclab#9004 * move dragdrop.js & comment.js to notes/comments partial publiclab#9004
…b#9037) * move comment.js & dragdrop.js to higher-level views publiclab#9004 * attach eventListeners on document.load publiclab#9004 * move dragdrop.js & comment.js to notes/comments partial publiclab#9004
…b#9037) * move comment.js & dragdrop.js to higher-level views publiclab#9004 * attach eventListeners on document.load publiclab#9004 * move dragdrop.js & comment.js to notes/comments partial publiclab#9004
…b#9037) * move comment.js & dragdrop.js to higher-level views publiclab#9004 * attach eventListeners on document.load publiclab#9004 * move dragdrop.js & comment.js to notes/comments partial publiclab#9004
Part of an object-oriented refactoring of the Comment Editor. See #9004 for more details.
Currently
comment.js
anddragdrop.js
are loaded once per every comment form on a page:plots2/app/views/comments/_form.html.erb
Lines 107 to 110 in f0be879
They really only need to be loaded once per page (not 5 times on a page with 5 comments)!
Both scripts (but particularly
dragdrop.js
) have eventListeners which can get attached multiple times to the same element if each script is loaded multiple times.Simplifying the script loading is going to help with refactoring
editor.js
.(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)