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

Remove Event class #21

Open
wearhere opened this issue Jan 2, 2018 · 0 comments
Open

Remove Event class #21

wearhere opened this issue Jan 2, 2018 · 0 comments

Comments

@wearhere
Copy link
Contributor

wearhere commented Jan 2, 2018

We can just use the DOM Event class instead:

const e = new Event('event_name', { cancelable: true });
e.preventDefault();
console.log(e.defaultPrevented); // 'true'

Note that the third line there is technically a breaking change for SDK clients, from here—if they were reading that property vs. just calling preventDefault. But since they probably aren't and our usage is pretty low at the moment, if this is fixed in the near future, I'd just call the change a patch.

Another alternative to avoid making a breaking change is to do

Object.defineProperty(Event.prototype, 'isDefaultPrevented', {
  get() { return this.defaultPrevented; }
});
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

No branches or pull requests

1 participant