Skip to content

Improve test harness of submit events - #13463

Merged
philipp-spiess merged 4 commits into
react:masterfrom
philipp-spiess:submit-tests
Aug 22, 2018
Merged

philipp-spiess merged 4 commits into
react:masterfrom
philipp-spiess:submit-tests

Conversation

@philipp-spiess

Copy link
Copy Markdown
Contributor

This PR includes a test that I've enabled in #13358 and another test that we've discussed in #13462 as well as some random cleanup while I'm at it.

I found a test that was written more than 5 years ago and probably never
run until now. The behavior still works, although the API changed quite
a bit over the years.

Seems like this was part of the initial public release already:

react@75897c2#diff-1bf5126edab96f3b7fea034cd3b0c742R31
// This is a special case for submit and reset events as they are listened on
// at the element level and not the document.
// @see https://github.com/facebook/react/pull/13462
it('should not receive submit events if native, interim DOM handler prevents it', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test indeed fails if I re-apply my changes from #13358. If the onSubmit handler added a preventDefault(), this would never be called.

@gaearon gaearon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!


formRef.current.dispatchEvent(
new Event('reset', {
// https://developer.mozilla.org/en-US/docs/Web/Events/reset

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@philipp-spiess
philipp-spiess merged commit 3661616 into react:master Aug 22, 2018
@philipp-spiess
philipp-spiess deleted the submit-tests branch August 22, 2018 20:46
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
This PR includes a test that I've enabled in react#13358 and another test that we've discussed in react#13462 as well as some random cleanup while I'm at it.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
This PR includes a test that I've enabled in react#13358 and another test that we've discussed in react#13462 as well as some random cleanup while I'm at it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants