-
Notifications
You must be signed in to change notification settings - Fork 727
chore(docs): Update api-events.mdx issue #842 #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -121,6 +121,8 @@ programmatically (such as `timeStamp`). | |||
const myEvent = createEvent.click(node, { button: 2 }) | |||
fireEvent(node, myEvent) | |||
// myEvent.timeStamp can be accessed just like any other properties from myEvent | |||
// note: The access to the events created by `createEvent` is based on the native event API, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be best to add a reference to the native event API (https://developer.mozilla.org/en-US/docs/Web/API/Event).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatanBobi I think that this citation is more for users of the testing library, I'm not sure that in the native API you would even need to change the timestamp in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, I agree with you.. But since not all testing library users will be 100% familiar with the event API, I suggested to add a link to it.
@@ -121,6 +121,8 @@ programmatically (such as `timeStamp`). | |||
const myEvent = createEvent.click(node, { button: 2 }) | |||
fireEvent(node, myEvent) | |||
// myEvent.timeStamp can be accessed just like any other properties from myEvent | |||
// note: The access to the events created by `createEvent` is based on the native event API, | |||
// Therefore, native properties of HTMLEvent object (e.g. `timeStamp`) should be set using Object.defineProperty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably also add that only some properties need to be changed using Object.defineProperty
as there are no setters in the native implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatanBobi that's why I said "native" properties, but I'm honestly not exactly sure about the exact list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in this page which has Read only
on it can't be changed without using Object.defineProperty
:)
I don't mean to add a list, maybe just some examples. As all properties are the native properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatanBobi cool. adding
@drorheller Thanks! @all-contributors Add @drorheller for docs |
I've put up a pull request to add @drorheller! 🎉 |
Closes testing-library/dom-testing-library#842