Repository navigation
fix: allow read-only event properties like detail in trigger options - #3082
Merged
cexbrayat merged 1 commit intoDec 4, 2026
Conversation
`trigger('click', { detail: 2 })` threw "Cannot set property detail of
[object UIEvent] which has only a getter": the options are assigned to
the event after it is created, and only the closest prototype was
checked for read-only properties, while `detail`, `view` or `which`
are getters on `UIEvent.prototype` and `composed` on `Event.prototype`.
The constructor already receives these options, so `Reflect.set` is
used to skip the ones that cannot be assigned instead of throwing.
👷 Deploy request for vue-test-utils-docs pending review.Visit the deploys page to approve it
|
commit: |
cexbrayat
approved these changes
Dec 4, 2026
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.
A test for a double click handler that reads
event.detail:throws
TypeError: Cannot set property detail of [object UIEvent] which has only a getterand the handler is never called (playground, VTU 2.6.0). The same happens withview,which,composed,bubblesorisTrusted, and withdetailon keyboard, focus, wheel, pointer and touch events, in jsdom and in the browser.createDOMEventpasses the options to the event constructor and then assigns them to the event, skipping only the getters of the closest prototype (MouseEvent.prototype).detail,viewandwhichare getters onUIEvent.prototype,composedonEvent.prototype, so the assignment throws.The assignment now uses
Reflect.set, which returnsfalseinstead of throwing for these properties. The constructor already received them, and everything that was assigned before is still assigned.I also rewrote the
only defines the properties the event rejectstest from #3043: it expected theTypeErrorfromcurrentTarget: {}, which was this bug. It now checks that the handler gets therelatedTargetfrom the options and the realcurrentTarget.