Skip to content

Commit

Permalink
Add isDefaultPrevented fn to event
Browse files Browse the repository at this point in the history
  • Loading branch information
teodragovic committed Feb 28, 2020
1 parent afb350f commit 72a283b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions compat/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ let oldEventHook = options.event;
options.event = e => {
if (oldEventHook) e = oldEventHook(e);
e.persist = () => {};
e.isDefaultPrevented = () => e.defaultPrevented;
return (e.nativeEvent = e);
};

Expand Down
1 change: 1 addition & 0 deletions compat/test/browser/events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('preact/compat events', () => {
const event = spy.args[0][0];
expect(event).to.haveOwnProperty('persist');
expect(event).to.haveOwnProperty('nativeEvent');
expect(event).to.haveOwnProperty('isDefaultPrevented');
expect(typeof event.persist).to.equal('function');

expect(() => event.persist()).to.not.throw();
Expand Down

0 comments on commit 72a283b

Please sign in to comment.