-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Fix event handling when input name='nodeName' #6311
Conversation
Let's figure out the solution first and then fix the whole class of issues, whack-a-mole isn't fun (there's another method in that file which needs to be fixed anyway). |
@zpao Just fixed the other method (I assume that's the one you were referring to), also switched to the I think whack-a-mole is a little unavoidable in this case. Anywhere we assume that any attribute of an element exists (or rather, contains the expected value), it could break if the element happens to be a form. We just need to find them and squash them. |
@jimfb updated the pull request. |
There are still a bunch of other uses of |
Yeah, nodeName is mostly used for unit tests. It's only a problem when we're potentially going to run up against a form element (or window, with Ids). If you spot another one that you think will have a similar issue, feel free to flag it. At least this makes things incrementally better.
instanceof is faster than doing a typeof check (http://jsperf.com/wgerherherh/2), so this seems fine from a perf perspective. It's a pretty straight forward diff, so I think we should just push it forward. If we happen to discover that it's bad, we can always revert, but I think it's fine. If you have an idea of an alternative you would prefer, just say so. |
Might not have the same issue, but we should just use the same pattern. No point doing the same thing different ways when we know 1 has an issue and there are supposedly no tradeoffs. react/src/renderers/dom/client/ReactInputSelection.js Lines 33 to 36 in c528732
Also
|
To be clear: doing an instanceof check is slightly more expensive than doing a strcmp check. It's just much cheaper than doing a typeof.
We should avoid adding an instanceof check if we don't have a reason to believe we need it.
Not necessarily the right thing to do here. The point was that it's more expensive to first check that we have a string. We could probably add a devmode warning there if we wanted to. But in the 99% case, that container is going to be a The reason it made sense in the cases that I fixed is because we are traversing the DOM and if any of the nodes are forms with this problem, we fatal. In |
cc10815
to
1ba0464
Compare
@jimfb updated the pull request. |
👍 |
Aren’t |
Here’s a repro case for when the new version reports |
Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired. Before we can review or merge your code, we need you to email [email protected] with your details so we can update your status. |
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.
Changes requested above.
@jimfb Are you game for making the requested changes? Otherwise, I'm happy to pick this up. |
Fix event handling when input name='nodeName'. Fixes #6284
cc @zpao