Skip to content

Conversation

pppp606
Copy link
Contributor

@pppp606 pppp606 commented Feb 28, 2022

When I copied the code example, there was an error, so I fixed it.
https://testing-library.com/docs/preact-testing-library/api/#example-1

buttonNode,
new Event('MouseEvent', {
bubbles: true,
cancelable: true,
Copy link
Member

@timdeschryver timdeschryver Feb 28, 2022

Choose a reason for hiding this comment

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

Thanks for the fix, though I would like to re-add the button property.

Suggested change
cancelable: true,
cancelable: true,
button: 0

button is a valid event property - https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button - and it's also implemented like this in fireEvent - https://github.com/testing-library/dom-testing-library/blob/main/src/event-map.js#L82.

Copy link
Member

Choose a reason for hiding this comment

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

@pppp606 is correct. There is no button property on Event. It is implemented on MouseEvent.
https://codesandbox.io/s/event-property-button-p6w8xh?file=/src/index.test.js

Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
@pppp606
Copy link
Contributor Author

pppp606 commented Mar 1, 2022

@timdeschryver @ph-fritsche
Thanks to both of you. I have committed the suggestion, please recheck pr.

@timdeschryver timdeschryver merged commit 64767ad into testing-library:main Mar 2, 2022
@timdeschryver
Copy link
Member

@all-contributors please add @pppp606 for docs

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @pppp606! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants