-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Update buildMouseEvent to use MouseEvent constructor if it is present #387
Conversation
} catch (e) { | ||
// left intentionally blank |
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.
Hmm, aren’t some errors valid here? E.g. when MouseEvent
is present but you pass invalid options or something?
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.
maybe we could make a constant in module scope to track if `MouseEvent‘ is functional, then remove the try/catch inline?
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.
Was following the pattern from buildKeyboardEvent, but I agree that the solution where checking if MouseEvent exists is better
@@ -1,5 +1,15 @@ | |||
import { merge } from '@ember/polyfills'; | |||
|
|||
// eslint-disable-next-line require-jsdoc | |||
function checkMouseEventExistence() { | |||
try { |
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.
can you memoize this?
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.
Do you have an example of where else Memoization it is done in this repo? Or another example I can emulate?
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.
Something like:
const MOUSE_EVENT_CONSTRUCTOR = (() => {
try {
new MouseEvent(‘test’);
return true;
} catch(e) {
return false;
}
})();
Bump? |
It looks good to me. /cc @rwjblue |
Closes #266 by using the
MouseEvent
constructor inbuildMouseEvent
if it is present. Otherwise, it falls back to the existinginitMouseEvent
function for compatibility with IE 9/10