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

Fallback to event.srcElement for IE9 #12976

Merged
merged 1 commit into from Jun 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/react-dom/src/events/getEventTarget.js
Expand Up @@ -15,7 +15,9 @@ import {TEXT_NODE} from '../shared/HTMLNodeType';
* @return {DOMEventTarget} Target node.
*/
function getEventTarget(nativeEvent) {
let target = nativeEvent.target || window;
// Fallback to nativeEvent.srcElement for IE9
// https://github.com/facebook/react/issues/12506
let target = nativeEvent.target || nativeEvent.srcElement || window;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we have an internal unit test for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd really like to track down the reason for this so we don't accidentally remove it again as well. Everything I can find suggests that srcElement should not be needed in IE9, so I'm wondering where the issue is coming from. I haven't found much some-places suggest that when attachEvent is used it follows the ie8 event model (with target undefined), I wonder if some branches are still hitting attachEvent?

Copy link
Contributor

Choose a reason for hiding this comment

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

the change polyfill uses it, Perhaps that's the root cause? I think we could use addEventListener there...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting... I actually remove that listener in #12505. I'll hunt!

Copy link
Contributor

Choose a reason for hiding this comment

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

My other guess is that maybe it's like a quirksmode sort of thing, where folks are seeing something in document mode they don't realize they are in, in ie9 :/


// Normalize SVG <use> element events #4963
if (target.correspondingUseElement) {
Expand Down