Skip to content

Let Wicket.Event.remove remove a listener added for several event types - #1648

Merged
papegaaij merged 1 commit into
masterfrom
event-remove-multiple-types
Oct 5, 2026
Merged

papegaaij merged 1 commit into
masterfrom
event-remove-multiple-types

Conversation

@papegaaij

Copy link
Copy Markdown
Contributor

Fixes #1646.

Wicket.Event.add in wicket-ajax-jquery.js recorded a listener under the whole type string, e.g. 'input change'. Wicket.Event.remove splits the type on whitespace before looking it up, so it never found a listener added for several types and unbound nothing. This is a regression from 10.x, where remove delegated to jQuery#off.

add now records the listener under each type separately, as wicket-ajax.js already does. That makes removal work for all the types at once and for each type on its own. Wicket's own code always adds one type at a time, so only application scripts are affected.

Tests: three QUnit tests in wicket-core/src/test/js/event.js, run against both engines. They cover removing all of the types, removing just one of them, and removing by type without a handler. All three fail on master's wicket-ajax-jquery.js and pass with the fix. mvn clean verify -Pjs-test is green.

🤖 Generated with Claude Code

Wicket.Event.add in wicket-ajax-jquery.js accepts several space separated
event types, as jQuery#on does, but it recorded the listener in its
registry under the type string exactly as given, e.g. 'input change'.
Wicket.Event.remove splits its type on whitespace and looks the listener
up per type, so it found nothing and unbound nothing:
remove(el, 'input change', fn), remove(el, 'input', fn) and
remove(el, 'input change') all left both events bound. Only remove(el),
without any type, still worked.

This is a regression from 10.x, where remove delegated to jQuery#off,
which handles several types. The jQuery-free wicket-ajax.js was not
affected, because its add already records each type separately.

add now does the same, so removing a listener works for all of its
types at once and for each one on its own. Wicket's own code always adds
one type at a time, so only application scripts that add a listener for
several types and remove it again see a difference: the listener is now
removed.

GitHub issue #1646

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@papegaaij papegaaij added the javascript Pull requests that update Javascript code label Oct 5, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.94%. Comparing base (ee62ec8) to head (967e9f0).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1648      +/-   ##
============================================
- Coverage     61.95%   61.94%   -0.01%     
- Complexity    11280    11281       +1     
============================================
  Files          1250     1250              
  Lines         48429    48429              
  Branches       6792     6792              
============================================
- Hits          30002    30000       -2     
- Misses        15729    15730       +1     
- Partials       2698     2699       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@reiern70 reiern70 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@papegaaij
papegaaij merged commit ca7a28c into master Oct 5, 2026
3 checks passed
@papegaaij
papegaaij deleted the event-remove-multiple-types branch October 5, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wicket.Event.remove does not remove a listener added for several event types

3 participants