Repository navigation
Fix "event is not a function" error on My Payment Methods page - #867
Conversation
|
Hi @agibson-godaddy , I’ve opened a framework fix for MWC-20379: #867. A missing pair of parentheses in the My Payment Methods CoffeeScript (.on 'click', event ->) throws “event is not a function” for any customer with a saved payment method. It affects every plugin bundling framework 6.2.4, and I confirmed it on Authorize.Net. It’s a one-liner plus the rebuilt dist. Two questions: should this go out as 6.2.5 with #864 or on its own, and who triggers the framework release? I’ve cut release/3.10.22 for Authorize.Net (#152) and will pin the new framework version in the story PR once it’s tagged. |
|
Tested this branch (7fae387) in WooCommerce Authorize.Net Gateway 3.10.22-dev.1, installed via a zip built from the branch’s own dist. On My Account > Payment Methods with a saved method, there is no event is not a function error in the console. The disabled “Add payment method” button no longer navigates while a method is being edited. Nickname save/cancel, set default, and delete (Cancel and OK) all work as before. Local PHPUnit errors identically (18 of 26) with and without this change on PHP 8.5 |
* Version 6.2.5 * Fix "event is not a function" error on My Payment Methods page (#867) * Fix event handler syntax error on My Payment Methods page (MWC-20379) * Update changelog --------- Co-authored-by: Ashley Gibson <agibson@godaddy.com> * Add additional nonce & capability checks (#869) * Add nonce checks to notice dismissal * Add capaiblity check to batch handling * Add changelog entry * Change since version * Fix false _doing_it_wrong in ScriptHelper::addInlineScript() on WP 6.9+ block editor (#864) * Update class-sv-wc-admin-notice-handler.php * Add fallback for wp_print_inline_script_tag function Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Updated Tests * Code updates to address Ashely's comment * Update ScriptHelperTest to correct failing tests * Update namespace * Customize messaging based on required hook * Update changelog --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ashley Gibson <agibson@godaddy.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: smoen-godaddy <76167060+smoen-godaddy@users.noreply.github.com> Co-authored-by: Ashley Gibson <agibson@godaddy.com> Co-authored-by: Ashley Gibson <99189195+agibson-godaddy@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Fixes an uncaught
TypeError: event is not a functionthrown by the My Payment Methods handler whenever a customer has at least one saved payment method.Story: MWC-20379
Release: TBD
Details
In
sv-wc-payment-gateway-my-payment-methods.coffee, the click handler for the "Add payment method" button was written as.on 'click', event ->. Without parentheses, CoffeeScript compiles this to.on('click', event(function() {...})), a call towindow.event, which isn't a function. The constructor throws at that line, so the handler never finishes setting up and the guard that stops a disabled "Add payment method" button from navigating is never registered.The fix adds the missing parentheses:
.on 'click', ( event ) ->. The thin arrow is kept because the body relies on$( this )being the clicked button. Thedistasset and source map are rebuilt.The error only appears when a saved method exists, because WooCommerce only renders the payment methods table then. Other framework-based gateways bundling an affected version are likely affected too.
UI Changes
None.
QA
Setup
Steps
event is not a functionerror is loggedBefore merge