Skip to content

Commit dc0c358

Browse files
[JENKINS-73944] Extract inline event handler from POSTHyperlinkNote (jenkinsci#284)
1 parent f8d41ac commit dc0c358

File tree

2 files changed

+11
-1
lines changed
  • src/main
    • java/org/jenkinsci/plugins/workflow/support/steps/input
    • resources/org/jenkinsci/plugins/workflow/support/steps/input/POSTHyperlinkNote

2 files changed

+11
-1
lines changed

src/main/java/org/jenkinsci/plugins/workflow/support/steps/input/POSTHyperlinkNote.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public POSTHyperlinkNote(String url, int length) {
8383

8484
@Override protected String extraAttributes() {
8585
// TODO perhaps add hoverNotification
86-
return " onclick=\"fetch(decodeURIComponent(atob('" + encodeForJavascript(url) + "')), { method: 'post', headers: crumb.wrap({})}); return false\"";
86+
return " data-encoded-url='" + encodeForJavascript(url) + "' class='post-hyperlink-note-button'";
8787
}
8888

8989
/**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Behaviour.specify("A.post-hyperlink-note-button", "POSTHyperLinkNote", 0, function (element) {
2+
element.addEventListener("click", (event) => {
3+
event.preventDefault();
4+
const url = decodeURIComponent(atob(element.dataset.encodedUrl));
5+
fetch(url, {
6+
method: "post",
7+
headers: crumb.wrap({}),
8+
});
9+
});
10+
});

0 commit comments

Comments
 (0)