-
Notifications
You must be signed in to change notification settings - Fork 26
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
JENKINS-73971 Extract event handlers in NestedViewsSearch/search-results #48
Conversation
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.
This is really great, as it gets us halfway to the finish line. To complete this task, we need to remove the onclick=
HTML attribute, and instead set it programmatically from searchscripts.js
. To do that, you'll need to use either document.addEventListener('DOMContentLoaded', …)
or Behaviour#specify
(as described in https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers) to write some code that runs when the page loads. That code should find the <a>
elements whose onclick
handlers were removed (e.g. through document.querySelector
and iterating by class name or ID), then add a new onclick
handler with element.addListener("click", ...)
. For an example, see:
jenkinsci/scriptler-plugin#120
Once that is done and the result is tested, I am happy to approve this PR.
@@ -0,0 +1,17 @@ | |||
// <![CDATA[ |
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.
CDATA is not needed here. or on line 16.
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.
Unless you insists, I will keep it there. I like when code is somehow wrapped, and on contrary I do nt ot like the JS's myNameSapce = function () {
notation... Anyway.. Yah my bad habit:(
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.
OK, no big deal either way.
Ah sure. Will do. |
moving adjunct after creation of elements
@basil done sir! |
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.
This is looking almost done. The only task I think is remaining is to follow this advice from the CSP documentation:
For event handlers like
onclick
that used to callreturn false
to prevent the usual action (e.g. link navigation) from happening, add a call toEvent.preventDefault()
in a separate event handler on the providedEvent
argument.
For an example, see:
jenkinsci/workflow-job-plugin#477
After that is done, I think this change is ready to ship.
This is quite educational PR. TY! |
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.
Thanks for the PR! I trust you can confirm this is all working as expected by manually testing the UI.
yup, I did. In adition unittests did its job susprisngly well. ty! |
Thank you very much! |
https://issues.jenkins.io/browse/JENKINS-73971