Repository navigation
fix: fire lowercase event types for Preact 11 - #86
Merged
Merged
Conversation
Preact 11 always lowercases event names it listens for, whereas Preact 10 only did so when the element had a matching on* property. Detect which behavior the installed Preact has so fireEvent hits the listener for events jsdom has no on* property for (touch, animation, clipboard, ...).
Preact 10 always lowercases onFocusIn/onFocusOut, and preact/compat lowercases onAnimation*, onTransition*, onTouch*, onBeforeInput and onComposition* itself, so fireEvent dispatched a capitalised type that missed the listener in jsdom. Fixes #67
|
🎉 This PR is included in version 3.2.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preact 11 always lowercases event names before adding listeners (
onTouchStart→touchstart). Preact 10 only did that when the element had a matchingon*property, so in jsdom it listened forTouchStart, andfireEventcopied that by dispatching the capitalised type. On Preact 11 that misses the listener for every event jsdom has noon*property for (touch, animation, transition, clipboard, composition, pointerenter/leave, …): 17 tests inevents.jsfail.The same mismatch already existed on Preact 10 for:
focusIn/focusOut, which Preact 10 always lowercasespreact/compat, which lowercases those prop names itself (fireEvent.animationEnd does not call preact-registered listener #67)fireEventnow dispatches the lowercase type in those cases, and probes once whether the installed Preact always lowercases. The suite, including new focusIn/focusOut and compat tests, passes on both 10.29.8 and 11.0.1.Fixes #67
Investigated and authored with help from Claude (Opus 5.5).