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

Invalid operand to 'in': Object expected. [SelectEventPlugin.js in IE9] #694

Closed
colingourlay opened this issue Dec 22, 2013 · 5 comments · Fixed by #771
Closed

Invalid operand to 'in': Object expected. [SelectEventPlugin.js in IE9] #694

colingourlay opened this issue Dec 22, 2013 · 5 comments · Fixed by #771

Comments

@colingourlay
Copy link

In IE9, when you use a button to trigger an event that deletes an element (containing that button), everything works as expected. However, if this event is an item in a list of similar elements, clicking the buttons in each element in quick succession triggers an error in this function:

if ('selectionStart' in node &&

The error is:

"Invalid operand to 'in': Object expected".

Using IE9's debugging tools I've been able to discover that in this situation, the node argument is null. I can't work out if there is a problem with React's DOM representation, but can confirm that this is only a problem when you make multiple clicks within a few hundred milliseconds of each other. Taking your time doesn't trigger the error.

Here's the website I'm getting this error on: http://colin-gourlay.com/25headlines. Try adding a few items, then removing them by clicking the X.

I'd submit a pull request that extends the condition in L66 to ensure node is an object, but I don't know enough about the overall architecture to know if the else blocks you currently have can handle this case, or if another is needed.

@syranide
Copy link
Contributor

It has something to do with double-clicks (as in the event), adjusting the double-click timeout in Windows makes the problem easier/harder to reproduce. So perhaps it's something with the synthetic events? If I recall correctly, double-clicks are a bit wonky in IE and perhaps the handling of that is broken.

After discussing a bit more in the chat, this most likely has to do with double-click triggering text selection, the element is then immediately removed and I'm guessing React tries to restore it for some reason, but the element is now gone, hence null as node.

@plievone
Copy link
Contributor

the element is now gone, hence null as node.

So the fix could involve the failing early return in constructSelectEvent or its call sites.

@syranide
Copy link
Contributor

@plievone Could I ask that temporarily switch to debug react.js so I can see the callstacks, it's understand exactly what's going on right now.

@sophiebits
Copy link
Collaborator

@colingourlay I can't reproduce in IE9 on your site. You're still seeing the problem?

sophiebits added a commit to sophiebits/react that referenced this issue Jan 1, 2014
Fixes facebook#694.

Previously, it could be that there was an active element that was removed in between mousedown and mouseup.
@syranide
Copy link
Contributor

syranide commented Jan 1, 2014

@spicyj Great!

The source of the problem here is actually that when double-clicking on an X, you switch to edit mode for the entry, and the input is then removed immediately which confuses React. I'm assuming you attached double-click to the wrong node, and double-clicking on the text and not the remove button is what should cause the entry to become editable.

yungsters added a commit that referenced this issue Jan 10, 2014
Don't get selection if no active element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants