Skip to content
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

Change target to currentTarget in documentation for React forms #9279

Closed
wants to merge 1 commit into from
Closed

Change target to currentTarget in documentation for React forms #9279

wants to merge 1 commit into from

Conversation

huy-nguyen
Copy link

Because currentTarget is more appropriate
(https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget)
and it makes TypeScript typing works better
(DefinitelyTyped/DefinitelyTyped#12239 and
DefinitelyTyped/DefinitelyTyped#11508 (comment))

Before submitting a pull request, please make sure the following is done:

  1. Fork the repository and create your branch from master.
  2. If you've added code that should be tested, add tests!
  3. If you've changed APIs, update the documentation.
  4. Ensure the test suite passes (npm test).
  5. Make sure your code lints (npm run lint).
  6. Format your code with prettier (npm run prettier).
  7. Run the Flow typechecks (npm run flow).
  8. If you added or removed any tests, run ./scripts/fiber/record-tests before submitting the pull request, and commit the resulting changes.
  9. If you haven't already, complete the CLA.

@aweary
Copy link
Contributor

aweary commented Mar 29, 2017

Thanks for the PR @huy-nguyen! Can you share an example where using event.target for a text element (input, textarea) is incorrect? I understand using event.currentTarget in situations like the one described in DefinitelyTyped/DefinitelyTyped#11508 (comment) but in the case of inputs there are no child elements from which the event could originate.

It may also be worth nothing that currentTarget will change if you are listening during the capture phase, making it the wrong choice in some specific situations.

@huy-nguyen
Copy link
Author

Hi @aweary. Actually using target hasn't caused a problem for me. I just thought I'd suggest this change because it seems more appropriate and works better with the React's TS definition. I've never used an event listener in the capture phase before so I haven't thought of that use case.

@gaearon
Copy link
Collaborator

gaearon commented Apr 18, 2017

I'd like to leave it as is. Otherwise we'll keep getting PRs changing it back to target because currentTarget is not necessary here 😄 . If there's a problem with TS definition, please help fix it upstream. Thanks for the PR though!

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.

None yet

4 participants