Repository navigation
WW-5772 Remove inline event handlers from optiontransferselect, inputtransferselect, updownselect and combobox #2012
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ | |
| <#include "/${attributes.templateDir}/simple/text.ftl" /> | ||
| <br /> | ||
| <#if attributes.list??> | ||
| <select onChange="autoPopulate_${attributes.escapedId}(this);"<#rt/> | ||
| <select data-struts-combobox="${attributes.escapedId}"<#rt/> | ||
| <#include "/${attributes.templateDir}/${attributes.expandTheme}/css.ftl" /> | ||
| <#if attributes.disabled!false> | ||
| disabled="disabled"<#rt/> | ||
|
|
@@ -98,4 +98,17 @@ | |
| </option><#lt/> | ||
| </@s.iterator> | ||
| </select> | ||
| <@s.script> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Combobox takes a different route from the transfer selects: a per-instance inline script (with the nonce) rather than a static delegated listener. That works under a nonce-based CSP, but:
Fine to land as is; a static |
||
| (function () { | ||
| var selects = document.querySelectorAll('select[data-struts-combobox="${attributes.escapedId}"]'); | ||
| for (var i = 0; i < selects.length; i++) { | ||
| if (!selects[i].strutsComboboxBound) { | ||
| selects[i].strutsComboboxBound = true; | ||
| selects[i].addEventListener('change', function () { | ||
| autoPopulate_${attributes.escapedId}(this); | ||
| }); | ||
| } | ||
| } | ||
| })(); | ||
| </@s.script> | ||
| </#if> | ||
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.
Not introduced here, but worth knowing since the ticket says a header key with a quote now works: the key still goes through
compile(), which buildsnew RegExp("^" + ptn + "$")without escaping. A key like[nonemakes every button throwInvalid regular expression, and(none)doesn't match itself, so the header option gets moved/selected with the rest. The old inline handlers had the same behaviour, so no change needed in this PR.