Skip to content

Conversation

drorheller
Copy link
Contributor

@drorheller drorheller commented May 5, 2021

@drorheller drorheller changed the title Update api-events.mdx chore(docs): Update api-events.mdx May 5, 2021
@drorheller drorheller changed the title chore(docs): Update api-events.mdx chore(docs): Update api-events.mdx issue #842 May 5, 2021
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,
Copy link
Member

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).

Copy link
Contributor Author

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

Copy link
Member

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.

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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MatanBobi cool. adding

@eps1lon eps1lon merged commit f097e0e into testing-library:main May 5, 2021
@eps1lon
Copy link
Member

eps1lon commented May 5, 2021

@allcontributors
Copy link
Contributor

@eps1lon

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

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

Labels

None yet

4 participants