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

chore(syntheticEvent): remove IE8 code #11178

Merged
merged 8 commits into from
Oct 12, 2017
Merged

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Oct 10, 2017

Since IE8 has been deprecated for a while, I thought it might be useful to remove some IE8-only code

If this is not something you want to focus on yet, or is too much work to test, feel free to close this PR

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. Format your code with prettier (npm run prettier).
  6. Make sure your code lints (npm run lint).
  7. Run the Flow typechecks (npm run flow).
  8. If you haven't already, complete the CLA.

Since IE8 has been deprecated for a while, I thought it might be useful to remove some IE8-only code

If this is not something you want to focus on yet, or is too much work to test, feel free to close this PR
} else {
return window;
}
return doc.defaultView;
Copy link

Choose a reason for hiding this comment

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

Should return target.ownerDocument.parentWindow immediately.

@gaearon
Copy link
Collaborator

gaearon commented Oct 10, 2017

We’ll need someone to verify this is only the case in IE8, and not IE9+.

@Haroenv
Copy link
Contributor Author

Haroenv commented Oct 10, 2017

If I read MDN correctly, it's added in IE9, but should definitely be tested thoroughly

@gaearon
Copy link
Collaborator

gaearon commented Oct 10, 2017

MDN says ownerDocument has been around since IE6: https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument

MSDN also doesn’t mention any version support differences: https://msdn.microsoft.com/library/ms534315(v=vs.85).aspx

So there’s clearly something else happening here.
It would help to dig into the git history to see when this was added.

} else {
return window;
}
return target.ownerDocument.defaultView;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you could still have cases where ownerDocument is undefined, e.g. if the node is detached (for some reason)

Copy link
Contributor

Choose a reason for hiding this comment

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

This whole block might be able to go away, it looks like IE9 supports event.view:

screen shot 2017-10-11 at 7 24 17 am

I'll do some testing. MDN isn't comprehensive on support here:

screen shot 2017-10-11 at 7 24 57 am

Maybe we can fix that :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep! UIEvent.view is supported in:

IE9-11
Safari Desktop 4, 5.1, 6.2, 7.1, 10.1, 11.0
Safari iOS 3, 4
FF 47
Windows Phone 8.1

Here's my test case:
https://codepen.io/nhunzaker/pen/BwVwqo

And I've submitted a revision to this page on MDN:
https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view

@Haroenv
Copy link
Contributor Author

Haroenv commented Oct 10, 2017

defaultView was added in IE9 preactjs/preact-compat#423, maybe I misread the comment, and there's no code to remove here 🤔

@syranide
Copy link
Contributor

parentWindow is fallback for IE8 I believe and should be redundant. The rest is not IE8-specific though I'm sure.

Copy link
Contributor

@nhunzaker nhunzaker left a comment

Choose a reason for hiding this comment

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

According to my research (https://github.com/facebook/react/pull/11178/files#r143985409), we can totally remove the event.view polyfill.

Could you remove the event.view entry?

@nhunzaker
Copy link
Contributor

nhunzaker commented Oct 11, 2017

I did some testing of detail while we're in here. Here's what I found:

IE9-11
* BUG: IE11 always reports 0

IE Edge 14, 15

Safari Desktop 4, 5.1, 6.2, 7.1, 8, 9.1, 10.1, 11.0

Safari iOS 3, 4, 9, 10.3
* Doubleclick is hard on iOS

FF 47

Windows Phone 8.1
* BUG: Always reports 0

Chrome 27-61

Firefox 11-56

Opera 12.12-48

So basically everywhere except below IE9. IE 11/Windows Phone always reports 0 for detail, but we don't attempt to fix this in React.

We should remove the patch for event.detail

@Haroenv
Copy link
Contributor Author

Haroenv commented Oct 11, 2017

@nhunzaker, so I can remove all the code after if (event.view) return event.view?

} else {
return window;
}
return event.view;
},
detail: function(event) {
return event.detail || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe, unless I'm mistaken, this can be:

var UIEventInterface = {
  view: null,
  detail: null
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the var can be completely removed then? and not augmenting the class?

@Haroenv
Copy link
Contributor Author

Haroenv commented Oct 11, 2017

I did the augment with twice null @nhunzaker, I tried removing it completely, but that made the whole test suite cry, so I guess it depended on it being augmented.

@nhunzaker
Copy link
Contributor

Yeah, I think it's essential. Thank you for your contribution!

@jquense, @aweary, or @syranide. I've confirmed basic support for these two properties everywhere, can you think of anything else we should check before I merge this?

@blling
Copy link

blling commented Oct 11, 2017

Why should not removing it completely ?

@nhunzaker
Copy link
Contributor

@blling synthetic events maintain an interface so that they can copy over properties. It does that here:
https://github.com/facebook/react/blob/master/src/renderers/shared/shared/event/SyntheticEvent.js#L90-L107

The keys can't be completely removed because they tell SyntheticEvent to copy over those attributes from the original DOM event.

@blling
Copy link

blling commented Oct 11, 2017

Get it, thanks!

@syranide
Copy link
Contributor

syranide commented Oct 12, 2017

@nhunzaker 👍

@nhunzaker nhunzaker merged commit 0c5a455 into facebook:master Oct 12, 2017
@nhunzaker
Copy link
Contributor

Thanks, @Haroenv!

@Haroenv Haroenv deleted the patch-1 branch October 12, 2017 21:38
@Haroenv
Copy link
Contributor Author

Haroenv commented Oct 12, 2017

Thanks for your guidance @nhunzaker

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.

7 participants